How can I manager two serial (SoftwareSerial)

Good evening,

I already meet that problem and I found the answer (which is not working with my actual issue) Correct me if I am wrong

I create to serial

SoftwareSerial mySeria(2,3);
SoftwareSerial uart_gps(4,5);

Then I begin it

mySerial.begin(9600);
uart.begin(9600);

At the loop, I start listen the cell flux

mySerial.listent();

When I need to listen the GPS coors, I listen uart_gps and when it finish, I re-listen mySerial

uart_gps.listen();
...code...
mySerial.listen();

Do I am correct?

My issue is...

The problem is, I do not declare mySerial (SoftwareSerial mySerial(4,5)) in myfile.ino. uart_gps is declare (SoftwareSerial uart_gps(4,5)) in myfile.ino but mySerial is delcare in my library file : GSM.cpp as the following

GSM::GSM():_cell(_GSM_TXPIN_,_GSM_RXPIN_),_tf(_cell, 10),_status(IDLE){
};



int GSM::begin(long baud_rate){
         (...code...)
    _cell.begin(baud_rate);
         (...code...)
}

Then my question is, How can I listen _cell, which is declare into file library?

I tried gsm._cell.listen()

But it seams to not work

Do I am correct?

Yes. Except, that I can't imagine that you've attached a mySerial to the SoftwareSerial pins. What the hell is a mySerial?

Now, a uart_gps makes sense (except for the uart_) part. That it is a GPS that is attached and being read from/written to is clear.

What a mySerial is is not at all clear.

How is _cell defined? Is it a public variable?

I suggest that you probably need a Mega that has 4 hardware serial ports.

I can't imagine that you've attached a mySerial to the SoftwareSerial pins. What the hell is a mySerial?

What do you means, I should use an hardware? I use a library which use pin 2 and 3 and it work. I prefere to continue use SoftwareSerial for gsm communication

Now, a uart_gps makes sense (except for the uart_) part. That it is a GPS that is attached and being read from/written to is clear.

I am using pin 3 and 4 for to read GPS coords SoftwareSerial uart_gps(3,4);

How is _cell defined? Is it a public variable?

_cell was "protected" and I "moved" it to public section. When I do gms._cell.listen it does not display an error message, but my script stop just at the begining of the steup loop. The message "Please wait..." is display, but nothing happen, after

void setup() 
{
  uart_gps.begin(GPSBAUD);
  //Serial connection.
  //pinMode(GSM_ON, OUTPUT);      Defined in GSM::begin(long baud_rate)
  //pinMode(GSM_RESET, OUTPUT);   Defined in GSM::begin(long baud_rate)
  Serial.begin(9600);
  Serial.println(F("\n----------------------"));
  Serial.println(F("Starting SIM900/908."));
  Serial.println(F("----------------------"));
  Serial.println(F("Please wait..."));
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  
  
  if (gsm.begin(9600)){
    Serial.println(F("\nstatus=READY"));
    started=true;  
  }else{
    Serial.println("\nstatus=IDLE");
  }

I suggest that you probably need a Mega that has 4 hardware serial ports.

No I have to find a solution with Arduino Mini Pro 5V or 3.3V :)

What do you means, I should use an hardware? I use a library which use pin 2 and 3 and it work. I prefere to continue use SoftwareSerial for gsm communication

Fine. But, use a name for the instance that makes sense, like gps, cell, phone, etc. mySerial tells us NOTHING about what is connected.

No I have to find a solution with Arduino Mini Pro 5V or 3.3V

Why? Using suitable hardware makes more sense to me.

pierrot10: my script stop just at the begining of the steup loop. The message "Please wait..." is display, but nothing happen, after

That suggests that gsm.begin(9600) isn't completing. Perhaps because it's trying to read a response from a SoftwareSerial port that isn't listening? I think you need to review the code inside gsm.begin() and see what it's doing, and perhaps add some trace statements so you can see exactly where it's getting stuck. Depending on the sequence of events in your startup code it may be that you can influence which of the SoftwareSerial objects is listening within the call to begin() by the order of initialisation in setup().

@Paul

use a name for the instance that makes sense

I am agree with you. mySerial is "provided" by the library and I would call it cell instead of mySerial. I juts prefere to not modify to much the lib. I am not not a big expert :P

Using suitable hardware makes more sense to me.

It make me confude now. It's not the first time I read this. But Harware it's a bit anoying as we have to disconnect the wire before uploading the code. But I will try to use 0 and 1 and 2 and 3 for the GPS.

harware port, can be use for the GPS? It does not matter?

@PeterH, Yes, I think it's possible now that I check my code, once more. Let's try to change something

mySerial is "provided" by the library

By what library? You said that the GSM library was creating an instance called cell, and that YOU were creating mySerial and uart_gps. I'm confused, I guess.

Please, forgive me, there is no mySerial!!!!

_cell is correct.

I am stupid and I put you in confudion. I just switch to another lib. The previous were using mySerial

SotwareSerial mySerial(2,3)

With the actial library it's _cell.

GSM::GSM():_cell(_GSM_TXPIN_,_GSM_RXPIN_),_tf(_cell, 10),_status(IDLE){
};

I am using that library http://code.google.com/p/gsm-shield-arduino/downloads/list

So sorry, for my bad information.