OpenSourceEBike / Bafang_M500_M600

GNU General Public License v3.0
80 stars 37 forks source link

CANBUS opt bits #94

Closed Teunderbolt closed 3 months ago

Teunderbolt commented 9 months ago

Hello Everybody,

Currently I am looking into the canbus protocol that has been used on this Bafang ecosystem. I know thanks to this repo how the frameID is build. But one thing I don't seem to understand, what OPT code is used? Based on the 3 bits used in the frameID for the OPT command, it looks like almost every frameID is a WRITE_CMD (which seems logical), or an OPT_HARDWARE_VERSION (which seems odd).

So which values needs to be used in the OPT command? These ones:

WRITE_CMD           : 0x00
READ_CMD            : 0x01
NORMAL_ACK          : 0x02
ERROR_ACK           : 0x03
LONG_START_CMD      : 0x04
LONG_TRANG_CMD      : 0x05
LONG_END_CMD        : 0x06
LONG_WARNING_CMD    : 0x07

or these ones:

OPT_HARDWARE_VERSION    : 0x00
OPT_SOFTWARE_VERSION    : 0x01
OPT_MODEL_VERSION       : 0x02
OPT_SN                  : 0x03
OPT_CLIENT_NO           : 0x04

I hope someone could answer this for me.

Already thanks for the hero that could help me.

Kind regards, Teun

Teunderbolt commented 3 months ago

I figured it out. The opt value in the frame-id calculator should be the write, read, ack and etc. command.