CAN-Shield

Hello,

I’ve got can shield and am looking to write my own code with the use of the supplied Seeedstudio library.

I have two questions can anyone help?

1.) I am using the only library download I can find 0.1, when I send an extended message in loopback mode it is not received, presumably there is a mistake in the filter setup in the library? I don’t know enough C to fix it, unless I make a mistake?

INT32U frame_id; char str[20]; unsigned char stmp[8] = {0xA7, 0x00, 0x54, 0x35, 0x44, 0x35, 0x20, 0x20};

[code]void ConfigCAN()
{

CAN.begin(CAN_125KBPS); // init can bus : baudrate = 125k
CAN.mcp2515_setCANCTRL_Mode(MODE_CONFIG);
//CAN.init_Mask(1, 1 , 0x000);
#ifdef DEBUG_MODE
CAN.mcp2515_setCANCTRL_Mode(MODE_LOOPBACK); // Loopback for debug
#else
CAN.mcp2515_setCANCTRL_Mode(MODE_LISTENONLY);

#endif
}[/code]

#ifdef DEBUG_MODE Serial.println("Debug"); CAN.sendMsgBuf(0x1800008, true, 8, stmp); // If this is true I don't get anything back, false I do. delay(100); #endif

The code for receiving messages uses the interrupt as per your demo sketch.

2.) Can someone please give me an example of setting the masks and filters using this library? I can’t seem to figure it out.

Many thanks.

John.

Just some more information:-

#define MCP_RXB_RX_STDEXT   0x00

If I change 0x00 to 0x60 (0x60 is bypass filters and masks) then I receive extended frames, this leads me to believe that the default CAN init does not allow for receiving extended frames

Unless I use the library wrong.

Hi jpcurrie,

Which library did you use ?

:unamused:

Hi,

The one on the Can shield wikki page?

hi,

I can’t find LOOPBACK and LISTENONLY MODE in Library ??

are u sure get library from WIKI site??

Yes I’m sure!

It’s on line 186 in the defs header file.

hi John~ about MODE_LOOPBACK and MODE_LISTENONLY, I am shame to tell you that I have never use.
You know, it’s just a basic library, it’ll just contains some basic function~ :smiley:
But if some guy will update the library, we’ll be pleasure to add it to the library or the wiki :wink:

I think it’s necessary to write an example about how to use masks and filters, I’ll find a time to do it… maybe next week.
When I finished it, I’ll contract you asap.

Thanks Loovee, an example will be good.

Sorry I just seen this.

I noticed while testing, I use loopback to test the code before fitting it into the car :slight_smile:

I think the library seemed very complete compared to some of the others I seen so well done :slight_smile: I just need to figure out the masking etc.

Thanks.

John.