Can_Read() blocks until timeout expires

Hi all,

here I have uploaded a example project to send and receive can frames.

The application uses the CE libraries v2.2.

There is a RX task with priority 42 and a TX task with priority 40.
The CAN task from the CanLib is at priority 12.
There is also a producer/consumer task with priotity 64.

This task wants to send CAN messages in a 100ms interval.
If I run the program and trace the frames, the messages are send in a 1000ms interval.
This is the time I specified with the Can_SetConfigInt(hCan, L"Timeout", wTimeout, StoreVolatile); function.

If I change wTimeout to 500ms, the messages are send in a 500ms interval and so on.

I think the RX task is blocking until the timeout expires and the producer task can’t interrupt the RX task.
In the release notes for CE lib 2.2 i readed “Improved CAN Library”.

Has this something to do with my problem?
Because with CE libs v2.0 the program worked.

Or what can I do to solve the problem?

I also tried to set wTimeout to 1ms. The performance for my application was ok, but I don’t think that this is good for the whole system if every millisecond the RX task is active.

Thanks for any advice.

Kind regards,

kuzco

Dear @Kuzco

In recent library versions we added more locking mechanisms to prevent race conditions during parallel use of library functions. This is the reason, why Can_Read() and Can_Write() are now dependent on each other.

There is probably a potential to reduce the interlocks, but doing such changes is always quite dangerous and might lead to other limitations and/or errors.
I judge the performance impact of the 1ms timeout should be minimal, therefore I would strongly prefer if you could live with this workaround.

Regards, Andy