SoftwareSerial method in gsm library problem

Hello everyone,

I downloaded a gsm library from Google Code Archive - Long-term storage for Google Code Project Hosting.
There is a gsm.cpp and a sim900.cpp. The problem starts in method 'begin' of gsm, which I call in my main:

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

int GSM::begin(long baud_rate){

	int response=-1;
	int cont=0;
	boolean norep=false;
	boolean turnedON=false;
	SetCommLineStatus(CLS_ATCMD);
	//_cell.begin(baud_rate);              // original
	mySerial.begin(baud_rate);		// workaround
	setStatus(IDLE); 
and so on...

If I use _cell.begin (or later _cell.println(...)), I can read (via hardware connect to my pc via external rs232 connection to the software serial pins) that I write correctly to the software serial but nothing is returned.
If I do not use _cell but instead state 'SoftwareSerial mySerial(RX,TX) in gsm.cpp' and then use mySerial.xxx to print to the Softport, I get the correct results.
But then I can not use mySerial in sim900.cpp the same way, cause I would define it twice.

Hope you guys can help. Thanks in advance.

RandomWireMan

GSM_Shield_GPRS_Ver_3_06_(IDE100).zip (111 KB)

I had to increase the RX buffer in the software serial to use it with my GSM chip. if you go into the NewSoftSerial.h file and change

#define _NewSS_MAX_RX_BUFF 64 // RX buffer size

to

#define _NewSS_MAX_RX_BUFF 256 // RX buffer size

that fixed all my GSM communication issues.

hi stealthtransam,

thanks for your reply. I tried your suggestion but to no avail. Using '_cell' prints the command to the softport, but although it is a println command, it looks like the newline character is missung. I see:
AT
AT
AT
...but no OK as an answer.
If I use a _cell.println("\n");,
I see
AT

AT

AT
...
but still no answer.
Using mySerial.println, the thing just works fine:
AT

OK
...

Cheers,

RandomWireMan

I actually just tested it and got the same results as you on my mac running Arduino alpha 23 serial monitor. How ever when I used a program called Z term on my Mac as a serial monitor the responses showed up. This might be a bug in the Arduino Serial monitor and not something you are doing. Try using a different serial monitor to look at the results if you are using the Arduino one.

Hi Stealth,

I justed tried three different terminal programs (incl. HTerm and ZOC Terminal; ZTerm is only for MAC), usually I am using Terminal V1.9b. But all show the same results.
It actually seems a bit odd that a different software solves the issue since I am not using the terminal to send anything but just keep listening on the port on what arduino sends.
Do you thing you could send me a screenshot with the settings of ZTerm?

Thanks a lot for your help, mate.
I appreciate it very much.

RandomWireMan

hello
I'm also working with gsm modem and I have it working.
Im my case I'm just reading sms from it but I can seend sms or make calls with it.I already try to use that library too but in fact if you are using the newsoftserial library there is a problem with buffer size. I give up from the library(I didnt know that we can maximize buffer size) and instead I use the Seria port1 on my mega witlhout the library gms.
To deal with the modem (in my case SIEMENS MC35) I collect all the AT commands I need and write the code based on it.
Anyway if you need I can give my code in case you chose this way
hope it help you

char numero[12];
char corpo[2];
char sms_array[120];
int i = 0 ;



void setup()  
{
  Serial.begin(9600);
  Serial.println("IInicia Leitura Modem");
  Serial1.begin(9600);
  delay(500);
  Serial1.println("AT+CMGF=1\r\n");  // SetSerial1 mode to text (vs pdu)
  delay(500);
  Serial1.print("AT+CMGR=1");  //Will read SMS on 1 position 


}



void loop()                     // run over and over again
{
carrega_array_dados();
retira_numero_sms();
retira_corpo_sms();


}


void carrega_array_dados()
{
Serial1.println("\r\n"); 
delay(500);
while (Serial1.available() > 0 ) {
sms_array[i] = Serial1.read();
//delay(30);
i++;
//delay(100);
} 
}

//________________________
void retira_numero_sms()
{
int l = 47;
for (int j=0;j<=12;j++){
numero[j] = sms_array[l];
l++;
  }
Serial.println("Numero de SMS Retirado");
for(int i = 0; i<= 12; i++){
  Serial.print(numero[i],BYTE);
  }
}
  
  
//________________________
void retira_corpo_sms(){
int l = 87;
for( int i = 0;i<= 2; i++){
  corpo[i] = sms_array[l];
  l++;
   Serial.print(corpo[i],BYTE);
}
}

Hi 007, stealthtransam

Hugo, thank you very much for your code. I will check it out shortly.
I am not using the NewsoftSerial lib though, I use Arduino 1.0 and the 'build in' SoftwareSerial.
Anyway, I increase the buffer size here and found that 128 byte work all right, and 256 byte cause com3 from the arduino to the pc to not send anything (but that's not the real problem here, I think).
Stealth, you said you didn't get a response using the monitor function in the IDE. But that would be the hardware port, right?
Where did you get your answer from the SoftwareSerial? What I use is an extra circuitry which is connected to my pc to listen direclty on the software port, and here I see the command from the uC but no response from the gsm module.

Cheers,

RandomWireMan