Pages: [1]   Go Down
Author Topic: Code hangs in interrupt when there is poor GSM signal  (Read 3292 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Offline Offline
Jr. Member
**
Karma: 1
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Turku
Offline Offline
Full Member
***
Karma: 0
Posts: 201
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 !
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink ):

In GSM3ShieldV1AccessProvider.cpp in the library files there is this piece of code:
Code:
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:
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:
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.
Logged

Pages: [1]   Go Up
Jump to: