12-09-2008 03:46 AM
Hi!
I use a DLL, wich handles an USB CAN transceiver device, and generates LabVIEW user events with extcode.h and PostLVUserEvent() function.
In my vi I use an event case structure to handle theese external events. The problem is, that if the events come too frequently, then it cannot handle all events.
The vi contains a couple of parallel while loops which process the incoming data from the external event.
In another application I use the same architecture, and that works fine. This one is more complex.
Do you think I have reached the limits of the program? Or what else can be the problem?
I have tried to use a queue in the event structure, it helped a little, but yet, not all the events are handled. My external DLL sends all event, so the problem is not there.
Thanks in advance!
12-09-2008 05:56 AM
Hi Wasz,
Thanks for the post and I hope your well.
It is not possible for the event structure to miss events - it simply queues them up. To keep the event structure 'in time' with the code you must ensure the code to execute in each event is minimal to allow the event structure to handle the next event.
Please see this two links:
event structure buffering: leading to,
How to avoid built-up for "cursor move" events? : where somone is trying to avoid handling all events.
What sort of events are not being handled? Could it be an issue your events are not configured correctly? Maybe if you could produce a small example in LabVIEW code, so we can just test the event structure configuration... someone working around the external dll call - which you seem sure is working correctly.
In terms of queuing to process the events in other loops is certainly an option to speed up the event structure. To do this, use a produce/consumer design pattern.
hope this helps,
12-09-2008 06:40 AM
Hi!
I use something similar, excep for that my event is generated in the dll directly, if there is new data in the USB buffer.
Then in another while loop i process the "message from dll" (which is, in my case, a structure, containing some integers) via local variable.
This is the only event handled by this event-structure.
So this is not a UI event, this is generated by calling the GenerateLVEvent() function. It is sure, that this function is called every time. If i send 100 messages via the CAN bus, then only 98 or 99 events take place in my VI,even though i call the function 100 times in the DLL, which is traceable, so i am sure it is done.
12-09-2008 09:29 AM
Hi!
Meanwhile the problem has been solved. I rearranged a little tha application structure, and now it works fine... I dont know yet, what was the problem, but if i figure it out, ill post it, if anybody else had tha same problem.
Anyway, thanks for the help!
W
12-09-2008 11:24 AM
wasz wrote:Hi!
Meanwhile the problem has been solved. I rearranged a little tha application structure, and now it works fine... I dont know yet, what was the problem, but if i figure it out, ill post it, if anybody else had tha same problem.
Anyway, thanks for the help!
W
I would really like to hear what the answer to this riddle is. If you figure it out, please share.
Ben
12-09-2008 11:49 AM
Hi Wasz,
Thanks for getting back to us - sorry I didnt get a chance to see your reply sooner (bussiness times at NI UK :P).
What did you alter .. maybe this will help to explain what the issue was?
Thanks,
12-09-2008 11:56 AM - edited 12-09-2008 11:56 AM
Hi, wasz,
Here just classical race condition: you starting firing events before registration!
Look code below - here we will lost first 40 events:
Andrey.