How to calculate Least Signficant Byte in Ruby

Posted by Seth Archer on Stack Overflow See other posts from Stack Overflow or by Seth Archer
Published on 2010-04-04T04:50:58Z Indexed on 2010/04/04 4:53 UTC
Read the original article Hit count: 627

Filed under:
|
|

I'm sending a byte array to a piece of hardware.

The first 7 bytes contain data and the 8th byte is a checksum.

The 8th byte is the Least Significant Byte of the sum of the first 7 bytes.

Examples that include the correct checksum. The last byte of each of these is the checksum

200-30-7-5-1-2-0-245

42-0-0-1-176-0-148-39

42-0-0-3-177-0-201-118

How do I calculate the checksum?

Thanks, Seth

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby