Need to convert C to PBP


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Location
    Kent, UK
    Posts
    52

    Default Need to convert C to PBP

    I am trying to write some code in PBPpro from an example in C.
    I have got so far but am not familiar with C.
    They give the packet structure and an example, but I cannot decipher what the code is doing before retrieving a value from a lookup table, and hopefully someone will be able to assist me here.

    Any help greatly appreciated.

    By the way, attachment is copyright Atomos Pty, Australia.


    Code:
    CHKSUM		VAR LONG
    VALUE		VAR LONG
    COMMAND		VAR WORD
    SIZE		        VAR WORD
    TEMP_W		VAR WORD
    TEMP_B		VAR BYTE
    BUFFER		VAR BYTE [21]
    
    SEND:		 SIZE = $14
    			COMMAND = 0
    			VALUE = 1
    			
    			BUFFER [1] = SIZE.BYTE1
    			BUFFER [2] = SIZE.BYTE0
    			BUFFER [3] = COMMAND.BYTE1
    			BUFFER [4] = COMMAND.BYTE0
    			BUFFER [5] = $FF
    			BUFFER [6] = $FF
    			BUFFER [7] = $FF
    			BUFFER [8] = $FF
    			BUFFER [9] = $FF
    			BUFFER [10] = $FF
    			BUFFER [11] = $FF
    			BUFFER [12] = $FF
    			BUFFER [13] = VALUE.BYTE3
    			BUFFER [14] = VALUE.BYTE2
    			BUFFER [15] = VALUE.BYTE1
    			BUFFER [16] = VALUE.BYTE0
    			
    			SOMEVALUE = ' <insert converted C code here >
    			GOSUB LOOK_CHKSUM
    			
    			BUFFER [17] = CHKSUM.BYTE3
    			BUFFER [18] = CHKSUM.BYTE2
    			BUFFER [19] = CHKSUM.BYTE1
    			BUFFER [20] = CHKSUM.BYTE0
    			
    			
    			FOR TEMP_W = 1 TO SIZE
    				TEMP_B = BUFFER [TEMP_W]
    				HSEROUT [TEMP_B]
    			NEXT
    			GOTO MAIN_LOOP
    			
    			
    LOOK_CHKSUM:
                            LOOKUP2 SOMEVALUE,_
    				[$0000, $1021, $2042, etc ], CHKSUM
    			RETURN

  2. #2
    Join Date
    Apr 2011
    Location
    Kent, UK
    Posts
    52


    Did you find this post helpful? Yes | No

    Default Re: Need to convert C to PBP

    Dohh... Here is the attachment.
    Attached Images Attached Images

  3. #3
    Join Date
    Jun 2010
    Location
    Venezuela
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: Need to convert C to PBP

    hi timmers, you example is for calculate cyclic redundancy check (CRC16). look here two example one using Vb6 the another one with PBP. i use both

    http://www.picbasic.co.uk/forum/showthread.php?t=16735

    here explain how to that:

    http://en.wikipedia.org/wiki/Computation_of_CRC

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Need to convert C to PBP

    I am still struggling to learn C myself so what I say here MAY BE TOTALLY INCORRECT.

    const u16 crc_16_table[0x100]

    const u16 = dataType , crc_16_table = varName, [0x100] = startMemLocation, & this can be put into program memory with PROGMEM command at least in arduino.
    HTH
    Last edited by Archangel; - 6th August 2012 at 06:51.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts