I’m trying to switch an old project from 4.2 framework to 4.3.
I need to initialize ENC28 with Static IP and then start a web server.
In 4.2 project I initialized the ENC28 and started Web server using this code:
With NetworkInterface.GetAllNetworkInterfaces()(0)
.EnableStaticIP("192.168.2.64", "255.255.255.0", "192.168.2.1")
.EnableStaticDns(New String() {"8.8.8.8"})
End With
WebServer.StartLocalServer("192.168.2.64", 80)
Now, in framework 4.3 the same code throws this exception on the row of WebServer.StartLocalServer function:
ErrorNumber: 10022
Message: Exception was thrown: System.Net.Sockets.SocketException
StackTrace:
@ BigFoot - How the FEZ Cerberus handles networking was brought in line with the rest of our products in the 4.3 SDK. https://www.ghielectronics.com/docs/30/networking discusses how to initialize the network now.
@ John - I read that document and I also tried this code:
Dim pEth As New GHI.Networking.EthernetENC28J60(Hardware.SPI.SPI_module.SPI1, Hardware.Cpu.Pin.GPIO_Pin7, Hardware.Cpu.Pin.GPIO_Pin8, Hardware.Cpu.Pin.GPIO_Pin9)
pEth.Open()
With pEth
.EnableStaticIP("192.168.2.64", "255.255.255.0", "192.168.2.1")
.EnableStaticDns(New String() {"8.8.8.8"})
End With
but the same exception is thrown.
Maybe are wrong the parameters of EthernetENC28J60 constructor?
@ BigFoot - You need to update the pins to match your hardware setup as the document talks about. If you are using Gadgeteer, just connect the ENC28 module in the designer and it will be taken care of for you.
@ John - I found the issue. I didn’t call the EthernetENC28’s function .UseThisNetworkInterface() .
Now I found another problem using WebServer.
Those are the steps I do:
Set EthernetENC28 using static ip address;
Start a web server on port 80;
Manage the web server’s default event using a WebEvent’s class instance.
When I request the default page from a browser I see in the Immediate Control Window that there is a thrown exception IndexOutOfRangeException from Gadgeteer.WebServer.dll:
[quote]Using mainboard GHI Electronics FEZ Cerberus version 1.3
IS OPEN : True
Web server started at http://192.168.2.64:80/
Program Started
Eccezione first-chance di tipo ‘System.IndexOutOfRangeException’ in Gadgeteer.WebServer.dll[/quote]
This exception is thrown each time I request the default page.