Page 1 of 1

CAN Driver doesn't check if Transmission is successful

Posted: Wed Oct 21, 2015 9:35 am
by visc
Hello,

I have been trying to test OBD2 over CAN BUS using STM32F103CB and ChibiOS.

I have been able to get my CAN RX working and now am able to receive CAN frames. I have been trying to send some OBD2 queries over CAN Protocol, but don't seem to be getting any response.

The canTransmit API returns OK status. I looked into the canTransmit API. It calls can_lld_transmit() function, which is only writing the CAN packet details into CAN TIxR register, but not waiting for the transmission status in CAN TSR register to be set.

Shouldn't it ideally check in CAN TSR register if transmission status for corresponding TX MailBox is set and only then return to the application if it is success or failure.

Another thing that even though my CAN configuration seems to be correct (as I am able to see CAN RX frames), my CAN Tx seems to be not working. The CAN TSR register doesn't show success after I have called the canTransmit API. Any thoughts?

Re: CAN Driver doesn't check if Transmission is successful

Posted: Wed Oct 21, 2015 10:22 am
by Giovanni
Hi,

The canTransmit() function is not blocking so it cannot wait internally and get the status.

The transmit error check is currently missing but it should be implemented to signal errors through the error event mechanism like for receive errors. The change should not be very difficult, I will put this enhancement in queue.

The flags mask would have one bit for each transmit mailbox, this will allow to know which one failed.

Giovanni

Re: CAN Driver doesn't check if Transmission is successful

Posted: Wed Oct 21, 2015 10:28 am
by visc
Hi,

Thanks for your reply.

Any thoughts on the CAN Tx not happening as suggested by CAN TSR register? Is there anything that I could check apart from configuration?

visc

Re: CAN Driver doesn't check if Transmission is successful

Posted: Wed Oct 21, 2015 10:49 am
by Giovanni
The demos use the CAN loopback mode in the CANConfig structure, is it disabled? alternatively check I/O alternate mode settings and wiring.

Giovanni

Re: CAN Driver doesn't check if Transmission is successful

Posted: Wed Oct 21, 2015 11:20 am
by visc
Hi Giovanni,

Loopback mode is disabled and alternate I/O settings and wiring seem to be correct.

I am able to see live data on CAN Rx when I connect my setup to my CAR. The problem is that my Queries on TX are not getting answered like they should.

It could be a problem of application layer protocol (OBD2 in this case), but just wanted to get a perspective from ChibiOS side.

Thanks.

Re: CAN Driver doesn't check if Transmission is successful

Posted: Thu Dec 17, 2015 1:53 pm
by Giovanni
Hi,

A small update on this, now the driver signals transmission errors by setting flags in the upper 16 bits of the tx event source. Bit 16 for mailbox 1, 17 for mailbox 2 and so on.

The lower 16 bits are used for signaling that the transmission has been successful.

Giovanni