You didn't include the UIR file but anyway, seems you want to read data from
your device every so often. I would suggest that you use a timer control.
When you press START button, configure your SerialPort, clear all
input/output queues. Also remember by default serial timeouts are 5seconds.
After you done this, turn on the timer and have a global flag which tells
you that timer is ON. Now in timer callback, just read your data and display
in the text box or whatever you want. I don't know what your device sends
when you send 1 byte to it (why are Flushing the input Q after reading from
it?). The timer callback should also check the global variable and read data
only if global variable is ON. On STOP button callback, turn off that global
variable that you turned on in START callack.
The way you have your code, STST will never become 0. Reason is that you are
using Delay function which hangs up GUI. You need to have something like
do {
ProcessSysetmEvents();
} while (STST != 0);
ProcessSystemEvents processes your GUI events.
I use my own Delay something like follows:
void Wait(double NumOfSeconds)
{
double t0;
double t1;
t0 = Timer();
t1 = Timer();
while ((t1-t0) < NumOfSeconds) {
ProcessSystemEvents();
t1 = Timer();
}
}
Let me know if you need more help.
vishi
"njc" wrote in message
news:506500000008000000747E0000-1042324653000@exchange.ni.com...
> Hello, I was wandering if anyone could help. I have written a program
> to send a code to a PIC and record the returned data in a text display
> before saving. The program needs to have a delay between receiving the
> data and requesting the next. It also needs a start and stop button,
> the problem is that once I start the program running I get stuck
> within a do while loop. I have looked at the GetUserEvent but cant get
> it to work. Are there any good examples? Or could you tell me how to
> get it to work.
> Thanks
>
> Nigel
>
> P.S. I am using LabWindows CVI V6.0
> P.S. I have attached the program code.