Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Crc 32 bit

Crc 32 bit

Scheduled Pinned Locked Moved C / C++ / MFC
questioniothelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yagokhan
    wrote on last edited by
    #1

    Hi I am trying to commucate with a sensor usimg 32 bit crc. I am using pre-built 32bit crc table. How can I implement error detection code? Sensor sends 38bytes of data with a header 0x93.

    J Y 2 Replies Last reply
    0
    • Y yagokhan

      Hi I am trying to commucate with a sensor usimg 32 bit crc. I am using pre-built 32bit crc table. How can I implement error detection code? Sensor sends 38bytes of data with a header 0x93.

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      There is an error if the CRC send with the message is not the same as those calculated for the received message. So you have to

      • Receive message
      • Calculate CRC for received message
      • Compare with CRC which is part of the message

      The final implementation depends on the used message format which should be part of the sensor documentation.

      1 Reply Last reply
      0
      • Y yagokhan

        Hi I am trying to commucate with a sensor usimg 32 bit crc. I am using pre-built 32bit crc table. How can I implement error detection code? Sensor sends 38bytes of data with a header 0x93.

        Y Offline
        Y Offline
        yagokhan
        wrote on last edited by
        #3

        thank you for your answer here is the code part of my project.

        	for aye=bytePullIdx:(crcIdx-1) 
        

        a = bitand(bitxor(byteBufferPtr(aye),bitshift(crc,-24)),hex2dec('FF'));
        crc = bitxor(bitshift(crc,8),crcLookupTable2(a));

        abowe byteBufferPtr is coming message (38bytes) crcLookupTable is pre-built table for crc polynom '04C11DB7'. after calculating crc I check if (crc==byteBufferPtr(crcIdx) condition to get the data. Is there anything wrong here? because I could not get the right if condition here. I could not find the right crc value among the crc table values. Thank you.

        L 1 Reply Last reply
        0
        • Y yagokhan

          thank you for your answer here is the code part of my project.

          	for aye=bytePullIdx:(crcIdx-1) 
          

          a = bitand(bitxor(byteBufferPtr(aye),bitshift(crc,-24)),hex2dec('FF'));
          crc = bitxor(bitshift(crc,8),crcLookupTable2(a));

          abowe byteBufferPtr is coming message (38bytes) crcLookupTable is pre-built table for crc polynom '04C11DB7'. after calculating crc I check if (crc==byteBufferPtr(crcIdx) condition to get the data. Is there anything wrong here? because I could not get the right if condition here. I could not find the right crc value among the crc table values. Thank you.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You need to find out what the sensor uses to calculate its CRC.

          Y 1 Reply Last reply
          0
          • L Lost User

            You need to find out what the sensor uses to calculate its CRC.

            Y Offline
            Y Offline
            yagokhan
            wrote on last edited by
            #5

            Actually I am working on code offline. I took 38byte of data starting with header and put it my code. The sensor is sensonor stim300

            L J 2 Replies Last reply
            0
            • Y yagokhan

              Actually I am working on code offline. I took 38byte of data starting with header and put it my code. The sensor is sensonor stim300

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I do not think anyone here can guess what data the device will produce. You should check the technical documentation for the device, or contact the manufacturer.

              Y 1 Reply Last reply
              0
              • L Lost User

                I do not think anyone here can guess what data the device will produce. You should check the technical documentation for the device, or contact the manufacturer.

                Y Offline
                Y Offline
                yagokhan
                wrote on last edited by
                #7

                The device produces 32bit crc with polynomial

                0x04c11db7

                What else do i need to ask?

                1 Reply Last reply
                0
                • Y yagokhan

                  Actually I am working on code offline. I took 38byte of data starting with header and put it my code. The sensor is sensonor stim300

                  J Offline
                  J Offline
                  Jochen Arndt
                  wrote on last edited by
                  #8

                  yagokhan wrote:

                  he sensor is sensonor stim300

                  A quick Google search for "stim300 crc" found this: drivers-imu_stim300/src at master · rock-drivers/drivers-imu_stim300 · GitHub[^]. There see the verifyChecksum function at drivers-imu_stim300/Stim300RevD.cpp at master · rock-drivers/drivers-imu_stim300 · GitHub[^]. It uses the Boost CRC Library - 1.63.0[^] which is just a header file implementing the CRC calculations.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups