LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to get all data through VISA READ function and attribute node

Dear friends:

    Recently, I met a problem. The program is shown in the following figure. I wanted to read all the data from the serial port at once, but failed.

DK_Zero_0-1667480464212.png

    The program should read all the data in the serial port at one time, but in fact, only 8 bytes of data can be read each time. For example, when the serial port detects 40 bytes of data at a certain time, VISA READ will not read all 40 bytes of data at once, but read 8 bytes each time, until all data are read (as shown in the attached video). In addition, the data detected by the VISA READ function is uploaded through another program. The program uploads a total of 40 bytes of data, 8 bytes each time, in a very short time. 

    Thank you, I hope to hear your thoughts.

 

0 Kudos
Message 1 of 8
(1,384 Views)

You are doin it wrong. Watch this video, VIWeek 2020/Proper way to communicate over serial

 

Why you are you using property nodes and references to display serial data?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 8
(1,372 Views)

Hi zero,

 


@DK_Zero wrote:

The program should read all the data in the serial port at one time, but in fact, only 8 bytes of data can be read each time. For example, when the serial port detects 40 bytes of data at a certain time, VISA READ will not read all 40 bytes of data at once, but read 8 bytes each time, until all data are read (as shown in the attached video). In addition, the data detected by the VISA READ function is uploaded through another program. The program uploads a total of 40 bytes of data, 8 bytes each time, in a very short time. 


Two problems:

  • Using BytesAtPort is wrong when you know how many bytes to read…
  • When you read less bytes than expected then your settings are wrong. Here you enable the usage of TermChars even though you should not have done that…

Did you watch this video yet?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(1,367 Views)

The program that uploads data only sends data at a certain frequency, so the VISA READ function does not know how many bytes of data to read each time. Therefore, the attribute node is used here to obtain the data size in the serial port.

0 Kudos
Message 4 of 8
(1,357 Views)

Thank you for your reply and make the following explanations for your questions:

    1.The actual VISA READ function does not know the number of bytes to be read each time. The program that uploads data only sends data at a certain frequency. Therefore, I need to know how much data exists in the serial port this time and read it out at one time.

    2.I didn't know I had done something like "enable TermChars".

    3.Thank you for the video, I will study it carefully.

 

0 Kudos
Message 5 of 8
(1,350 Views)

@DK_Zero wrote:

Thank you for your reply and make the following explanations for your questions:

    1.The actual VISA READ function does not know the number of bytes to be read each time. The program that uploads data only sends data at a certain frequency. Therefore, I need to know how much data exists in the serial port this time and read it out at one time.

 


Please explain the program's communication protocol.  How are you supposed to know when a message is complete just by looking at raw data?  You can set up your read to mimic this.

 

Of course, I very highly recommend this video.  That guy really knows what he is talking about.😉

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
0 Kudos
Message 6 of 8
(1,331 Views)

Hi Zero,

 


@DK_Zero wrote:

2.I didn't know I had done something like "enable TermChars".


So you use those functions in your VI without knowing them, without reading their context help and without reading their LabVIEW help entries?

You just need to read the help...

 

Hint: Do you know you can switch the context help to show ALL inputs of a function?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(1,322 Views)

To add to my previous message:

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 8
(1,301 Views)