Hello,
I use PCANBasic with Python 2.6 on a Windows 7 machine (Windows 7 Ultimate, 64 bit).
Following the examples written in .Net and AStefan's forum post dating Monday 16th January 2012 I managed to trigger an event when messages are placed in the receive queue.
According to the PCANBasic documentation an event is triggered regardless of the message's content or its ID.
Is it possible to trigger an event for "special" messages only, e.g. messages showing a warning?
Best regards,
Andreas
PCANBasic: trigger event for "special" message only?
Re: PCANBasic: trigger event for "special" message only?
Hello Andreas,
Since all messages (warning and error messages too) are stored in the same queue, an extra event for special messages wouldn't be a good approach
since the queue must still be read/searched until those special messages are found.
Why do you need something like this? What would you do if you receive a special event?
This is not implemented. An event is triggered at the moment that any message is received on a connected channel. This means, you don't receive an event for each message placed in the queue but an even when the driver has written into the channel's queue.A.Kapp wrote:According to the PCANBasic documentation an event is triggered regardless of the message's content or its ID.
Is it possible to trigger an event for "special" messages only, e.g. messages showing a warning?
Since all messages (warning and error messages too) are stored in the same queue, an extra event for special messages wouldn't be a good approach


Best regards,
Keneth
Keneth
Re: PCANBasic: trigger event for "special" message only?
Hello Kenneth,
thanks for your reply.
Since I have understood that it is not possible to trigger events for "special" messges only, I will make a work-around.
My intention was to trigger an event for special messages without having to read the entire message queue.
Situation: I want to read a stream of data via CAN. Every now and then a warning message pops up and I want to react as fast as possible.
Kind regards,
Andreas
thanks for your reply.
Since I have understood that it is not possible to trigger events for "special" messges only, I will make a work-around.
My intention was to trigger an event for special messages without having to read the entire message queue.
Situation: I want to read a stream of data via CAN. Every now and then a warning message pops up and I want to react as fast as possible.
Kind regards,
Andreas
Re: PCANBasic: trigger event for "special" message only?
Hello Andreas,
sorry but there is no way to do that without reading the queue, since these errors are placed there in the order as they happened.
You have to ensure the fast reading from the queue and then you will react fast enough for every warning message. Actually the event capability was included in order to have a secondary read-thread, so that an application can react as faster as possible when messages are received. You can just split the work on the read part of your code, for example:
// Run function of a thread
I hope this help.
sorry but there is no way to do that without reading the queue, since these errors are placed there in the order as they happened.
You have to ensure the fast reading from the queue and then you will react fast enough for every warning message. Actually the event capability was included in order to have a secondary read-thread, so that an application can react as faster as possible when messages are received. You can just split the work on the read part of your code, for example:
// Run function of a thread
Code: Select all
TPCANMsg msg;
TPCANTimestamp timestamp;
TPCANStatus result;
char strMsg[256];
while(running)
{
do
{
result = CAN_Read(PCAN_USBBUS1,&msg,×tamp);
if(result == PCAN_ERROR_OK)
// Process the received message
//
ProcessMessage(msg)
else
// An error occurred, handle it
//
HandleReadError(result);
}while((result & PCAN_ERROR_QRCVEMPTY) != PCAN_ERROR_QRCVEMPTY);
}
Best regards,
Keneth
Keneth