Skip to content

MODBUS CRC does not seem to deliver correct value #32

@holgersprute

Description

@holgersprute

Dear Frank,

thank you for your great work. I tried to use your library to calculate a CRC for MODBUS use. However, when I compare the output of your library for FastCRC16 MODBUS with the CRC Calculator https://crccalc.com/, then the output doesn´t match.
For other CRC methods, the outputs are identical.

For example belowmodified example of yours delivers "0x25B4" as a result, while CRCCalc delivers "0x2590". REsults in case of KERMIT or CCITT are identical for your library and CRCCalc. Is there anything I do wrong, or is there an issue with the library?

/*
FastCRC-Example
(c) Frank Boesing 2014
*/
#include <Arduino.h>
#include <FastCRC.h>

FastCRC16 CRC16;

uint8_t buf[5] = {0x12, 0x34, 0x56, 0x78, 0x09 };

void setup() {

delay(1500);
Serial.begin(115200);

Serial.println("CRC Example");
Serial.println();

Serial.print("MODBUS-CRC of "");

for (unsigned int i = 0; i < sizeof(buf); i++) {
Serial.print((char) buf[i]);
}

Serial.print("" is: 0x");
Serial.println( CRC16.modbus_upd(buf, sizeof(buf)), HEX );

}

void loop() {
}

Thanks for checking,
Holger

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions