GSM.h with SoftwareSerial.h?

I’m using two things that need the libraries SoftwareSerial and GSM, but they seem to conflict with each other. One friend told me that multiple SoftwareSerials can’t be used in the same thing, but I was wondering if there was any way to get around that. I didn’t think I would be the only person to try something like this, so I was hoping someone on the forum knew anything about this.

I’ve been trying to work with the libraries, and compiling the following code:

#include <GSM.h>
#include <SoftwareSerial.h>

void setup(){
}
void loop(){
}

but that itself just doesn’t seem to work. Does anyone have any ideas on how I can make this work?

Thanks in advance.

I don't know much about GSM, but I can see that GSM3SoftSerial.cpp appears to implement its own version of software serial, which therefore uses the pin-change interrupt vectors.

#if defined(PCINT0_vect)
ISR(PCINT0_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT1_vect)
ISR(PCINT1_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

#if defined(PCINT3_vect)
ISR(PCINT3_vect)
{
  GSM3SoftSerial::handle_interrupt();
}
#endif

Is there anything I can do to fix that?

GSMSoftSerial and SoftwareSerial conflict with each other because they use the same pin interrupts. I got around this by using the AltSoftSerial library instead of SoftwareSerial. It does not use pin interrupts, or at least not the same ones as GSMSoftSerial. Serial communication with AltSoftSerial can only be used through two specific pins. You can download it and see the documentation here: http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html.

Another possible solution can be found here: http://purposefulscience.blogspot.com/2013/06/arduino-gsm-shield-tips.html. This fix (commenting out some of the interrupts in the library files) will allow your code to compile with both libraries, but you may lose some of the functionality of your GSM shield or whatever else you're using. Be sure to test it out.