Rx validation of checksum


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    17

    Default Rx validation of checksum

    Code:
    CALC_Checksum1:
        Checksum1 = 0
        WORD_HOLD = 0
        for i = 3 to MAX_LEN
           Word_Hold = Word_Hold + tx_data1(i)
         next 
         Checksum1 = WORD_HOLD.byte0 ^ $FF
        RETURN
    
    CALC_Checksum2:
        Checksum2 = 0
        for i = 3 to MAX_LEN
           Checksum2 = Checksum2 + tx_data1(i)
        next 
        Checksum2 =  Checksum2 // 256
       'Checksum2 = -Checksum2
        RETURN
    the above routines i pieced together from other posts here to genereate a checksum for transimitted data packets.

    to validate on the received end, do i run the same routine and compare values to see if the checksums are equal?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default

    Yes you do.

    But instead of this double checksum i'd prefer the 16 bit CRC check. More reliable.

    Look here for the fast sub routine from the usual suspect:

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

    Ioannis

  3. #3
    Join Date
    Jan 2009
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Thanks Ioannis.

    Indeed, DT's looks quite fast. a handy routine i'll "borrow" into me tool box.

    btw, i would use [either or] of my sub-routines, not both at the same time.

    Cheers!

Similar Threads

  1. NMEA CheckSum Routine
    By Tom Gonser in forum Code Examples
    Replies: 2
    Last Post: - 6th June 2015, 22:24
  2. 4 Bytes one button press
    By Dennis in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th January 2010, 22:36
  3. Checksum
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th October 2009, 04:09
  4. Creating Checksum in PBP
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th March 2005, 04:49
  5. Checksum problem!
    By atomski in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd November 2004, 07:21

Members who have read this thread : 0

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