Quantcast
Viewing all articles
Browse latest Browse all 68975

Empty serial port read buffer

Hello everyone. I am currently programming a vi that takes an input string from a serial device and parses that string. The only issue I am having is that, (presumably) in between reads, when the buffer empties, the vi will parse this empty buffer and return an error message because the now empty string doesn't conform to the standard string that is expected. How do I go about fixing this, assuming I have interpretted the source of the error correctly?

 

Edit: I wanted to add that searching turned up advice that suggested setting the Visa read control to synchronous. This doesn't seem to have made a difference.

 

Edit 2: Attached the vi as well. Here's what's going on. The device being read is an infrared thermometer that has an operational range of 550-3000C. When the temperature is below 550, the output is "HCC -U-". This output is terminated by a carriage return and line feed. When the tempartue is above 550, the output is "HUCxxxx" where the x's represent the digits. This string is read and the parsed. If the HCC is found, it then searches for " -U-". If found, this is displayed. Otherwise "ERROR" is displayed. In the event that HUC is found, the 4 characters after it are displayed and graphed.

 

To observe what is happening, I have a text box to show the contents of the read buffer and then another to display the parsed string. There is a final text box (output string 2) that shows the temperature should a numerical value register. I have also thrown in a led that lights up when the string parses properly and turns off in the event that "ERROR" is displayed.

 

Here is what is happening: when the temperature is below 550, I first see HCC -U- in the read buffer display, -U- in the parsed display and my led lights up. Then, presumably the buffer is emptied because I see the display empty, the parsed display now shows ERROR and the led goes off.


Viewing all articles
Browse latest Browse all 68975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>