demntor / pymodbus

Modbus Python release (tools included)
0 stars 0 forks source link

computeLRC is wrong #26

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
According MODBUS over Serial Line Specification and Implementation Guide
V1.02, section 6.2.1:

A procedure for generating an LRC is:
1. Add all bytes in the message, excluding the starting ‘colon’ and ending 
CRLF. Add them into an 8–bit field, so that carries will be discarded.
2. Subtract the final field value from FF hex (all 1’s), to produce the 
ones–complement.
3. Add 1 to produce the twos–complement.

The current implementation use xor and computes a different value from my 
testcases. The proposed implementation don't follow the exactly same steps 
quoted before but get the same result.

The patch also remove some trailing white spaces.

Original issue reported on code.google.com by jjconti@gmail.com on 15 Jul 2010 at 2:09

Attachments:

GoogleCodeExporter commented 8 years ago
This patch make some tests fail. After reading my comment, do you think test 
are ok or should we change them?

Original comment by jjconti@gmail.com on 15 Jul 2010 at 6:47

GoogleCodeExporter commented 8 years ago
Do not apply this patch. There is an error on it too.

Original comment by jjconti@gmail.com on 20 Jul 2010 at 5:04

GoogleCodeExporter commented 8 years ago
Fixed with changeset 69

Original comment by Bashw...@gmail.com on 5 Jan 2011 at 7:30