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.
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.
10-04-2022 01:10 AM
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.
Solved! Go to Solution.
10-04-2022 01:51 AM
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:
10-04-2022 04:22 AM
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.
10-04-2022 06:49 AM
I also think the device clear is what is causing your issue. Per Wikipedia:
A 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
10-04-2022 07:25 AM
@crossrulz wrote:
I also think the device clear is what is causing your issue. Per Wikipedia:
A 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.
10-06-2022 12:54 AM
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.