01-18-2011 05:03 PM
It may be simple for others but I just have no idea how...
I have two while loops, one is for "VISA write" and the other is for "VISA read".
"VISA write" sends data to serial port continuously.
"VISA read" is a state machine structure with each state reads one byte from serial port. If the data read is expected, stop "VISA read" while loop And "VISA write" while loop.
How can I stop the "VISA write" while loop as required? Local variable is not reasonable, and I don't other ways yet.
Any suggestions?
Thank you.
01-18-2011 05:34 PM
Search for "notifier" in the forums.
Why would a local variable not be reasonable for you?
Why do you need VISA Write and VISA Read in different loops? Most serial port applications are a back and forth, write and read, scenario.
01-18-2011 05:56 PM
This is one instance where Local is a good solution, but scratching that you can use Global (just a worse version of Local in this case), Action Engine, Events, queue or notifier.
/Y
01-18-2011 08:11 PM
Attached pls find a solution for that.
01-19-2011 07:46 AM
I attached the VI in another post http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/serial-port-VISA-read-error/td-p/1418364
This VI will be used as a sub-VI and no extra boolean button or other control can be reached by caller-VI.
I'm not sure what you meant by back and forth. I have to send out a complete command to serial port and read the command response back from serial port and intepret it.
Do you mean to have a loop outside this one scenario (send out a command and read back the response)?
I tried this but most of the time i got error like memory structure damage at "unflatten from string" vi.
01-19-2011 10:52 AM
Better yet, if everything is already typdefed, edit the typedef, changing the ring to an enum, apply changes, edit the strings, then apply changes again.
01-19-2011 11:38 AM
I think I used enum instead of ring.
01-19-2011 12:44 PM - edited 01-19-2011 12:46 PM
Edit:
Haha I misinterpreted your jpg. Ignore this post. 😄
01-19-2011 09:06 PM
@MileP wrote:
I'm not sure what you meant by back and forth. I have to send out a complete command to serial port and read the command response back from serial port and intepret it.
Yes. That is exactly what I mean. You send out a command then read the response back. That means a Write then a Read in that order, all in a single loop. Putting the write in a loop and the read in a separate parallel loop makes no sense and would make it that much more difficult to due the Write then Read that you are looking for.
Have you looked as the Serial port examples in the Example Finder?
01-20-2011 07:25 AM
Thank you. I've tried what you said. It is better.