From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

RS-232 laser returns \00 in backslash codes randomly

For some reason the laser with which I am communicating returns \00 several times in the return string rather than the data requested. When the query functions correctly I receive :
\r\nSapphire:0->\s
However when ever it fails it returns:
\00\r\00\n\rSapphire:0->\s
This causes the VISA read to error out and the program to stop, the erroneous code is always the same leading me to believe there is some setting that is off. Te flow control is set to none as determined by the manufacturer, and the baud rate is at 19200 as suggested. Thus far I have tried breaking the queries and commands up into sequence structures to prevent overlapping communication and also implemented time delays to ensure the buffer is read
y to be read from.
Any suggestions would be helpful.
Thanks,
Dave
0 Kudos
Message 1 of 4
(3,340 Views)
Dave:

There are 2 possibilities here:

1) The device is actually sending back \0 in its data stream. If that is the case, VISA Read should not return an error. If the status code is successful, then all you need is a way to tell the driver to strip out NUL characters. Assuming you are using LabVIEW, set the property "Discard NUL" to True. In this case, all should be well and you should not have to do anything else.

2) The device is not sending back \0 in its data stream. VISA Read is detecting a parity error, for example, and setting the offending portion of the input stream to the error replacement character. Since the default error character is \0, you can verify this by changing the property "Replace Char" to something else and see if that
appears in your data stream. In this case, you will find that you do indeed have transmission errors, and you'll need to figure out the root cause. What is the error code?

I hope this helps.

Dan Mondrik
National Instruments
0 Kudos
Message 2 of 4
(3,340 Views)
Dan, thanks for the help however it still errors out. I have tried the property node for discard NUL and set that to true and still received the null characters. So I tried the replace char property and the \00 still shows up. I noticed you referenced it at \0 rather than \00 which I am recieving back, perhaps there is a difference? The odd thing is that everything looks normal when "spying" on the data sent and received using hyperterminal, the extra \r and \n characters dont seem to affect it there.

As for the error code besides being stuffed with two sets of "\00" and one "\r" it brings the pop up window saying : Error -1073807298 occurred at VISA Read in ASI_Serial_Get_Reply[2].vi->laser boot.vi where laser boot is my main VI and the ser
ial get reply is my sub vi with a read in it.

Should I be using a VISA clear after each VISA read call to ensure there is no data left in the buffers of is there some other VISA function or property node I should be using?

Any help would be very appreciated. I will attach my vi as it is incase that may proove helpful.

Thanks,
Dave
0 Kudos
Message 3 of 4
(3,340 Views)
I discovered the problem using a different data spy for the serial port. It seems the carriage return + line feed was causing the error. The timing would allow the combination to work some times but not every time. By using a carriage return constant alone the program functions flawlessly.

Thanks again for the help.
0 Kudos
Message 4 of 4
(3,340 Views)