02-03-2006 08:20 AM
Hello,
I would appreciate if someone can help me with my problem. Basically, i am trying to receive data via a serial port. I have my UAP set up such that when i press start button it initialises the comport and configures it using OpenComConfig......then i use InstallComCallback which calls the callback routine.....in that routine i use ComRdTerm to read the serial port....
At the moment it works fine but sometimes when i press start, it doesnt receive any data.....so i stop it adn start again....it might get the data otherwise have to do it again.......i dont know why.......in my Stop button......i basically do the following..
InstallComCallback (comport, 0, 0, 0, 0, 0); //stops communication with serial port
FlushInQ (comport); //Flush input que buffer
len= GetInQLen (comport);
CloseCom(comport);
config_flag =0;
port_open =0;
Also i would like to know when i use InstallComCallback (comport, 0, 0, 0, 0, 0); does this also stop filling the input queue? because if i dont flushInQ when stopping...the next time its got 4096 character and because of that some data is missing thus a data loss led goes on.......so i hv realised flushing the input que out solves that problem n i receiev all the data bt sometimes i do not get any data....
Looking forward to hear from someone....
Thanks
k1_ke
02-03-2006 09:16 AM
I am not convinced that your programming approach is sound. I am referring to the repeated calls you seem to make to InstallComCallback(), OpenComConfig() and CloseCom(), triggered by UIR button presses. It may actually be valid, but my personal preference would be to use the InstallComCallback() and OpenComConfig() calls just once in my CVI program, say in main() just before the call to RunUserInterface(). Similarly, I would only CloseCom() once, at the point of exit of the program, say just after the call to RunUserInterface(). That way, you can be sure that you will not be resetting ports at an inconvenient time, which could be causing unexpected and unpredictable data loss.
JR
02-03-2006 09:25 AM
Hi Jr,
Thanks for ur reply. Well i noted your comments but say if i use InstallComCallback in my main program....then as soon as i run it...it triggers the comback routine which starts reading the data from the input que n updating my user interface........but i would like my program to run such that when i press start it should start reading the input que....and when press stop stop readin it.......so how should i go about this then?
Looking forward for ur help.
Thanks
k1_ke
02-03-2006 11:22 AM
It should not be too difficult to arrange for a global variable to be used as a flag throughout your program; for example:
static int enabled;
02-09-2006 01:06 PM