Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
8.98k stars 5.17k forks source link

Support 2-byte message ids in host/mcu protocol #6613

Closed KevinOConnor closed 2 weeks ago

KevinOConnor commented 2 weeks ago

Currently the message protocol only supports 128 possible message ids. However, some microcontroller builds need up to ~125 messages today and some proposed code additions are exceeding the limit.

This PR increases the limit from 128 message ids to 16384 ids. It does this by adding support for either 1 or 2 byte message ids in the low-level message parsing code.

This does mean that the bulk sensor code should use no more than 51 bytes of data when reporting results back to the host. (A message can be up to 64 bytes long: 5 bytes for the headers, 2 bytes for the response id, 2 bytes for oid, 3 bytes for the sequence number, 1 byte for data length, 51 bytes of data.) This is a breaking change for the ldc1612 sensor support - users with this sensor will need to recompile and reflash their mcu code after applying this update.

@garethky - fyi.

-Kevin

garethky commented 2 weeks ago

Thanks for picking this up so quickly! I didn't want to be responsible for knowing all the ways this could break something.