Go Down

Topic: Code hangs in interrupt when there is poor GSM signal (Read 5472 times) previous topic - next topic

armin

Hello,

I am using the GSMShield on a custom pcb. This works perfectly when I was developing the code, one of the tests is how the code responds when the GSM signal is lost. Another test is how the board responds with poor GSM signal. This is where a problem occurs.

When the GSM signal is lost I reboot the board. When the board starts with a poor/no signal the gsm.begin() function hangs. (I previously had problems with the power supply but I solved these).

After some digging arround in the code I found in GSM2SoftSerial::recv() a call to mgr->manageMsg(thisHead, cb.getTail()); when the buffer is full, line feed or space.

In GSM3ShieldV1ModemCore::manageMsg I find the implementation which specifies that is we are not debugging we are going to manage the message in the interrupt.

When we manage the response GSM3ShieldV1AccessProvider::manageResponse is called which calls GSM3ShieldV1AccessProvider::ModemConfigurationContinue which will send a new request.

Since this chain happens during an interrupt the normal code will not run untill a good GSM signal is detected. This looks like gsm.begin() hangs.

Can somebody confirm this behaviour? Is there a good work around?

thanks


armin

As a hack I have added a counter in GSM3ShieldV1AccessProvider::ModemConfigurationContinue() which limits the number of tries to get a connection. I think a better solution should be implemented in the library because this bug can create not responsive board. Especially with this GSMboard it is likely the boards are in a remote place.

There are a lot of network related edge-cases that introduces strange problems that locks the modem. I did solve this one, but can't find my answer on the forum. Glad you figured out a way too.

The GSM shield hardware, software and the Quectel module itself, has some severe problems for real world projects... I'm thinking of re-writing the needed AT-commands in a very simple C style with individual timeouts for each command. Our latest discovery were that the Quectel module might take several minutes of trial and error to find a network it can use. A two minute timeout was not enough when the first network refuses it...

dgelectron

Hi armin,

I have exactly that problem. The module keeps looking for connectivity indefinetily... can you tell us the way you solve the problem by modify the librarie?? That will be much appreciated.

Thanks!

I have the exact same problem. Few days ago my Arduino UNO + GSM shiled was working just fine. It now decided not to work for some reason. The NET led keeps blinking, at a higher frequency (than when it is actually connected to the GSM network). It does this for hours and hours without any connection. I have searched the forum and tried everything other have suggested but no luck. Ant help is appreciated. I am new to this stuff and no idea how to work with AT commands.  Thank you.

I have the exact same problem here. I'm doing a beehive monitor system and my arduino is at a poor network signal place.  I have even made a hardware watchdog to reset arduino in case it hangs at this point. It has been working that way fine except for 2 times, when not even after a reset it can stablish connection again. It must be hard reestarted to continue. As i am 250km far away from the system when it happens its very anoing :-( .. I have not had the time to check the library code. It would be very nice to have a solution or good workarround for this problem. .
kind regards,
Amaro Farinha

dtluigi

I have the same issue...and I believe that there are some libraries of GSM that need to be rewritten...

amarofarinha - You need to connect a reset line to the modems emergency shut off pin. This is not included on the GSM board, but it clearly states this in the Quectel hardware manual. There are some GPRS edge cases when the module tries to shut down GPRS but the network has already bin lost and then there is no way to connect to it at all. Without removing the power to the board, or pulling this special line low.

In the arduino sowftware I have an input pin that I set low. Then turn it into an output pulling the emergency shutdown low. Then returning it to an input again. Never drive the pin high as an output as the voltage levels are wrong.

This problem can only be seen in some special physical places. It works without it for months at some places and just a day or two in some. It is not just a bad signal, it is a network related error when the gprs connection can not be disconnected correctly from the network.

LMI

Perhaps this is a similar problem I had with an other GSM Shield. The shield stopped working after day or two. There was no error messages and no way to tell that it had stopped working. Only way to recover was to shut down the power for a second.

I've the same problem sometimes the function  gsmAccess.begin(PINNUMBER, true)==GSM_READY  hangs my process
indefinitely !

I try to put the begin() function in asynchronous  mode by  gsmAccess.begin(PINNUMBER, true, false) ==GSM_READY  but i can't connect  ever when in the same place with synchronous mode i had no problem .

How can i solve this issue ?

Thanks in Advance

** I read the posts before but i don't understand how reset the board when the hangs happens !

armin

Well I started on another gsmshield project so I checked the forum again and I see some replies on my question.

Lets quickly explain what I did (customer is not complaining so it must be working ;) ):

In GSM3ShieldV1AccessProvider.cpp in the library files there is this piece of code:
Code: [Select]

GSM3_NetworkStatus_t GSM3ShieldV1AccessProvider::begin(char* pin, bool restart, bool synchronous)
{
pinMode(__RESETPIN__, OUTPUT);

// If asked for modem restart, restart
if (restart)
HWrestart();
else
HWstart();
 
theGSM3ShieldV1ModemCore.gss.begin(9600);
// Launch modem configuration commands
ModemConfiguration(pin);
// If synchronous, wait till ModemConfiguration is over
if(synchronous)
{
// if we shorten this delay, the command fails
while(ready()==0)
delay(1000);
}
return getStatus();
}


Changes this to:
Code: [Select]

GSM3_NetworkStatus_t GSM3ShieldV1AccessProvider::begin(char* pin, bool restart, bool synchronous)
{
Serial.println("gsm.begin()");
pinMode(__RESETPIN__, OUTPUT);

// If asked for modem restart, restart
if (restart)
{
HWrestart();
}
else
{
HWstart();
}

unsigned loopCnt = 30;
theGSM3ShieldV1ModemCore.gss.begin(9600);
// Launch modem configuration commands
ModemConfiguration(pin);
// If synchronous, wait till ModemConfiguration is over
if(synchronous)
{
// if we shorten this delay, the command fails
while(ready()==0 && loopCnt--)
{
delay(1000);
Serial.println("gsm.begin() waiting for ready");
}
}
return getStatus();
}


In the main code I do a check every few minutes to see if the signal is alive:
Code: [Select]

int reg = PINManager.checkReg();
if(reg != 0 && reg != 1)
     restart();


The restart function does somethings and then it restarts using the AVR's watchdog timer.

Hope this help.

MakoMaker

I am trying to use the Watchdog timer to do just what the code above is doing, reset if the gsm hangs due to poor cell signal and connection in a loop.  Can anyone further explain how to use the watchdog to do this reset.  I only see how to use it with an 8 second maximum, which is not long enough for the code above. 

Also the post above refers to checking every few minutes from the main code.. how is this accomplished? 

msolomos

Would you please spend 5 minutes and let me know where I must place this part of code?
Do you mean somewhere inside the GSM3ShieldV1AccessProvider.cpp?



In the main code I do a check every few minutes to see if the signal is alive:
Code: [Select]

int reg = PINManager.checkReg();
if(reg != 0 && reg != 1)
     restart();


The restart function does somethings and then it restarts using the AVR's watchdog timer.

Awaiting the pleasure of your reply

ElleWoodIoT

AndersHedberg is correct. It's a network related error when the gprs connection can not be disconnected correctly from the network.

If you use a Neo sim, it can easily be detected and fixed w/ the free device management tools that come with the service.

I shortened the link for you here: http://goo.gl/IqScpX

Good luck all!

Go Up