JohnieBraaf / Robomaster-Micropython

Robomaster S1 - Micropython CAN BUS controller
GNU General Public License v3.0
25 stars 4 forks source link

CAN data field length #3

Closed ArtRytz closed 12 months ago

ArtRytz commented 1 year ago

Hi, I'm trying to do something similar, except in C, so I really appreciate your code.

I read through the SDK source code and I think I have a pretty good understanding of how it works, except that it seems like the resulting CAN message data is much longer than a standard CAN data field and I'm not sure how this is handled. Can you give me any advice about this?

JohnieBraaf commented 1 year ago

Hi @ArtRytz, the data will just arrive sequentially over multiple 8 byte CAN bus frames. Just start a new message whenever you see 0x55. And process or reject when you reached the length of message indicated by the second byte.

This is a c based repo doing the same https://github.com/RoboMasterS1Challenge/robomaster_s1_can_hack

ArtRytz commented 12 months ago

I see, I had a feeling that was it. I'll check out the repo, thanks

JohnieBraaf commented 12 months ago

@ArtRytz sometimes robomaster sends concatenated messages, so multiple messages over multiple frames, which you should split based on 0x55, so best strategy is just keep building up messages until the next 0x55 arrives or you reach the expected length.

You get the gist 😄

JohnieBraaf commented 12 months ago

Closing again