serial read variable length
serial read variable length
(OP)
I'm new to LabView (v6) and writing a vi to read an unknown number of bytes from a serial port. I am using a while loop and would like to exit when the VISA byte count has been zero for some amount of time.
I created a timeout vi, but can't use it as a subvi, because the while loop doesn't "see" the controls in the calling vi.
Suggestions?
Craig
I created a timeout vi, but can't use it as a subvi, because the while loop doesn't "see" the controls in the calling vi.
Suggestions?
Craig
RE: serial read variable length
It is slightly more complicated if you need a specific timeout period but not that difficult.
Within the while loop, you can use the same counter to indicate that a 0-byte count has been detected. On the first iteration (when 0-byte counter=0) of the 0-byte condition, capture the millisecond tick count into a shift register and on subsequent loops, subtract the current tick count from the original. If it matches or exceeds your timeout time, break out of the loop. Any byte counts detected after the 0-byte condition and before the loop breakout should reset the counter back to 0.
RE: serial read variable length
LabView should be very helpful once I get used to it.
My vi is starting to have several levels of while/for/case structures. Should I be concerned about getting too deep?
RE: serial read variable length
Generally my rule of thumb is to contain the code to what I can fit on my screen without having to use the horizontal or vertical scrollbars too much. If your code starts to get large, look into condensing some code into subroutines. Making Labview code as easy to read as possible will save you time down the line when you have to debug the code.