Main Site Documentation

Issue with Fez Connect Sheild


#1

Hello, Im using my Panda II with the Fez connect shield and I seem to be in a bit of a pickle. After a couple months away from Fez I pulled out my Fez Ultimate kit (everything was nicely stored in their respective bags within the box). I tried to utilize the Ethernet shield and to my dismay I could not get any kind of connection. Im using code straight out of the the “Internet Book of Things” and my router settings are correct. When I plug in the fez the Link,SPD and Fox lights stay solid green for 5 seconds before going out. I have tried updating the firmware and wiping out all user data but to no avail. I have a red light on PWR and a red light on D18, it is operating with the 5v Jumper set to 5v. I think im having hardware troubles because not more then 2 months ago this worked just fine on the same network (Same IP allocation and router setup info) I have checked there are no devices holding the IP lease I want, if I try to use a temperature sensor on the Fez Connect Shield it reads crazy numbers like 635 and 754 (its not that hot here). I hope im missing something, I would hate to loose this device.

Code I am using is as follows;

using System;
using System.Threading;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Net;
using GHIElectronics.NETMF.Net.NetworkInformation;
using GHIElectronics.NETMF.Net.Sockets;

public static class MySocketServer
{
// Our LED eblock is connected to Di5
static OutputPort LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di5, false);
public static void Main()
{
byte[] ip = { 192, 168, 0, 190 };
byte[] subnet = { 255, 255, 255, 0 };
byte[] gateway = { 192, 168, 0, 1 };
byte[] mac = { 0x00, 0x88, 0x98, 0x90, 0xD4, 0xE0 };
WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,
(Cpu.Pin)FEZ_Pin.Digital.Di7, true);
    NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
NetworkInterface.EnableStaticDns(gateway);
// Our Listening socket
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
// Telnet usually uses port 23
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 23);
server.Bind(localEndPoint);
// start listening
server.Listen(1);
while (true)
{
// Wait for a client
Socket Sock = server.Accept();
new TelnetProcess(Sock);
}
}
internal sealed class TelnetProcess
{
byte[] prompt = Encoding.UTF8.GetBytes("\r\nFEZ >");
private Socket clientSocket;
bool EchoIsEnabeled = false;
public TelnetProcess(Socket Sock)
{
clientSocket = Sock;
// Spawn a new thread
new Thread(Process).Start();
}
private void HandleCommand(string cmd)
{
string str;
cmd = cmd.ToUpper();
switch (cmd)
{
case "ECHO":
EchoIsEnabeled = !EchoIsEnabeled;
clientSocket.Send(prompt);
str = "EchoIsEnabeled = " + EchoIsEnabeled;
clientSocket.Send(Encoding.UTF8.GetBytes(str), 0, str.Length,
SocketFlags.None);
break;
case "LED ON":
LED.Write(true);
clientSocket.Send(prompt);
str = "LED is now on";
clientSocket.Send(Encoding.UTF8.GetBytes(str), 0, str.Length,
SocketFlags.None);
break;
case "LED OFF":
LED.Write(false);
clientSocket.Send(prompt);
str = "LED is now off";
clientSocket.Send(Encoding.UTF8.GetBytes(str), 0, str.Length,
SocketFlags.None);
break;
}
}
private void Process()
{
    byte[] command = new byte[100];
    int index = 0;
    using (clientSocket)
    {
        clientSocket.Send(prompt);
        while (true)
        {
            if (clientSocket.Receive(command, index, 1, SocketFlags.None) == 0)
            {
                clientSocket.Close();
                break;
            }
            if (command[index] == '\r')
            {
                // do we have some data?
                string cmd = new string(Encoding.UTF8.GetChars(command), 0, index);
                HandleCommand(cmd);
                index = 0;
                clientSocket.Send(prompt);
            }
            else if (command[index] >= 32 && command[index] <= 126)
            {
                // Echo back
                if (EchoIsEnabeled)
                    clientSocket.Send(command, index, 1, SocketFlags.None);
                index++;
                if (index >= command.Length)
                {
                    Debug.Print("We have too much data!");
                    index = 0;//dump it all
                }
            }
        }
    }
}
}
}

#2

I neglected to add, but when I try to execute that code I get the error:

[quote]An unhandled exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.W5100.dll

Additional information: Fail[invalid ip,port]
[/quote]


#3

are you are using the wrong references? you need the references for the w5100 library.

it would also help to say which line got the exception.


#4

Personally, I would grab a copy of this project and fire it up. http://code.tinyclr.com/project/426/fez-connect-web-server/ That will allow you to easily confirm that the hardware pieces are not at fault.


#5

Thank you for the replies, I have tried the project @ http://code.tinyclr.com/project/426/fez-connect-web-server/ and it executes just fine but I still have no network connectivity. All the needed references are in place. It seems to be hardware if you ask me :frowning:


#6

… which is why it’s important to make sure you use a “known working project” to eliminate coding as a possible fault.

The beauty of that project is that it includes a complete project, so you can just unzip it and load it into VS.

Lets take some more steps back though. Please check your firmware versions match your SDK versions. Tell us the info the device capabilities and the SDK readme state.

Edit: OK, the below is redundant, you’ve done most / all of that anyway. The conclusion you came to is probably right, this used to work but now does not. The only chance I can see if if you did an SDK upgrade sometime since you last had your app working, and your app had old references.

Then, tell us if you have anything else connected other than Fez Connect. Also tell us about the way you powering this (the Wiznet chips aren’t exactly power hungry, but I’ve seen them be sensitive to power).

Then, open the project file from the above project, write down the references listed, rip them out, and re-add.

Then hit F5 and tell us what happens. In particular tell us how the LEDs flash, if they flash.