FEZ Hydra: Connected ENC28 and music module, exception: SPI bus 0 is already reserved

Hello,

I am trying the create a webradio on my FEZHydra. Therefore ENC28 on socket 3 is used for internet connectivity and on socket 4 the music module should do its job.

NETMF version info:
.NET MF 4.3
FEZ Hydra: 4.3.2.0 Firmware, 4.3.2.0 Loader
NETMF and Gadgeteer Package 2014 R2 Beta-3

ENC28 is working fine and I can ping the board. So I wanted to instanciate the music module on socket 4 and this leqads to the following exception:

Exception System.Exception - 0x00000000 (1)

#### Message: SPI bus 0 is already reserved, cannot instantiate it again.
#### Gadgeteer.SocketInterfaces.NativeSpi::GetAndUseInstance [IP: 007a] ####
#### Gadgeteer.SocketInterfaces.NativeSpi::.ctor [IP: 000e] ####
#### Gadgeteer.SocketInterfaces.SpiFactory::Create [IP: 0041] ####
#### Gadgeteer.SocketInterfaces.SpiFactory::Create [IP: 000d] ####
#### Gadgeteer.Modules.GHIElectronics.Music::.ctor [IP: 0095] ####
#### TerraceControl.Program::Main [IP: 001d] ####

A first chance exception of type ‘System.Exception’ occurred in Gadgeteer.SPI.dll

 Gadgeteer.Modules.GHIElectronics.Music musicHardware = new Gadgeteer.Modules.GHIElectronics.Music(4);
            musicHardware.SetVolume(150, 150);

Does this mean I cannot use ENC28 and Music module in parallel on my FEZ Hydra :’(
There are not other S marked sockets available but 3 and four. Please don’t tell me that my hydra board stops my project here :open_mouth:

Reagrds,
sanyo

Are you using a Gadgeteer project or a regular netmf project? What have you connected in your Gadgeteer designer if using that?

Hydra is specific in that you do NOT add the ENC28 on the designer; I suspect you may have done that. But given you explicitly list an instantiation of the music module, it is also possible you’ve just duplicated that as well?

Of course, it could also be a beta issue…

I use a regular NET MF project with some gadgeteering libraries. The designer in gadgeteering is not my friend thus I want to initialize the modulesy myself… :slight_smile:

Here is the intialization code:


 public static void Main()
        {

            FEZHydra mainboard = new FEZHydra();

            Hardware.Ethernet LAN = new Hardware.Ethernet(); // initialization component for ENC28 I have written myself
            Gadgeteer.Modules.GHIElectronics.Music musicHardware = new Gadgeteer.Modules.GHIElectronics.Music(4);
            musicHardware.SetVolume(150, 150);
            musicHardware.RunSineTest();


I try to reproduce this error with a minimum NET MF project.

Hm is there any way to use gadgeteer libraries in plain NET MF without issues?

If you use Gadgeteer libraries then it is not plain MF. :smiley:

I like these libraries so want use them :wink:
Back to topic, the error depends on the order of initalization. See my sample code, it is a plain .NET MF project. If the music module is initalized before the ENC28 everything works fine. In contrast when the ENC28 comes first there is the exception… Is this a bug in the GHI libraries?


FEZHydra mainboard = new FEZHydra();

            Gadgeteer.Modules.GHIElectronics.Music musicHardware = new Gadgeteer.Modules.GHIElectronics.Music(4);
            musicHardware.SetVolume(150, 150);
            musicHardware.RunSineTest();


            EthernetENC28 EthernetInterface = new EthernetENC28(3);
            EthernetInterface.UseThisNetworkInterface(); // Very important!!!
            NetworkInterface[] networkArray = NetworkInterface.GetAllNetworkInterfaces();
            NetworkInterface LAN = networkArray[1];
            LAN.EnableDhcp();



            #region Test connectivity
            // Creates a new web session
            SimpleSocket Socket = new IntegratedSocket("www.netmftoolbox.com", 80);
            HTTP_Client WebSession = new HTTP_Client(new IntegratedSocket("www.netmftoolbox.com", 80));

            // Requests the latest source
            HTTP_Client.HTTP_Response Response = WebSession.Get("/helloworld/");

            // Did we get the expected response? (a "200 OK")
            if (Response.ResponseCode != 200)
                throw new ApplicationException("Unexpected HTTP response code: " + Response.ResponseCode.ToString());

            // Fetches a response header
            Debug.Print("Current date according to www.netmftoolbox.com: " + Response.ResponseHeader("date"));

            // Gets the response as a string
            Debug.Print(Response.ToString());
            #endregion


This is unlikely to be a bug because it’s not a scenario anyone would test against. Call it an undesired consequence of the way you’re doing what you’re doing, which nobody else does.

Having said that, do you actually need the ENC28 on Hydra? Isn’t this one of those devices where you must have the Ethernet firmware loaded and you must have the ENC28 connected when you load that firmware?

Yes back in the NETMF and Gadgeteer Packages for NET 4.2 there was a seperate ethernet firmware. After installing the beta package 4.3 there was no such special ethernet firmware… Where is it now?
So I did use the firmware FEZ Config provided me. Was that wrong?

The ping towards the Hydra works but currently socket connections fail. May the wrong firmware be the reason for failing socket connections?