1
\$\begingroup\$

I have two measurement circuitry connected to two separate Arduinos.

I need to grab and record data from the two simultaneously, so how can I monitor and record data from two serial stream from separate USB cords?

I don´t have a unix system but I have been using Cygwin so far. I´m currently installing Ubuntu on VMVirtualBox. Can I just open multiple shells in Ubuntu and record the data in that way given that I know my COM ports?

\$\endgroup\$
1
\$\begingroup\$

It should work, but there is no need to install Linux just for this purpose...

You could do what I did: I opened putty windows, and set it to log the output to file. I made the serial output of the Arduino code so that it was pasteable (is that a word?) into Excel to be able to easily display the result as a chart.

It worked like a charm.

\$\endgroup\$
  • 1
    \$\begingroup\$ I wanted to have access to Ubuntu anyway, so this gave me a chance to install Ubuntu. Also, I have been having problems with serial streams in Windows, the communications tends to rupture in the middle of my data recording. \$\endgroup\$ – l3win Sep 17 '13 at 19:25
  • \$\begingroup\$ Simple, clear, and concise. +1 \$\endgroup\$ – Anonymous Penguin Sep 18 '13 at 20:41
0
\$\begingroup\$

Using unix-style serial APIs on either Linux of Cygwin, you should be able to read from two serial ports in the same program.

One way that you could do this would be to set the two ports to non-blocking mode, such that the read() call will return 0 if no data is available, which would let you poll the two in a loop - though that may needlessly waste CPU.

Another method is to use select() with a list of both file descriptors, to block until either one has data - then you grab data from that one, and call select() again to wait until something is again available from either.

But note that messages may or may not come in from the two in complete pieces which can be trivially interleaved - so you may need some per-port software buffering and logic to hold onto received bytes from several select()/read() cycles until you get an entire line or record that it makes sense to print out, which will nicely interleave with the entire chunks from the other.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.