LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NULL (0x00) is sent when VISA Clear is executed?

Solved!
Go to solution

Dear all

 

We are doing RS232-C communication between programs A(PC) and B(PC).
Program A occasionally receives NULL (0x00).
However, we are not sending NULL from B.

 

There was a part in program B that executes VISA Clear.vi, but if I remove that part, program A no longer receives NULLs.
Does executing VISA Clear send NULLs as the title suggests?

 

I found the following description in the LabVIEW help, but I wonder if it has anything to do with this.
・Serial INSTR-VISA flushes (discards) the I/O output buffer, sends a break, and flushes the I/O input buffer.

 

Any help would be greatly appreciated.

 

0 Kudos
Message 1 of 6
(1,068 Views)
Solution
Accepted by topic author yuma_ysd

The null char may be caused by the break. Do you really need to clear the output buffer? I mean, there are characters in the output buffer that you don't want to send anymore? If you only need to flush the input instead, just read and discard whatever is pending:

 

pincpanter_1-1664866238841.png

 

 

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 6
(1,052 Views)

Thank you for your response.

 

>>The null char may be caused by the break.

Is it a problem on the receiving end that the break is recognized as null? I am hoping to solve this problem on the sending side, as I do not want to change the receiving program as much as possible this time.

 

>>Do you really need to clear the output buffer?

I honestly don't think it is necessary, but due to existing code created by others, I need to investigate.
If it looks like clearing the receive buffer is all I need to do, I would like to do it the way you taught me.

 

Thanks.

0 Kudos
Message 3 of 6
(1,009 Views)

I also think the device clear is what is causing your issue.  Per Wikipedia:

break condition occurs when the receiver input is at the "space" (logic low, i.e., '0') level for longer than some duration of time, typically, for more than a character time. This is not necessarily an error, but appears to the receiver as a character of all zero-bits with a framing error."

 

So the break is causing a "low" for long enough that is shows up as a NULL character on the other side.  This would also mean the break time approximately matches 9 characters (1 start bit, 8 data bits) and the idle (high) just looks like a stop bit.  You could try using a property node to set the Serial Break Length to something really short (1 ms is the minimum value that property can be set).

 

But I have yet to have an interface where I actually needed the VISA Clear.  A read before running the main code (to sync up to messages) is generally needed if the other device is constantly spitting out data.  Otherwise, you are likely handling the port incorrectly (and I would guess this is the case since you are using a local variable for the reference).

 

You might want to watch this video: VIWeek 2020/Proper way to communicate over serial


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(990 Views)

@crossrulz wrote:

I also think the device clear is what is causing your issue.  Per Wikipedia:

break condition occurs when the receiver input is at the "space" (logic low, i.e., '0') level for longer than some duration of time, typically, for more than a character time. This is not necessarily an error, but appears to the receiver as a character of all zero-bits with a framing error."

 

So the break is causing a "low" for long enough that is shows up as a NULL character on the other side.  This would also mean the break time approximately matches 9 characters (1 start bit, 8 data bits) and the idle (high) just looks like a stop bit.  You could try using a property node to set the Serial Break Length to something really short (1 ms is the minimum value that property can be set).

 

But I have yet to have an interface where I actually needed the VISA Clear.  A read before running the main code (to sync up to messages) is generally needed if the other device is constantly spitting out data.  Otherwise, you are likely handling the port incorrectly (and I would guess this is the case since you are using a local variable for the reference).

 

You might want to watch this video: VIWeek 2020/Proper way to communicate over serial


I agree with this.  In my experience, "needing" something like VISA clear usually means you don't completely understand communications with your instrument.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 5 of 6
(981 Views)

Thanks for the reply.

 

It looks like the null reception factor should be a break command.
I have checked and it seems that VISA clear is unnecessary, so I am going to remove it.

 

Thank you for the video, I will take a look.

0 Kudos
Message 6 of 6
(929 Views)