SparkFun_CAN-Bus_Arduino_Library icon indicating copy to clipboard operation
SparkFun_CAN-Bus_Arduino_Library copied to clipboard

Add support for 29 bit identifier

Open danjo133 opened this issue 9 years ago • 6 comments

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?

danjo133 avatar Jan 25 '16 12:01 danjo133

Same problem here. Do you still have this code?

wellsa1 avatar Jun 07 '18 14:06 wellsa1

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

danjo133 avatar Jun 07 '18 15:06 danjo133

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

wellsa1 avatar Jun 07 '18 18:06 wellsa1

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

danjo133 avatar Jun 08 '18 12:06 danjo133

@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

bessman avatar Jan 08 '19 12:01 bessman

Good to know, thanks!

danjo133 avatar Jan 08 '19 14:01 danjo133