Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-CAN notification functions is re-enabled even though it should not be.

In my application I register a callback function for a CAN network interface. The callback is enabled by following states
  • NC_ST_READ_AVAIL
  • NC_ST_WRITE_SUCCESS
  • NC_ST_WARNING
  • NC_ST_ERROR

When I detect WRITE_SUCCESS, WARNING or ERROR I set the return value of my callback to the set listed above excluding the detected state (i.e. if a warning has been detected the returned set of states would be NC_ST_READ_AVAIL | NC_ST_WRITE_SUCCESS | NC_ST_ERROR), which should disable repeated triggering of the callback function. But the callback is retriggered again and again causing deadlock of the calling application.

What may be the problem or is there any other way to control the behaviour of the callback function? Or how to correctly implement a callback with following behaviour:

  • I need to check for incoming data all the time
  • I need to check for errors, warnings and write success only if data is written to the interface

One solution I can think of is to create global variables enabling individual sections of the callback function and the other is to swap two callback functions each of which would handle one situation (i.e. one for data input and the other for data output).

Regards,

Petr Micek

0 Kudos
Message 1 of 2
(3,626 Views)

Hi,

The notification function activates for errors allways automatically. You can not disable that. 

The write success state is allways set if the write queue is empty, thus whenever you do not write the state is set because the queue should be empty.

You can not have multiple notifications on the same handle. Thus the only chance is, to write on a different port using the wait for state to check the write success, or

using the same port and an object for e specific ID to have a different handle for the wait on write success.

DirkW

Message 2 of 2
(3,611 Views)