10-26-2011 07:05 AM
Hey folks,
Noobie here,
I suppose I've got more than one question- Im looking to stop this VI that I'm posting a jpg of. Its a very watered down equivelant of a much larger program that Im having some issues with. I tried using a local variable, and that didn't work because it was still waiting for the visa read to time out before it processes the stop- I thought killing the VISA session would make for an error instantly and stop the top loop...
also- regarding the timeout on my VISA session- if I can find a way to get this type of architecture to stop immediately when the stop button is pressed, I don't want the VISA session to time out at all since it is possible that data may appear on the incoming serial line that takes precedence over the UI inputs (which are disabled as soon as a command comes in over serial). Is an infinite timeout possible?
thanks
-pat
10-26-2011 07:45 AM
Have a look at this:
Stopping Parallel While Loops in LabVIEW With One Stop Button
Also, there is a better to do what you are doing. Do you mind explaining what your program is supposed to do and possibly post your code?
10-26-2011 08:06 AM
Adnan- thanks a lot for the quick response!
I'll attach the code with this post
I tried local variable as mentioned in the article you linked to, but it still seems to wait for the VISA session to time out.
basically, in a much bigger VI, there's several parallel loops- the two loops in this small VI represent the remote control (through serial) loop and the UI loop structures (an event structure . I need the UI loop to be able to kill the loop thats monitoring the serial input with the VISA session.
Thanks for the info!
-pat
10-26-2011 08:24 AM
Well, the timing out is a separate issue.
You need to understand why you are timing out at Read. Maybe you are not supposed to read 100 bytes but possibly lesser? Also, there needs to be a wait in your while loop. And, why are you writing the same value that you read on the serial port?
Look at the attached image for a better way to develop code.
10-26-2011 08:48 AM - edited 10-26-2011 08:52 AM
You need to understand why you are timing out at Read. Maybe you are not supposed to read 100 bytes but possibly lesser? Also, there needs to be a wait in your while loop. And, why are you writing the same value that you read on the serial port?
EDIT: i just realized I misinterpreted your mods you made- where's the ref for that boolean node coming from? (Thanks again!)
This is just a small VI I threw together to make sure the issues I was having with the main program were not related to any of the hardware I am using (and I didn't realize I forgot a wait until you mentioned it, poor programming on my part).
I beleive it is timing out because it is waiting for the termination character before it passes on whatever data has come in on the buffer- if no term char is received then the data just gets pulled out of the buffer when the amount of data reaches 100 bytes right?
I beleive my issue is that the length of input commands vary, from 4 characters to up to 100 (commands can be concatenated with semicolons in my code) and "byte count" is a required input.
I'm going to try to wire "Bytes at port" directly to "byte count" and re-build to see if that works.
Thanks!
10-26-2011 09:14 AM
Oops sorry that is a local variable. Ignore that node in the image.
You are right about the termination character. Maybe the device is not sending the one that you are expecting?
10-26-2011 09:20 AM
In this case I'm only going from an XPembedded brick PC (the target) through a serial/usb adapter and into the usb port on my laptop- then VISA recognizes the usb adapter as a com port. The VI I built for talking to the target concatenates a line feed (\n with \codes display) with every command.
I'm attaching it as I have modified it- it still waits for the time out of the read- I thought the 'Bytes at port' node being in the while loop it wouldnt let the read enter any state where it's 'waiting'... i guess not...
any other ideas?
Thanks a lot for the help- it's much appreciated
-pat