CLR_E_PIN_UNAVAILABLE (1) Error; please help!

Hello, so I have recently been trying to get my cellular radio module working for SMS, and came across this error before I could even really get into it.


Using mainboard GHI Electronics FEZSpider version 1.0
    #### Exception System.Exception - CLR_E_PIN_UNAVAILABLE (1) ####
    #### Message: 
    #### Microsoft.SPOT.Hardware.Port::.ctor [IP: 0000] ####
    #### Microsoft.SPOT.Hardware.OutputPort::.ctor [IP: 0006] ####
    #### Gadgeteer.Interfaces.NativeDigitalOutput::.ctor [IP: 0018] ####
    #### Gadgeteer.Interfaces.DigitalOutput::.ctor [IP: 0031] ####
    #### Gadgeteer.Modules.Seeed.CellularRadio::.ctor [IP: 0031] ####
    #### Core.Program::ProgramStarted [IP: 007a] ####
    #### Core.Program::Main [IP: 0015] ####
A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll

My code is simply this:


        private CellularRadio cellRadio;

        void ProgramStarted()
        {
            //Socket #4 supports type 'K'
            cellRadio = new CellularRadio(4);
            cellRadio.DebugPrintEnabled = true;
            cellRadio.PowerOn(50);
            cellRadio.SendATCommand("AT");
            cellRadio.SendATCommand("AT+CPIN=0000");
            cellRadio.SendATCommand("AT+CMGF=1");
            cellRadio.SmsRetrieved += new CellularRadio.SmsRetrievedHandler(cellRadio_SmsRetrieved);
            cellRadio.SmsReceived += new CellularRadio.SmsReceivedHandler(cellRadio_SmsReceived);
            cellRadio.ModuleInitialized += new CellularRadio.ModuleInitializedHandler(cellRadio_ModuleInitialized);
         }

And the error occurs on the first line in ProgramStarted(); where I try to initialize the module.

Unfortunately, this is not the first time I have come across this error either. I tried to get my SD card module to work a couple of days ago, in Socket 5 (which supports type ‘F’), and I got the same CLR_E_PIN_UNAVAILABLE (1) Error :frowning:

Pretty frustrated at this point because I cannot find any resources really addressing how to resolve this error. I have triple checked my program and there is no other module / object working on the sockets I am requesting for either the Cellular Radio module, or the SD Card module.

At this point I’m thinking maybe there is a problem with my board? I really hope not. Thanks for any help!

Remove the line [quote]cellRadio = new CellularRadio(4);[/quote] You are using Gadgeteer which automatically creates objects for you.

EDIT: and since this module is already initialized, al the pins are reserved for it, so when you try to create another cellular module object, it fails, as the pins are unavailable.

Check the “Program.Generated.cs” file, initialization happens there.

2 Likes

Wow, such a simple and easy fix… (Still pretty new with Gadgeteer)

EDIT: So I was mistaken, it did not fix my problem completely, I now am having issue calling methods on the cellRadio object - getting NullReferenceExceptions. All I now have is a

 
declaration, and when I try to call, for example, 


```cs]cellRadio.DebugPrintEnabled = true;[/code

I get the NullReferenceException; is there something I'm missing here? Thanks!

EDIT EDIT: Geez am I a noob... need to call methods on the cellularRadio object that Gadgeteer automatically initializes, not my old cellRadio object... Think I need some coffee