modbus.crc16

modbus.crc16

modbus.crc16

Function

Calculate Modbus RTU CRC16.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
dataBytes/Array/StringYesNoneBytes involved in CRC calculation, excluding frame tail CRC.

Return value

TypeDescription
IntCRC16 value. Low byte first when writing RTU frames.

Code Example

Notes

  • crc16() only returns a numerical value; when building an RTU request, please use rtu_request() first to automatically write the CRC.