added checksum escape#131
Conversation
Signed-off-by: alxwk <[email protected]>
|
Hmm, I need to test this a bunch more as it doesn't make 100% sense to do this. The header already contains the message length so we easily know when |
|
I found a few settings that create such checksum but try as I might, it always works properly. |
|
Well, in a case of boxflat as an utility which only uses the serial for settings change once in a while, it may be not much important. In my case of a telemetry app with a constant serial exchange any discrepancy can be noticed pretty quickly. I filled this PR mostly just as a heads-up, if someone hits the same situation as I did. I agree that such "escaping" is not necessary for any sensible handling of a serial protocol, but apparently Moza developers (or a LLM they use) think otherwise. |
|
Here's what I've figured out at this point.... when a frame's computed checksum equals This applies to both directions (host -> device and device -> host) In the three- |
Yep, that's exactly what I wrote. Maybe my English isn't too good (despite being C2 at tests, lol). Usually, it's a pretty rare condition (1/256 probability, obviously), but when I stumbled upon it in my telemetry configuration, it almost has driven me mad. The LED just didn't light no matter what. |
Somehow I misread your PR to say it was doubling the message itself a 2nd time, took me a while to wrap my head around what was going on. I've been seeing these values plenty when trying to add support for dashboard displays in another codebase with the high traffic rate of messages being exchanged. |
I found an interesting thing in the protocol (maybe it was just added recently).
If the final checksum byte of a message equals 0x7e, it needs to be "escaped" by doubling it.
Examples I've captured with Wireshark under Win10:
So, for example, in the last reply the device 0x12 answers with the message having the checksum==0x7e, it gets doubled, and then follows the next message from the device 0x19, resulting in three 0x7e in a row.
(I learned about it the hard way — as I'm making a telemetry utility, I accidentally stumbled upon the telemetry combination resulting in a message having this checksum, and after sending it as is, without doubling, the wheel started to behave strange, RPM LEDs falling into some sort of "idle mode". Took me a couple of days to figure it. Honestly, it's not the brightest handling of a communication protocol by Moza developers, but oh well...)