flow_control: CRC documentation from modbus specifications
This commit is contained in:
parent
5f8f390434
commit
e34103c367
@ -10,7 +10,14 @@ import time
|
|||||||
|
|
||||||
DEBUG = False
|
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
|
6.2.2 CRC Generation
|
||||||
====================
|
====================
|
||||||
The Cyclical Redundancy Checking (CRC) field is two bytes, containing a 16–bit binary value. The CRC value is calculated by the
|
The Cyclical Redundancy Checking (CRC) field is two bytes, containing a 16–bit binary value. The CRC value is calculated by the
|
||||||
@ -48,11 +55,6 @@ When the 16–bit CRC (two 8–bit bytes) is transmitted in the message, the low
|
|||||||
order byte.
|
order byte.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
crc_test = "\x0d\x01\x00\x62\x00\x33"
|
|
||||||
crc_expected = 0xddd
|
|
||||||
|
|
||||||
|
|
||||||
def crc(message):
|
|
||||||
crc = 0xffff # step 1
|
crc = 0xffff # step 1
|
||||||
for byte in message:
|
for byte in message:
|
||||||
if type(byte) == type(str):
|
if type(byte) == type(str):
|
||||||
|
Loading…
Reference in New Issue
Block a user