Breadcrumbs

modbus_crc16()

Definition

modbus_crc16(data)

Features

When using the Modbus protocol, this command reduces the load on Modbus CRC16 calculations.

Parameters

Parameter Name

Data Type

Default Value

Description

data

byte

-

Modbus data for CRC16 calculations

Return

Value

Description

crchigh

High byte of CRC16 calculation result

crclow

Low byte of CRC16 calculation result

Exception

Exception

Description

DR_Error (DR_ERROR_TYPE)

Parameter data error occurred

DR_Error (DR_ERROR_VALUE)

Parameter value is invalid

DR_Error (DR_ERROR_RUNTIME)

C Extension module error occurred

DR_Error (DR_ERROR_STOP)

Program terminated forcefully

Example

Python
data = b"\x01\x02\x03\x04\x05\x06"
crchigh, crclow = modbus_crc16(data)
#crchigh = 186(DEC), BA(HEX)
#crclow = 221(DEC), DD(HEX)