element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Amphenol
  • Products
  • Manufacturers
  • Amphenol
  • More
  • Cancel
Amphenol
Forum How to do a Double Byte XOR Checksum?
  • Blog
  • Forum
  • Documents
  • Events
  • Leaderboard
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Amphenol to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 10 replies
  • Subscribers 22 subscribers
  • Views 4633 views
  • Users 0 members are here
  • checksum
  • data packets
  • serial communication
Related

How to do a Double Byte XOR Checksum?

Sean_Miller
Sean_Miller over 5 years ago

I have a data packet that states its data validation (check code) is verified by a double byte XOR.  I've Googled for a tutorial and came up empty.  I've tried to solve the puzzle in Excel to never get a match to serial data I captured with Putty.  I could use a tip on how the algorithm to apply.

 

The packet description is below.  Starting at position 8, the two byte CS item contains the check code and states it uses a double-byte XOR to verify the current data packet.  I've tried adding up all bytes starting at Si in series which equates to a two byte value.  I XOR it against the CS value I've assed to be xC4AD, but that didn't resolve to 0.

 

Should I be XORing blocks of 2 bytes and comparing to the CS value? 

 

 

image

 

image

 

Example packet:

        

AA 55 00 28 85 AE 9D 0C AD C4 00 00 00 00 00 00 32 00 00 2A 12 59 12 00 00 00 00 A6 1F E5 1F 8D 1F 6D 1F 0A 17 7D 17 62 55 09 1D B1 10 31 10 4D 10 7A 0F 61 0F 5D 0F 21 0F 19 0F 31 0F 49 0F 8D 0F 4E 6D 6D 1D 82 0D 84 0D 00 00 AE 1A 9D 1A 89 1A
  • Sign in to reply
  • Cancel

Top Replies

  • neuromodulator
    neuromodulator over 5 years ago +1
    It might be some parity check. Try to XOR all blocks of 2 bytes and check what you get
  • neuromodulator
    neuromodulator over 5 years ago +1
    Check the last part of the document: http://www.ydlidar.com/Public/upload/files/2019-12-18/YDLIDAR%20X2%20Development%20Manual.pdf It's poorly written, but they say that in case of 3 bytes 1 byte get padded…
  • neuromodulator
    neuromodulator over 5 years ago +1
    Leave the lidar scanning for a while and letme know if you find a checksum error. I suspect thst you wont
  • neuromodulator
    neuromodulator over 5 years ago

    It might be some parity check. Try to XOR all blocks of 2 bytes and check what you get

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Sean_Miller
    Sean_Miller over 5 years ago in reply to neuromodulator

    Tried it, but still didn't land on the check code given in the packet.

     

    But first, I found that the number of sample points was 9 bytes short in my original packet I was assessing.  The LS value says there should be 40 sample points.  So, I extracted from the stream of serial data a segment that had 80 bytes after the CS packet item.  This should be correct since each sample point is made of two bytes (80/2=40).

     

    In the new packet shown below, the check code is 0x0E63

     

    I made this routine in Excel to process the double byte XORs.  Unfortunately, it gives C7 01 or 0x01C7 in little endian format.

     

    Here's the algorithm:

    1. pass a comma delimited string of decimal values representing the original hex data
    2. split the string into a string array representing each byte in succession
    3. loop through the string array to create two arrays of bytes to process.  The arrays represent a left side column and a right side column to process.
    4. loop through the newly formed columns to xor each side
    5. present the answer in a message box

     

    I'm wondering if step 4 is where I'm not thinking right on processing it????

     

    Sub doer()
        MsgBox (my_checksum("0,0,182,12,228,12,30,5,29,5,0,0,50,13,0,0,0,0,36,13,4,13,244,12,228,12,216,12,204,12,201,12,185,12,177,12,169,12,165,12,161,12,153,12,153,12,149,12,149,12,145,12,145,12,145,12,145,12,145,12,149,12,157,12,161,12,161,12,165,12,177,12,181,12,193,12,197,12,208,12"))
    End Sub
    Function my_checksum(str As String) As String
        Dim bytes() As String
        Dim left_byte(100) As Byte
        Dim right_byte(100) As Byte
        Dim left_xor As Byte
        Dim right_xor As Byte
        Dim tt As Integer
        
        bytes = Split(str, ",")
        
        ' tt will index the new byte array we parse
        tt = 0
        ' Convert the strings to integers and then to bytes.  Make a left column and right column to process next with the xor operation
        For ii = 0 To UBound(bytes) - 1 Step 2
            left_byte(tt) = CByte(CInt(bytes(ii)))
            right_byte(tt) = CByte(CInt(bytes(ii + 1)))
            tt = tt + 1
        Next
        
        ' tt will now represent the upper bound of our byte arrays below
        tt = tt - 1
        
        
        left_xor = 0
        right_xor = 0
        
        ' perform the xor operation in double byte fashion
        For ii = 0 To tt
            left_xor = left_xor Xor left_byte(ii)
            right_xor = right_xor Xor right_byte(ii)
        Next
        
        my_checksum = ((Hex(left_xor) & " " & Hex(right_xor)))
    End Function

     

     

      

    Hex00B60CE40C1E51D500320D0000240D40DF40CE40CD80CCC0CC90CB90CB10CA90CA50CA10C990C990C950C950C910C910C910C910C910C950C9D0CA10CA10CA50CB10CB50CC10CC50CD00C
    Decimal001821222812305295005013000036134132441222812216122041220112185121771216912165121611215312153121491214912145121451214512145121451214912157121611216112165121771218112193121971220812
    PHCTLSFSALSACSS1S2
    012345678910111213
    AA550028F931F743630E0000B60C...
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • neuromodulator
    neuromodulator over 5 years ago

    Check the last part of the  document: http://www.ydlidar.com/Public/upload/files/2019-12-18/YDLIDAR%20X2%20Development%20Manual.pdf

     

    It's poorly written, but they say that in case of 3 bytes 1 byte get padded with 0s in the MSB. Maybe the same applies to single byte fields? As you receive the data, I would just ignore this, the chances that data is corrupted are probably very low. To test how frequent data gets corrupted I would keep the lidar running for a lot of time while recording the data. After a long log I would check the data, if there are no outliers, data is probable ok.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Fred27
    Fred27 over 5 years ago

    I've been having a poke around and can't come up with anything different to you. Is there any other information?

     

    I found some info on CRC using XORs but that also needs a lookup table: https://en.wikipedia.org/wiki/Cyclic_redundancy_check

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Sean_Miller
    Sean_Miller over 5 years ago in reply to neuromodulator

    Woa...I definitely didn't read down far enough.  I assumed the check code started for the sample data, but rather, its a mess of a combination with all data in the packet excluding the Check Code itself.

     

    This is like sudoku for me, so, I'm going to give it another couple of hours and see if I can crack it.  If I do, I'll post the code.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Sean_Miller
    Sean_Miller over 5 years ago in reply to Sean_Miller

    Hot Dog!  Got it.

     

    I have no idea why the docs have that confusing statement "since sample data is 3 bytes".  It doesn't say that its 3 bytes anywhere else in the document.  So, I didn't do anything with that.  I just dropped the check code bytes slapped on the rest of the bytes in the packet in the order they came.

     

    Here's a way to look at it:

    • Make two columns of bytes.  Byte 1 is row 1 left, Byte 2 in row 1 right.  Byte 3 is row 2 left, Byte 4 is Row 2 right.  On and on until the next packet starts.
    • Compound XOR each row.
    • For example, starting with decimal 170, 85 for the first block and then 249, 49 for the second as in Line 4 of the code, it looks like this in binary.  You are XORing the next row against the result of the previous XOR operation:

      

    1010101001010101
    XORXOR
    1111100100110001
    XORXOR
    ……
    ==
    630E

     

    Which is precisely the bytes at the CS item of the parameter.

     

    Here is the VB code to pull it off.

     

    'VB code for checksum of YDLIDAR X2 data packet
    Sub doer()
        'PH (2 bytes in order they streamed), FSA (2 Bytes in order they streamed), S1, Sx, CT (one Byte), LS (one byte), LSA (two bytes the ordered they streamed)
        MsgBox (my_checksum("170,85,249,49,0,0,182,12,228,12,30,5,29,5,0,0,50,13,0,0,0,0,36,13,4,13,244,12,228,12,216,12,204,12,201,12,185,12,177,12,169,12,165,12,161,12,153,12,153,12,149,12,149,12,145,12,145,12,145,12,145,12,145,12,149,12,157,12,161,12,161,12,165,12,177,12,181,12,193,12,197,12,208,12, 0,40,247,67"))
    End Sub
    Function my_checksum(str As String) As String
        Dim bytes() As String
        Dim left_byte(100) As Byte
        Dim right_byte(100) As Byte
        Dim left_xor As Byte
        Dim right_xor As Byte
        Dim tt As Integer
        
        bytes = Split(str, ",")
        
        ' tt will index the new byte array we parse
        tt = 0
        ' Convert the strings to integers and then to bytes.  Make a left column and right column to process next with the xor operation
        For ii = 0 To UBound(bytes) - 1 Step 2
            left_byte(tt) = CByte(CInt(bytes(ii)))
            right_byte(tt) = CByte(CInt(bytes(ii + 1)))
            tt = tt + 1
        Next
        
        ' tt will now represent the upper bound of our byte arrays below
        tt = tt - 1
        
        
        left_xor = 0
        right_xor = 0
        
        ' perform the xor operation in double byte fashion
        For ii = 0 To tt
            left_xor = left_xor Xor left_byte(ii)
            right_xor = right_xor Xor right_byte(ii)
        Next
        
        my_checksum = ((Hex(left_xor) & " " & Hex(right_xor)))
    End Function

     

     

    For info, the reason this interests me is because the SDK for the YDLIDAR has a very robust CMAKE file and c++ library that is great for Windows and Linux boxes.  But, it isn't too attractive for embedded devices like the Azure Sphere and Arduino.  If I make a simple C routine to snoop serial packets, its all I would need to get the point cloud data its senses without any overhead.

     

    See ya',

    Sean

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • neuromodulator
    neuromodulator over 5 years ago

    Leave the lidar scanning for a while and letme know if you find a checksum error. I suspect thst you wont

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Sean_Miller
    Sean_Miller over 5 years ago

    I ported the checksum code posted above to the Arduino and wrote a loop to catch the start of the packet and then parse the entire packet.

     

    Since I never have been one to compile successfully on the first try, I found the checksum comes in handy to catch my bugs and performance issues.  Here you see after every 11th packet read, I finally get a good check.  Of course at these crazy speeds, there is more than enough good data to snag, but I still need to perfect the Arduino code to do better - or address any data transfer problems I might be having from my cables.

     

    -Sean

     

    19:38:56.966 -> Samples Sent:  40 Checksum: 226, 72  New Checksum: 155, 85

    19:38:56.966 -> Samples Sent:  40 Checksum: 187, 108  New Checksum: 22, 106

    19:38:56.966 -> Samples Sent:  40 Checksum: 144, 2  New Checksum: 57, 11

    19:38:56.966 -> Samples Sent:  40 Checksum: 42, 109  New Checksum: 37, 109

    19:38:56.966 -> Samples Sent:  40 Checksum: 202, 76  New Checksum: 202, 76

    19:38:56.966 -> Samples Sent:  40 Checksum: 12, 118  New Checksum: 212, 107

    19:38:56.966 -> Samples Sent:  40 Checksum: 227, 144  New Checksum: 114, 132

    19:38:56.966 -> Samples Sent:  40 Checksum: 137, 64  New Checksum: 235, 93

    19:38:56.966 -> Samples Sent:  40 Checksum: 184, 121  New Checksum: 0, 122

    19:38:56.966 -> Samples Sent:  40 Checksum: 121, 214  New Checksum: 201, 216

    19:38:56.966 -> Samples Sent:  40 Checksum: 111, 127  New Checksum: 78, 98

    19:38:56.966 -> Samples Sent:  40 Checksum: 140, 74  New Checksum: 197, 87

    19:38:56.966 -> Samples Sent:  40 Checksum: 98, 108  New Checksum: 36, 106

    19:38:56.998 -> Samples Sent:  40 Checksum: 217, 15  New Checksum: 116, 10

    19:38:56.998 -> Samples Sent:  40 Checksum: 2, 108  New Checksum: 1, 109

    19:38:56.998 -> Samples Sent:  40 Checksum: 69, 77  New Checksum: 69, 77

    19:38:56.998 -> Samples Sent:  40 Checksum: 208, 118  New Checksum: 148, 107

    19:38:56.998 -> Samples Sent:  40 Checksum: 210, 147  New Checksum: 187, 131

    19:38:56.998 -> Samples Sent:  40 Checksum: 176, 91  New Checksum: 219, 109

    19:38:56.998 -> Samples Sent:  40 Checksum: 229, 105  New Checksum: 217, 97

    19:38:57.023 -> Samples Sent:  40 Checksum: 179, 209  New Checksum: 143, 217

    19:38:57.023 -> Samples Sent:  40 Checksum: 146, 113  New Checksum: 128, 111

    19:38:57.057 -> Samples Sent:  40 Checksum: 184, 72  New Checksum: 57, 84

    19:38:57.057 -> Samples Sent:  40 Checksum: 24, 111  New Checksum: 102, 106

    19:38:57.057 -> Samples Sent:  40 Checksum: 92, 3  New Checksum: 92, 10

    19:38:57.090 -> Samples Sent:  40 Checksum: 239, 111  New Checksum: 108, 109

    19:38:57.090 -> Samples Sent:  40 Checksum: 70, 77  New Checksum: 70, 77

    19:38:57.090 -> Samples Sent:  40 Checksum: 150, 64  New Checksum: 76, 93

    19:38:57.090 -> Samples Sent:  40 Checksum: 96, 174  New Checksum: 207, 128

    19:38:57.123 -> Samples Sent:  40 Checksum: 66, 125  New Checksum: 137, 112

    19:38:57.123 -> Samples Sent:  40 Checksum: 14, 0  New Checksum: 234, 102

    19:38:57.123 -> Samples Sent:  40 Checksum: 159, 201  New Checksum: 147, 151

    19:38:57.156 -> Samples Sent:  40 Checksum: 192, 64  New Checksum: 114, 90

    19:38:57.156 -> Samples Sent:  40 Checksum: 8, 72  New Checksum: 25, 85

    19:38:57.156 -> Samples Sent:  40 Checksum: 201, 117  New Checksum: 204, 112

    19:38:57.189 -> Samples Sent:  40 Checksum: 161, 14  New Checksum: 115, 10

    19:38:57.189 -> Samples Sent:  40 Checksum: 36, 75  New Checksum: 56, 75

    19:38:57.189 -> Samples Sent:  40 Checksum: 255, 77  New Checksum: 255, 77

    19:38:57.189 -> Samples Sent:  40 Checksum: 86, 70  New Checksum: 250, 88

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Sean_Miller
    Sean_Miller over 5 years ago in reply to neuromodulator

    Yep...had a bug in that I was not XORing the full bounds of the sample data array in my ported Arduino code.  It's now 100% as you said!  The "Good Data" in my post a few minutes ago must have occurred when the Last Angle's (LSA) most significant byte was zero so it didn't affect the checksum.

     

    All that is happening here within .001 seconds absolutely boggles my mind and inspires me that the world should become an amazing place for our kids.

     

    Arduino code is below.  One could readily expand this to decipher object distance at given angles around the YDLIDAR or log a point map for importing into software to establish a geometry from a point cloud.  This approach is much, much leaner than their SDK and good for the likes of Arduino and the Azure Sphere Starter Kit.

     

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 212, 74  New Checksum: 212, 74

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 59, 83  New Checksum: 59, 83

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 3, 15  New Checksum: 3, 15

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 84, 101  New Checksum: 84, 101

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 218, 107  New Checksum: 218, 107

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 97, 95  New Checksum: 97, 95

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 133, 244  New Checksum: 133, 244

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 129, 92  New Checksum: 129, 92

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 171, 26  New Checksum: 171, 26

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 5, 155  New Checksum: 5, 155

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 90, 72  New Checksum: 90, 72

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 158, 81  New Checksum: 158, 81

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 169, 15  New Checksum: 169, 15

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 37, 96  New Checksum: 37, 96

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 72, 107  New Checksum: 72, 107

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 139, 98  New Checksum: 139, 98

    20:06:07.391 -> Good:  Samples Sent:  40 Checksum: 66, 185  New Checksum: 66, 185

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 205, 70  New Checksum: 205, 70

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 157, 30  New Checksum: 157, 30

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 92, 236  New Checksum: 92, 236

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 250, 106  New Checksum: 250, 106

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 93, 85  New Checksum: 93, 85

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 51, 15  New Checksum: 51, 15

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 214, 104  New Checksum: 214, 104

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 129, 106  New Checksum: 129, 106

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 20, 95  New Checksum: 20, 95

    20:06:07.423 -> Good:  Samples Sent:  40 Checksum: 237, 251  New Checksum: 237, 251

    20:06:07.435 -> Good:  Samples Sent:  40 Checksum: 108, 93  New Checksum: 108, 93

    20:06:07.469 -> Good:  Samples Sent:  40 Checksum: 53, 74  New Checksum: 53, 74

    20:06:07.469 -> Good:  Samples Sent:  40 Checksum: 140, 149  New Checksum: 140, 149

    20:06:07.469 -> Good:  Samples Sent:  40 Checksum: 178, 117  New Checksum: 178, 117

     

     

    bool first_byte_received;
    bool second_byte_received;
    int incomingByte;
    
    
    void setup() {
      Serial.begin(115200);
      first_byte_received=false;
      second_byte_received=false;
    }
    
    
    void loop() {
      // Poll for our expected 3 bytes that reflect the packet header.
      if (Serial.available()) {      // If anything comes in Serial (USB),
        incomingByte=Serial.read();
        //Serial.println(incomingByte);
        if (!first_byte_received) {
          if (incomingByte==170) first_byte_received=true;
        }
        else if(!second_byte_received) {
          if (incomingByte==85) {
            second_byte_received=true;
          }
          else
          {
            first_byte_received=false;
          }
        }
        else
        {
          if (incomingByte==0) {
            first_byte_received=false;
            second_byte_received=false;
            ReceivePacket();
          }
          else
          {
            first_byte_received=false;
            second_byte_received=false;
          }
        }
      }
    }
    
    
    void ReceivePacket() {
      int samples_sent, starting_angle_LSB, starting_angle_MSB, end_angle_LSB, end_angle_MSB;
      int check_code_LSB, check_code_MSB;
      int left_column[50], right_column[50];
      int sample_bytes[100];
      
      while (!Serial.available());
      samples_sent=Serial.read();
    
    
      // Expect no more than 40 really, but just in case, just punt if more than 50.
      if (samples_sent>50) {    
        return;
      }
      
      while (!Serial.available());
      starting_angle_LSB=Serial.read();
      while (!Serial.available());
      starting_angle_MSB=Serial.read();
      while (!Serial.available());
      end_angle_LSB=Serial.read();
      while (!Serial.available());
      end_angle_MSB=Serial.read();
      while (!Serial.available());
      check_code_LSB=Serial.read();
      while (!Serial.available());
      check_code_MSB=Serial.read();
      
      for (int ii=0;ii<((2*samples_sent)); ii++) 
      {
        while (!Serial.available());  
        sample_bytes[ii]=Serial.read();
      }
      
      // Perform checksum
      int left_checksum=0;
      int right_checksum=0;
      
      left_checksum=left_checksum ^ 170;
      right_checksum=right_checksum ^ 85;
      
      left_checksum=left_checksum ^ starting_angle_LSB;
      right_checksum=right_checksum ^ starting_angle_MSB;
    
    
      for (int ii=0; ii<((samples_sent*2)-1); ii+=2)
      {
        left_checksum=left_checksum ^ sample_bytes[ii];
        right_checksum=right_checksum ^ sample_bytes[ii+1];
      }
      
      left_checksum=left_checksum ^ 0;
      right_checksum=right_checksum ^ samples_sent; 
    
    
      left_checksum=left_checksum ^ end_angle_LSB;
      right_checksum=right_checksum ^ end_angle_MSB;
      
      String assessment="Bad";
      if (left_checksum==check_code_LSB&&right_checksum==check_code_MSB) assessment="Good";
      Serial.println(assessment + ":  Samples Sent:  " + String(samples_sent) + " Checksum: " + String(check_code_LSB) + ", " + String(check_code_MSB) + "  New Checksum: " + String(left_checksum) + ", " + String(right_checksum) );
      while
    (Serial.available()){Serial.read();}
    
    }

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • neuromodulator
    neuromodulator over 5 years ago in reply to Sean_Miller

    I'm glade you got it working. I've never used a LIDAR but can imagine they are quite fun.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube