CAN Driver doesn't check if Transmission is successful

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
visc
Posts: 3
Joined: Wed Oct 21, 2015 9:16 am

CAN Driver doesn't check if Transmission is successful

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

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

Post 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
visc
Posts: 3
Joined: Wed Oct 21, 2015 9:16 am

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

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

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

Post 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
visc
Posts: 3
Joined: Wed Oct 21, 2015 9:16 am

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

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

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

Post 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
Post Reply