Main Site Documentation

Socket.InvalidSocketException. Module LED7R cannot


#1

Hi, I’m new to embedded, and my first day with hydra is going badly.

I get the following runtime exception when I attempt to debug run my embarrassingly simple first project. :-[

An unhandled exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll
Additional information: Module LED7R cannot be used with invalid socket number 7

I have tried moving the module to all other Y labelled sockets (with the relevant code change) but it doesn’t help. And searching this forum turned up nothing.
Fyi, on delivery the first thing I did was update the firmware.

The board configuration is: USB/power module @ port 2. LED7R (v1.0) module @ port 7.
Hydra board rev = 1.2


using System;
using Gadgeteer.Modules.GHIElectronics;

namespace _1stProject
{
    public class Program
    {
        public static void Main()
        {
            LED7R led = new LED7R(7);         //   <--  exception occurs here
            led.Animate(1000, true, true, false);
        }
    }
}

Output window:
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZHydra\NETMF 4.1\le\GHIElectronics.Gadgeteer.FEZHydra.dll’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).
#### Exception Gadgeteer.Socket+InvalidSocketException - 0x00000000 (1) ####
#### Message: Module LED7R cannot be used with invalid socket number 7
#### Gadgeteer.Socket::GetSocket [IP: 00c7] ####
#### Gadgeteer.Modules.GHIElectronics.LED7R::.ctor [IP: 0013] ####
#### _1stProject.Program::Main [IP: 0005] ####
A first chance exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll
An unhandled exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll
Additional information: Module LED7R cannot be used with invalid socket number 7
The program ‘[5] Micro Framework application: Managed’ has exited with code 0 (0x0).

MFDeploy DeviceInfo:
HAL build info: 4.1.2821.0, Microsoft Copyright © Microsoft Corporation. All rig
OEM Product codes (vendor, model, SKU): 255, 0, 65535
Serial Numbers (module, system):
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Solution Build Info: 4.1.3.1, Copyright © GHI Electronics, LLC
AppDomains:
default, id=1
Assemblies:
mscorlib,4.1.2821.0
Microsoft.SPOT.Native,4.1.2821.0
Microsoft.SPOT.Hardware,4.1.2821.0
Microsoft.SPOT.Graphics,4.1.2821.0
Microsoft.SPOT.TinyCore,4.1.2821.0
Microsoft.SPOT.IO,4.1.2821.0
System.IO,4.1.2821.0
Microsoft.SPOT.Hardware.Usb,4.1.2821.0
System.Xml,4.1.2821.0
Microsoft.SPOT.Hardware.SerialPort,4.1.2821.0
Microsoft.SPOT.Net,4.1.2821.0
System,4.1.2821.0
Microsoft.SPOT.Touch,4.1.2821.0
Microsoft.SPOT.Ink,4.1.2821.0
GTM.GHIElectronics.LED7R,4.1.1.0
1stProject,1.0.0.0
GHIElectronics.OSH.NETMF.Hardware,4.1.3.0
GHIElectronics.Gadgeteer.FEZHydra,4.1.1.0
Gadgeteer,2.41.0.0

[Edited to shorten topic title]


#2

This doesn’t look right. Use visual editor to connect module. It will generate the code for you.


#3

Ok, this time I spawned a new gadgeteer project, ran the visual editor, and it works fine.

So my first project was created by choosing ‘.Net MF console application’, as I’m not keen on wizards - and like to understand the code behind.

Doing a project diff, I spotted 2 things:
1 - my program should have been derived from

Gadgeteer.Program

2 - I had not instantiated

Mainboard = new GHIElectronics.Gadgeteer.FEZHydra(); 

3 - I had not called

program.Run(); // Starts Dispatcher

So I made the changes and my first project now works, but I should have known this before starting out really.
Is there a gadgeteer programmer’s guide somewhere (pdf/webpage) I can read that contains this sort of info please?

Thanks for your help.


#4

With the release of the latest SDK, there are a pair of Getting Started Guides for both the FEZSpider and FEZHydra, located in the SDK directory. Should be in “Program Files\GHI Electronics\GHI .Net Gadgeteer SDK\Getting Started Guides”