Go Down

Topic: Use both USB ports at the same time? (Read 619 times) previous topic - next topic

exedor

Apr 17, 2013, 04:03 am Last Edit: Apr 17, 2013, 04:45 pm by exedor Reason: 1
In the testing that I've done it seems that using Serial and SerialUSB at the same time does not work.  If I use only Serial or only SerialUSB everything works great.  I've tried this in the setup() function:

Code: [Select]

 while (!SerialUSB) ;
 SerialUSB.begin(0); //baud value is ignored in underlying implementation
 SerialUSB.flush();
 
 while (!Serial) ;
 Serial.begin(115200);
 Serial.flush();
...


It doesn't seem to matter which 3 Serial or SerialUSB statements to initialize serial communications come first.  In both cases both ports stop working.  I was curious why this might be the case.

Is anyone successfully doing read/write I/O through both the native and programming USB ports??  I have not tried doing end/begin calls every time I want to write something to one port or the other and just switching back and forth but that seems like a computationally expensive use case I'd want to avoid.

Any insights here would be greatly appreciated.


gslender

I'm having issues with serial ports and Due / USB - I wonder if this is something to do with baud rate? Have you tried lower rates?

G

exedor

#2
Apr 22, 2013, 09:24 am Last Edit: Apr 22, 2013, 07:52 pm by exedor Reason: 1
I have tried different baud rates for the actual Serial port and it doesn't seem to matter.  Of course if you go read the code for the implementation of SerialUSB The .begin function is a dummy function there for backward compatibility which has an empty code block.  This  makes sense since it is a native USB end point so that call (SerialUSB.begin(bps)) in my latest code is actually commented out since it is just unnecessary overhead.



Go Up