08-01-2023 06:19 PM
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:
08-01-2023 06:54 PM
So what are you expecting, reading bytes at port before you do a read?
08-02-2023 11:46 AM
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?
08-02-2023 11:53 AM
Most serial communication issues can be solved by watching this video: Proper way to communicate over serial
08-02-2023 12:22 PM
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.