sparkfun / SparkFun_CAN-Bus_Arduino_Library

Other
154 stars 99 forks source link

Add support for 29 bit identifier #1

Open danjo133 opened 8 years ago

danjo133 commented 8 years ago

Hi,

I need to have support for 29 bit identifiers in a project I'm working on.

I have working code for it that I would like to contribute, but I'm unsure what the best way of handling the 11 vs 29 bit difference.

I have added a bool for keeping track of if it's a 29 or 11 bit identifier typedef struct { uint32_t id; struct { int8_t rtr : 1; uint8_t length : 4; } header; uint8_t data[8]; bool extended; } tCAN;

I would like to keep all old code working though, and I have two suggestions. Either change the mcp2515.c to .cpp which would allow constructors that set default extended=false or add a new struct for extended messages. Do you have any other suggestion?

wellsa1 commented 6 years ago

Same problem here. Do you still have this code?

danjo133 commented 6 years ago

I have a 29 bit branch here, also changed to c++, but it should be split into separate commits. Haven't touched it for a couple years though.

https://github.com/danjo133/SparkFun_CAN-Bus_Arduino_Library

wellsa1 commented 6 years ago

Thanks for the reply!! I'll give it a go. I'm assuming the usage hasn't changed.

danjo133 commented 6 years ago

Not that I remember, just check extended flag in tCAN on receive and set it on send.

bessman commented 5 years ago

@danjo133 Your implementation misidentifies all incoming frames as extended. I've fixed it in my branch: https://github.com/bessman/SparkFun_CAN-Bus_Arduino_Library

danjo133 commented 5 years ago

Good to know, thanks!