07-14-2010 10:57 PM - edited 07-14-2010 11:01 PM
Are you sure that you are getting data in from your serial port? Put some probes in different parts of your serial reading loop to see if you are actually getting data out of your serial port, and whether the stop condition of that innermost while loop is being met. Since I don't have your device, I disabled that part of the code and replaced it with dummy data. The data seemed to be logged to the file okay. How much data is your device sending, and how fast? What is your baud rate? You have a 2 second timeout, and your VISA read is waiting for 4096 bytes. That sounds an awful lot like a full buffer. And at 9600 baud (an assumption on my part since I don't know your serial port settings), 4096 bytes are going to take over 4 seconds assuming they are all sent continuously (longer if there are any gaps between bytes due to the way the device sends data.) You would certainly get timeout errors in that case.
Now let's talk about all the other problems with your code.
Search the forums for producer/consumer and also got to File / New ... and look for the design pattern called Producer/Consumer (Data)
EDIT: Wow, I was taking so long to compile my list, Smerc got in a pretty good list himself, including some things I didn't notice. But I think you can safely combine our two lists and work through them to come up with a better program.
07-14-2010 11:09 PM
Good points. I'll take them all onboard.
This is only my second VI so I am still very much trying to figure out how labview sequences events and in what order it does things. I think I am getting the hang of it.
07-14-2010 11:19 PM
There are two key rules for when LabVIEW does or doesn't execute code which is known as a "dataflow" model.
1. LabVIEW will execute a piece of code once all inputs to it are available.
2. LabVIEW will not output any data from a structure (loop, case structure, subVI, sequence frame, ....) until all code within the structure has completed.