11-03-2022 08:29 AM
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.
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.
11-03-2022 09:04 AM - edited 11-03-2022 09:05 AM
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?
11-03-2022 09:06 AM
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:
Did you watch this video yet?
11-03-2022 09:23 AM
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.
11-03-2022 09:37 AM
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.
11-03-2022 11:31 AM
@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
11-03-2022 12:06 PM - edited 11-03-2022 12:08 PM
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?
11-03-2022 01:55 PM - edited 11-03-2022 01:55 PM