Jon, I hacked the code below together and it demonstrates that only 3 message objects work at a time. However, I was not able to recreate the problem setting the extended id directly on the [id] member, maybe that got fixed as it was related to some other problem in a previous mbed library version... ??
===================================================================
#include "mbed.h"
#include "CAN.h"
Ticker ticker;
DigitalOut can_Pca82c250SlopePin(p26);
CAN can2(p30, p29);
void send() {
static char counter = 0;
// our message data
static char testmsg1_data[8] = {0,0,0,0,0,0,0,1};
static char testmsg2_data[8] = {0,0,0,0,0,0,0,2};
static char testmsg3_data[8] = {0,0,0,0,0,0,0,3};
static char testmsg4_data[8] = {0,0,0,0,0,0,0,4};
static char testmsg5_data[8] = {0,0,0,0,0,0,0,5};
static char testmsg6_data[8] = {0,0,0,0,0,0,0,6};
// an empty object example
static CANMessage canmsg_testmsg1 = CANMessage();
// our completely defined message objects
static CANMessage canmsg_testmsg2 = CANMessage(0x18FF7227,testmsg2_data,8,CANData,CANExtended);
static CANMessage canmsg_testmsg3 = CANMessage(0x18FF7327,testmsg3_data,8,CANData,CANExtended);
static CANMessage canmsg_testmsg4 = CANMessage(0x18FF7427,testmsg4_data,8,CANData,CANExtended);
static CANMessage canmsg_testmsg5 = CANMessage(0x18FF7527,testmsg5_data,8,CANData,CANExtended);
static CANMessage canmsg_testmsg6 = CANMessage(0x18FF7127,testmsg6_data,8,CANData,CANExtended);
// set the empty object fields directly
canmsg_testmsg1.id = 0x18FF8027; // this appears to be working now
canmsg_testmsg1.len = 8;
canmsg_testmsg1.format = CANExtended;
canmsg_testmsg1.type = CANData;
// would be nice if we could assign a pointer to the data member
// this doesn't work but is here for illustration
// canmsg_testmsg1.data = &testmsg1_data;
// maybe another way would be:
// canmsg_testmsg1.setData(&testmsg1_data);
// set data bytes
canmsg_testmsg1.data[5] = counter;
testmsg1_data[1] = counter;
testmsg2_data[2] = counter;
testmsg3_data[3] = counter;
testmsg4_data[4] = counter;
testmsg5_data[5] = counter;
testmsg6_data[6] = counter;
// send messages
can2.write(canmsg_testmsg1); // visible on bus
can2.write(canmsg_testmsg2); // visible on bus
can2.write(canmsg_testmsg3); // visible on bus
can2.write(canmsg_testmsg4); // bug: not visible on bus
can2.write(canmsg_testmsg5); // bug: not visible on bus
can2.write(canmsg_testmsg6); // bug: not visible on bus
// increment the counter
counter++;
}
int main() {
can2.frequency(250000);
can_Pca82c250SlopePin = 0;
ticker.attach(&send, 0.250f);
while (1) {
;; // don't end
}
}
==========================================================
As you may have gathered, I'm doing various bug fixes and updates to the mbed library; coming up very shortly on my list is the CAN class. Could I ask what devices you, the mbed users, are talking to (or trying to talk to)?