Skip to content

Endless loop in modbus_crc16? #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
etet100 opened this issue Apr 4, 2025 · 2 comments
Open

Endless loop in modbus_crc16? #723

etet100 opened this issue Apr 4, 2025 · 2 comments

Comments

@etet100
Copy link

etet100 commented Apr 4, 2025

I had a problem running GRBL in simulator mode. It turned out that the code crashes in modbus_crc16x. This function allows length up to 16 bits but the counter (pos) is 8 bits. Is this intentional? In my case, len is 420 and the loop never ends.

@terjeio
Copy link
Contributor

terjeio commented Apr 4, 2025

Is this intentional?

Yes, max message length is 256 bytes including the CRC, from MODBUS APPLICATION PROTOCOL SPECIFICATION v1.1:

RS232 / RS485 ADU = 253 bytes + Server address (1 byte) + CRC (2 bytes) = 256 bytes.

@etet100
Copy link
Author

etet100 commented Apr 5, 2025

I understand. But this function also has an alias calc_checksum.

#if NVS_CRC_BYTES > 1
#define calc_checksum(data, length) modbus_crc16x(data, length)
#else

while calc_checksum is used to check the configuration object, which has 420 bytes.

terjeio added a commit that referenced this issue Apr 5, 2025
Added '$709' setting for second PWM spindle when available - PWM options.
Added properties to PWM spindles to allow "overdriving" PWM output when _RPM controls spindle enable signal is enabled with '$9' or '$709'.
Optimized Modbus CRC calculation, may fix issue with a compiler generating different code compared to most others. Ref. issue #723.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants