Teensuino and can bus transmitting

Status
Not open for further replies.

A6_quattro

Active member
Hi

Have a question that I hope someone could give be some input on.

I've a function that is supposed to transmitt via can bus to my ECU. I'm using the Flexcan library in the Arduino IDE.

The code for sending is this:

uint8_t ecu_reader_class::reply(uint8_t pid, int buf0, int buf1, int buf2, int buf3, int buf4, int buf5, int buf6, int buf7)
{

CAN_message_t can_MsgTx;
elapsedMillis waiting;
while (waiting < 1000) { //Check for timeout
if(Can0.write(can_MsgTx))
{
can_MsgTx.buf[0] = buf0;
can_MsgTx.buf[1] = buf1;
can_MsgTx.buf[2] = buf2;
can_MsgTx.buf[3] = buf3;
can_MsgTx.buf[4] = buf4;
can_MsgTx.buf[5] = buf5;
can_MsgTx.buf[6] = buf6;
can_MsgTx.buf[7] = buf7;
can_MsgTx.len = 8;
can_MsgTx.id = pid;
can_MsgTx.timeout = 500;
Can0.write(can_MsgTx);
return 1;
}
}
return 0;
}
I've succesfully used to transmitt but now it's impossible to get it to work.

Could it be that I've reciev about 15 variables on the bus so it gets a jam? To many operations on the same bus?

Should I get another instance of the Can.write(), Can1.write(), to get it to work as supposed?

Regards
Hans
 
Status
Not open for further replies.
Back
Top