LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving from two USB ports; bytes still at port

Hi y'all, I am reading a custom message (i.e.," *122$326#" ) from two Arduino. They both connect via USB (Com 4, Com 6) and I have the baud rate at 57600. However, the issue is that Bytes at Port shows 3000 bytes at any time when the data is collecting. I believe this is causing the issue that I am seeing in the data where I get empty messages. When only one Arduino is connected, the data is fine.

 

Is it an issue of how I am saving the data? Or that they are both in the while loop?

 

Below is a screenshot and the code:

 

Joaquinh_0-1690931974841.png

 

0 Kudos
Message 1 of 5
(600 Views)

So what are you expecting, reading bytes at port before you do a read?

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.
0 Kudos
Message 2 of 5
(586 Views)

Hi Bill,

 

I was expecting to have feedback of the buffer only to see if the laptop is holding up. Am I placing it in the wrong location?

0 Kudos
Message 3 of 5
(539 Views)

Most serial communication issues can be solved by watching this video: Proper way to communicate over serial

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 5
(535 Views)

Generally, I keep each serial port in its own loop.  This way one bus does not hold up the other.  You should also remove the wait in the loop; let the serial communication limit the loop rate.

 

The other potential issue is the saving to a file.  If the writing to the TDMS file is slow at all, it will hold up the reading from the port.  A Producer/Consumer should be used to move the writing to the file into a separate loop.  You can use a single queue from multiple loops and have a single loop receive the data and write to whichever channel it needs to be written to.

 

I would also be tempted to push back on using TDMS.  TDMS is not really designed for strings.  You might want to consider using 2 simple text files or actually parse the read data and write to the the TDMS file in the numeric format.


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 5 of 5
(527 Views)