flow_control: CRC documentation from modbus specifications

This commit is contained in:
Markus Rosenstihl 2016-02-18 20:39:28 +00:00
parent 5f8f390434
commit e34103c367

View File

@ -10,7 +10,14 @@ import time
DEBUG = False
crc_test = "\x0d\x01\x00\x62\x00\x33"
crc_expected = 0xddd
def crc(message):
"""
(from "Modbus_over_serial_line_V1_02.pdf" at http://www.modbus.org)
6.2.2 CRC Generation
====================
The Cyclical Redundancy Checking (CRC) field is two bytes, containing a 16bit binary value. The CRC value is calculated by the
@ -48,11 +55,6 @@ When the 16bit CRC (two 8bit bytes) is transmitted in the message, the low
order byte.
"""
crc_test = "\x0d\x01\x00\x62\x00\x33"
crc_expected = 0xddd
def crc(message):
crc = 0xffff # step 1
for byte in message:
if type(byte) == type(str):