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
}
}
}
}
}
}
}