Pages: [1]   Go Down
Author Topic: Use both USB ports at the same time?  (Read 610 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 2
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
 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.

« Last Edit: April 17, 2013, 09:45:41 am by exedor » Logged

Brisbane, Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


« Last Edit: April 22, 2013, 12:52:59 pm by exedor » Logged

Pages: [1]   Go Up
Jump to: