JBH wrote in message news:<506500000008000000DC560000-1027480788000@exchange.ni.com>...
> Does anyone have a solution to monitor the serial port for a carriage
> return line feed? My instrument under test puts data onto the port
> when It is available.This is done asynchronously.I am using the serial
> read VI in a while loop and would like to jump out of the loop upon
> detection of a carriage return line feed which is on the end of the
> data string.
The best solution is to use the VISA functions for your serial
communications. Once you've created the VISA session with the serial
port, you can configure it to terminate reads when a specific
character is read.
To configure the VISA session to terminate a read on a line feed
character, create a VISA p
roperty node and wire your VISA session
reference to it. Then size it to two inputs (elements). Popup on the
first element and select Properties->Message Based
Settings->Termination Character Enable. Wire a boolean to this
element and set it to true. For the second element, select
Properties->Message Based Settings->Termination Character. The input
to this function should be decimal 10, which is the ASCII numerical
value for a line feed character.
Once you do this, reading your instrument will be a snap. There won't
be any need for "loop & snoop" code. All you need to do is use the
VISA read function. It will read the input buffer until the line feed
character is read & then stop and return you the string. Use caution.
If the specified character doesn't arrive within the timeout period,
you'll get a timeout error. You can use the VISA property node to
increase the timeout period. Also make sure that your # characters to
read is equal to or greater than the number you expec
t, including the
carriage return-line feed. Additionally, you can use the VISA
property node to see how many bytes are at the port.
Email me if you have any questions about using VISA with serial
gm