Can a serial command library be used for multiple serial ports at the same time?

In one of my projects I need to use multiple Serial ports of an arduino to send/receive commands from other arduinos.
I used the library: SerialCommand (#include <SerialCommand.h>) and it works very well for one port.
It seems to run automatically on the Serial (Serial0) port.
It is possible to have multiple instances of this library to run simultaneously in the same program, one running for Serial and one for Serial1?
So far, I cannot see where is the link to the serial port.

if I do:
SerialCommand sCmdIn;
SerialCommand sCmdOut;
I'm afraid that both instances they will run on the same serial

Any help will be appreciated.
I'm also interested in other libraries that can accomplish this problem.

sorin

Salut, you could do like this..

#include <SoftwareSerial.h>

SoftwareSerial serial1 (1, 2); // RX, TX
SoftwareSerial serial2 (3, 4); // RX, TX

Do not use 1. 0,1 are the hardware serial pins.

sorin_63:
It is possible to have multiple instances of this library to run simultaneously in the same program, one running for Serial and one for Serial1?
So far, I cannot see where is the link to the serial port.

So far, I cannot see where is the link to the library you are referring to.

Is it this one?

Yes, that is the library.
Any ideas?

jurs:
Is it this one?

That one just seems to use HardwareSerial

You can have a few instances of SoftwareSerial but AFAIK it can only listen on one of them at any one time so it is not very practical to have more than one.

The best solution is to use a Mega that has 4 HardwareSerial connections.

If you can organize things so that only one of the other Arduinos talks at one time you could connect them all to a single serial connection. You would need to use some diodes (I think) to prevent the signals interfering with each other. The problem is that they all make their Tx lines HIGH when they are idle.

...R

sorin_63:
Yes, that is the library.
Any ideas?

Just look up the source code of the library:

As you can see, 'Serial' is hardcoded in the source code:

char inChar = Serial.read();

If you want to use different instances of the class with different ports like Serial1, Serial2, Serial3 (on MEGA for example), you would have to rewrite the library with the appropriate changes.