LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detect String in Serial Port

Hi ,

 

I'm looking to reliably detect a string over a serial port.

The system connected to the serial port is a machine which comes up with a login prompt. The system always says 'login:' at the end of the boot sequence. That string is unique during the boot process, too.

 

Currently I am using the attached VIs, but they do not reliably detect the target string. Sometimes it works, sometimes it doesn't.

 

Also, note that when I set up the serial port, I set it so that there is NO terminating character - I use the standard VISA serial port initialize VI. I don't use a carriage return terminating character because the 'login:' string ends with the terminal cursor right after the colon.

 

Please look at the code and let me know if I'm doing something wrong.

 

Thanks in advance.

Download All
0 Kudos
Message 1 of 2
(2,363 Views)

It would help if you tell us exactly what you get when it does not work.

 

Notes:

1. You should probably be doing the Search/Split String on the concatenated string rather then the current read string.  This is likely where at least part of the problem occurs.  If you get "lo" on one iteration and "gin:" on the next, it will never get the match.  But the concatenated string would have it.  Put an indicator on the output of the Concatenate primitve and watch what happens.

 

2. Consider moving theStop button terminal out of the case structure.  If the remote device is shut down or the serial cable is disconnected, you cannot stop the VI.

 

Lynn

0 Kudos
Message 2 of 2
(2,355 Views)