Discussion:
Clearing read buffer after Digital Change Event USB 6229
(too old to reply)
David L.
2007-08-09 21:40:12 UTC
Permalink
Hi Jon,


There is no property to clear the buffer, but this can be
done by stopping and starting the task. The reason for the thread hanging
is that your timeout is set to -1, which means no timeout. Since this is the
case, the program will wait until a trigger is pressed to continue along with
code. Change the timeout to an actual number, and the infinite hang will go
away.
Kevin Price
2007-08-10 13:10:12 UTC
Permalink
I only program with LabVIEW and can't help with your specific syntax.  Here's the kind of approach I *think* you'll need:
1. At beginning of program, create a regular DI task that reads those bits once to determine your initial states.  Store this "most recent state" info in a static variable.  Clear the task.
2. Now you can create the change detection task for those bits.
3. Every time you detect any changes and read the state of the digital bits, refresh the "most recent state" variable.
4. Anytime you're simply curious about the state of those bits, but there aren't any changes available in the buffer, query your "most recent state" variable.  It holds the values at the most recent transition.
At least under LabVIEW, there are also ways to query old data directly out of the data acq buffer.  There are properties you set like "Offset=-1" and "RelativeTo=MostRecentSample".  This is probably possible for you to do with DAQmx calls, but I don't know the text syntax for it.
-Kevin P.

Loading...