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. checksum

checksum

Scheduled Pinned Locked Moved C / C++ / MFC
debugginghelpquestion
2 Posts 2 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.
  • T Offline
    T Offline
    thathvamsi
    wrote on last edited by
    #1

    hey all, I do a checksum logic on both the serial device and the Pc end to see if the correct packet is received. I do : for (i = 0 ; i < (nMaxLenPkt2Tx - 1); i++) { cChkSum_2pc ^= txbuffer[i];} txbuffer[i] = cChkSum_2pc; and then send the packet from the serial device to PC. and on Pc's end, I do this after receiving the packet before copying it to a local buffer. char cChkSum = 0; `for (i = 0 ; i < (PKTINFO_LEN_MPU_2PC - 1); i++) cChkSum ^= m_cBufPktInfo_mpu_2pc[i];` and compare this checksum count with teh received checksu count in the packet to determine if it is a correct packet or not. ie., if (cChkSum != m_cBufPktInfo_mpu_2pc[PKTINFO_LEN_MPU_2PC - 1]) { TRACE("Received a bad packet!\n"); } But I get badpacket everytime . Waht could be wrong? the datatypes and the length of the packet sent and received are the same. I have checked that. Any ideas/help? Thanks in advance.

    A 1 Reply Last reply
    0
    • T thathvamsi

      hey all, I do a checksum logic on both the serial device and the Pc end to see if the correct packet is received. I do : for (i = 0 ; i < (nMaxLenPkt2Tx - 1); i++) { cChkSum_2pc ^= txbuffer[i];} txbuffer[i] = cChkSum_2pc; and then send the packet from the serial device to PC. and on Pc's end, I do this after receiving the packet before copying it to a local buffer. char cChkSum = 0; `for (i = 0 ; i < (PKTINFO_LEN_MPU_2PC - 1); i++) cChkSum ^= m_cBufPktInfo_mpu_2pc[i];` and compare this checksum count with teh received checksu count in the packet to determine if it is a correct packet or not. ie., if (cChkSum != m_cBufPktInfo_mpu_2pc[PKTINFO_LEN_MPU_2PC - 1]) { TRACE("Received a bad packet!\n"); } But I get badpacket everytime . Waht could be wrong? the datatypes and the length of the packet sent and received are the same. I have checked that. Any ideas/help? Thanks in advance.

      A Offline
      A Offline
      anu_88
      wrote on last edited by
      #2

      see this article on checksum algorithm .This may help [http://www.flounder.com/checksum.htm](<a href=)[^]" -- modified at 0:35 Friday 21st July, 2006

      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