Cellular driver NOT stable


Lots of people have now embraced the new PPP options, and they work. So far so good. Still some edges to polish it seems, and some more working examples. But progress.

Having the module running for longer periods is an evident need, which none I have heard of have managed. It simple throws exceptions in simple string parsing activities, because the modem OR the serial connection is not always stable in its replies. Nothing serious is wrong with the module, that cannot be handled with good error-handling.

But the error-handling is just not good enough. It has been improved, because now it is actually functional, but it crashes for sure within a few hours (days to some people).

A nice christmas present would be a stable cellular driver. In 3 months from now, I have been waiting 2 years for that. :wall:

I have attached an example of an exception, with the string returned from the modem showing, and the code looks too far the “ok” and returns -1. Which crashes the substring.

@ John - please please please, can you have a look at this soon.

@ njbuch - Looks like it is trying to parse incomplete response.

@ njbuch - Since the last SDK I have already made a number of improvements to the cellular radio, especially around response parsing and PPP. You can download the latest source from bitbucket and take a look if you’d like.


yes, that itself looks to be a simple check that can protect the substring from crashing. How is that situation meant to be handled - wait until some more data comes in ?

Indeed, and the question is why the string is incomplete…? I think this is where the homeboys have added a little sleep to ensure that the rest of the string came along.

Well, the latest driver is different a lot. I suggest to try it and see how it handles the situation now.

I will check the new driver asap.

I gave the new driver a quick try last night and found that it will not receive SMS (Event not fired) and the module becomes temperamental about registering on the Cellular network, sometimes it registers other times it doesn’t. Haven’t dug any deeper yet.

@ Sprigo - Could you post some quick code that didn’t receive an SMS? Have you just not received a registration event or did you verify that it truly wasn’t registered?

@ John - I’ve included the code a was using for testing. On the one occasion that the Registered event fired I got an exception on the response parsing. There also appears to be no firing of the incoming call event either.

    public partial class Program
        static CellularRadio gsm;
        GT.Timer smsList = new GT.Timer(60000); // 1 Minute timer
        GT.Timer singleSMS = new GT.Timer(30000);

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
            Debug.Print("Program Started");
            gsm = new CellularRadio(4);

            gsm.SmsReceived += gsm_SmsReceived;
            gsm.SmsListRequested += gsm_SmsListRequested;
            gsm.SmsRequested += gsm_SmsRequested;
            gsm.GsmNetworkRegistrationChanged += gsm_GsmNetworkRegistrationChanged;
            gsm.IncomingCall += gsm_IncomingCall;

            // Would put this after registration but it never seems to fire.
            singleSMS.Tick += singleSMS_Tick;
            smsList.Tick += smsList_Tick;

        void singleSMS_Tick(GT.Timer timer)
            gsm.RequestSms(1, false);

        void smsList_Tick(GT.Timer timer)

        void gsm_IncomingCall(CellularRadio sender, string caller)
            Debug.Print(" Telephone Number : " + caller + " is ringing.");

        void gsm_GsmNetworkRegistrationChanged(CellularRadio sender, CellularRadio.NetworkRegistrationState networkState)
            switch (networkState)
                case CellularRadio.NetworkRegistrationState.Registered:
                    Debug.Print("Registered on Network");

        // Expect this to fire after a request for an SMS.
        void gsm_SmsRequested(CellularRadio sender, CellularRadio.Sms message)
            Debug.Print("-------------------------------------------------------------- SMS REQUESTED ----------------------------------------------------------------------------");

        // Expect this to fire when new SMS received by module.
        void gsm_SmsReceived(CellularRadio sender, CellularRadio.Sms message)
            Debug.Print("-------------------------------------------------------------- SMS RECIEVED -----------------------------------------------------------------------------");

        // Expect this to fire after a request for the list.
        void gsm_SmsListRequested(CellularRadio sender, ArrayList smsList)
            if (smsList != null)
                Debug.Print("-------------------------------------------------------------- SMS LIST -----------------------------------------------------------------------------");
                foreach (CellularRadio.Sms message in smsList)
                    Debug.Print("-------------------------------------------------------------- SMS LIST ITEM -----------------------------------------------------------------------------");
                    Debug.Print("SMS Recieved:");
                    Debug.Print("       Index : " + message.Index.ToString());
                    Debug.Print("Phone Number : " + message.PhoneNumber);

@ Sprigo - I pushed up a few fixes to SMS handling.

I wasn’t able to reproduce the GSM exception, the event raised fine every time. If you could get some information on the exception if you see it again that can help. The easiest way to solve it is for you to capture the unsolicited message for the registered event.

I have not had a chance yet to test your calling issue, so if you see if any data is received on the port when you call the device, I can look into that as well.

1 Like

@ John - Pulled your changes from BitBucket and it seems to be working flawlessly with no repeat of the ArgumentOutOfRange exception so far. I’ll update my project to use this version and continue testing.

Many thanks.

Same here, thanks for the effort John. This is awsome. Will leave the system running with debugger attached the next days. :clap: :clap:

I’ll try it too. 8)

I’m still having problems using the last Cellular Radio driver version.
As you can see in the attached image, an “uncaught exception” is being thrown trying to elaborate the signal strength’s response.

I also noticed that the signal strength is not stable (as you can see in the immediate window).

Foolishly I don’t plugged in a strong power supply during this test, so the Cellular Radio module was powered only by USB. Maybe this could be the cause of uncaught exception and signal strength’s instability?

I must say that I have experienced many times that the USB supply only, had a significant impact on my signal strength…

But still, it should just deal with it, and return “Sorry, your foot is too big to complete this request!”. :wink:

@ BigFoot - When you get that exception, what is the value of response?

@ John - This is the value: 1ö€€AT+CSQ

See also the attached print screen.

@ BigFoot - Can you post a small program that I can use to reproduce that error?

@ John - Here it is! http://www.filedropper.com/gadgeteercellularradiotest32csharp

It’s the same project I’m using to test.

Feel free to ask me additional info to reproduce the issue.

P.S. this forum’s engine allows me to upload only images? Am I right? Or there’s the possibility to upload also a zip folder?