Question for TCP Cellular Radio Driver

I use a button and a Cellular for a simple test.
When GSM and GPRS network connected, I press button to send a sms and send a request to www.google.com.
My questions are:

  1. I can’t get IP address each time. I need rebuild the application many times then get the IP address. How to set the module to reconnect the GPRS to get the IP, instead of rebooting the system?

  2. The debug output shows Exception below

Exception System.Exception - 0x00000000 (4)

#### Message: 
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::ProcessATCommandResponse [IP: 01bd] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::SerialRead [IP: 0030] ####

The thread ‘’ (0x3) has exited with code 0 (0x0).
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll

  1. When I see the Ip in the output window, I press the button.
    After the button is pressed, the system hangs.
    However the sms successfully send to my phone.
 private CellularRadioManager _radioManager;
        GT.Timer GPRStimer;
        void ProgramStarted()
        {
            Debug.Print("Program Started");
            GPRStimer = new GT.Timer(2000); // every second (1000ms);
            GPRStimer.Tick += GPRStimer_Tick;
            button.ButtonPressed+=button_ButtonPressed;
           
            //GPRStimer.Start();
             _radioManager = new CellularRadioManager(4)
            {
                AccessPointName = "internet",
                DebugPrintEnabled = true,
                IsHttpModeEnabled = true
            };

        }
        private readonly string _crlf = "" + (char)13 + (char)10;
        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            Debug.Print("test");
            _radioManager.SendSMS("0963354403", "Scouring on Bridge1");
            _radioManager.Connect("www.google.com");
            var request =
                "GET / HTTP/1.1" + _crlf +
                "Host: www.google.com" + _crlf +
                _crlf;
            _radioManager.SendData(request);
            var response = "";
            _radioManager.ReceiveData(5000, out response);
            Debug.Print(response);

            Debug.Print("finished");
        }

output:

Program Started
#### Exception System.Exception - 0x00000000 (4) ####
#### Message:
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::ProcessATCommandResponse [IP: 01bd] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::SerialRead [IP: 0030] ####
The thread ‘’ (0x3) has exited with code 0 (0x0).
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
GSM Network Registration Error
GSM Network Registration Error
The thread ‘’ (0x6) has exited with code 0 (0x0).
#### Exception System.Exception - 0x00000000 (4) ####
#### Message:
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::ProcessATCommandResponse [IP: 01bd] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::SerialRead [IP: 0030] ####
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
GSM Network Registration Error
GSM Network Registered
GPRS Network Registration Error
GPRS Network Registered
IMEI: 861785000232458
IP: 116.59.177.15
test

What driver do you mean?
I download the source code form https://tcpcellularradio.codeplex.com/
Then add the CellularRadio and CellularRadioManager to my project.
Any problem?

But why I got problems using that driver?

@ Tzu Hsuan - I would try contact the author on codeplex.

One of the great features of open source software is you have the source. You can use your debugger to analyze the problem, and fix it.

The code that you have found is a good modification of the original driver code, to enable dat a communiation, and does not support sms for example.

The driver is still very buggy and unstable, I would not rely on it, at all.

Dave is working on a new version, when customs allows his GSM modules to arrive, and he sounded really ambitious about rewriting the driver.

Furthermore, there is new cellular chips on their way to the market, and I expect a cheaper and simple option in the relative near future.

If you start debugging and fixing errors in the driver, you should let us know.

Hi njbuch,

I got the modules and working on the software. I am doing this at the same time as I am completing my alarm system as it will be part of that. The existing design which has SMS is working fine, even at 115200 bps on a Cobra 2.

I’ll update you once I have something working reliably.

Hi Dave, if you finished your driver, will you share it?

Yes, I will add it to codeshare.

Reload the driver and re-add it.
Main problem solved. The module can get the IP now.
But the parser problem still exist.
Keep debuging.

Thanks.

This is awsome news, keep up the good work! Looking forward to try it!

I can’t always get the IP using the GPRS module. (maybe 3 times deploying, then get the IP once)
Is this a normal condition?

In my code, when I get the IP, I use a button to send a request to google.
But only in the first time I can get the response. Then, the system hang
Do I need to reset something ?

{
        // This method is run when the mainboard is powered up or reset.   
        private CellularRadioManager _radioManager;
  
        void ProgramStarted()
        {
            Debug.Print("Program Started");
         
            button.ButtonPressed+=button_ButtonPressed;
           
             _radioManager = new CellularRadioManager(4)
            {
                AccessPointName = "internet",
                DebugPrintEnabled = true,
                IsHttpModeEnabled = true
            };

        }
        private readonly string _crlf = "" + (char)13 + (char)10;
        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            Debug.Print("sending data");
           
            _radioManager.Connect("www.google.com");
          
            var request =
                "GET / HTTP/1.1" + _crlf +
                "Host: www.google.com" + _crlf +
                _crlf;   
            _radioManager.SendData(request);
            var response = "";
            _radioManager.ReceiveData(5000, out response);
            Debug.Print(response);

            Debug.Print("finished");
        }  
                        
    }

Output:

Program Started
The thread ‘’ (0x3) has exited with code 0 (0x0).
#### Exception System.Exception - 0x00000000 (4) ####
#### Message:
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::ProcessATCommandResponse [IP: 01bd] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::SerialRead [IP: 0030] ####
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
GSM Network Registration Error
GSM Network Registration Error
GSM Network Registration Error
The thread ‘’ (0x6) has exited with code 0 (0x0).
#### Exception System.Exception - 0x00000000 (4) ####
#### Message:
#### System.Convert::ToInt64 [IP: 00af] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::ProcessATCommandResponse [IP: 01bd] ####
#### Gadgeteer.Modules.Mekalogic.CellularRadio::SerialRead [IP: 0030] ####
A first chance exception of type ‘System.Exception’ occurred in mscorlib.dll
GSM Network Registration Error
GSM Network Registered
GPRS Network Registration Error
GPRS Network Registered
IMEI: 861785000232458
IP: 116.59.179.55
sending data
HTTP/1.1 302 Found
Location: Google
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=3dad002b607fe34e:FF=0:TM=1381823626:LM=1381823626:S=YN-IsQvgi-HPHvw0; expires=Thu, 15-Oct-2015 07:53:46 GMT; path=/; domain=.google.com
Set-Cookie: NID=67=JcLx96ulQO4jKWTj0d_akkNktqyD41IS4ORBNnHyX_Jzl6gmI3zy7PX23erAW7iEW8WxzGzDHI9q9W-63LtXkKqzxPZUUZNnOuRyH-cRswIxQ0pNuv3zmpKdEua0Yv9k; expires=Wed, 16-Apr-2014 07:53:46 GMT; path=/; domain=.google.com; HttpOnly
P3P: CP=“This is not a P3P policy! See P3P and Google's cookies - Google Account Help for more info.”
Date: Tue, 15 Oct 2013 07:53:46 GMT
Server: gws
Content-Length: 262
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alternate-Protocol: 80:quic

302 Moved

302 Moved

The document has moved here.

finished
sending data