i am using an ethernet shield with a domino as a telnet server.
everything is running fine, except when i reset the device, unable to connect again. seems the ethernet device keeps an open socket in memory and try to close it… but it’s stuck in a loop.
i have to power off and power on the device. to be able to open again a socket.
Your issue though is that the default reset circuitry on the Ethernet shield does not do an effective job of resetting the Wiz chip when the Fez (or Ard) is reset. So the talk about hardware is actually that if you can manually reset the ethernet chip in your code, with a re-routing of the RESET pin on the shield to an IO port, you get the same result.
In your case, a full power off is resetting the Wiz chip correctly and closing any open connection, so that it will respond correctly.
If you wire the reset to an io pin it will work. Just reset the wiz in your code and everything will work correctly. I have made a modbus tcp server on a fez mini and it works. I can disconnect the ethernet cable connect it back and the modbus master happily continues. I can switch off/on the board and the everything continues just working fine.
I just hope that the native code is a bit faster then the code I am using now because it is not that fast when I send over 100 integers = 200 bytes. I am convinced that the guys of Fez will do better.
If only the board could get his power over ethernet then the system would rock. POE is the future in my opinion.
I looked at the ethernet shield with poe and this is what I am looking for. Imagine now having that and a usbizi including the voltage regulation from 24vdc or a bit more (industrial voltage) all on one small pcb.
Thanks for the info guys.
If you use commercial PoE injectors/switches, then you need a good conversion option, yeah. The good news is that the Freetronics guys have built the shield in a way that you can use their [url]http://www.freetronics.com/pages/power-over-ethernet-for-arduino[/url] adapter to do just that. And if you don’t have commercial grade PoE you can just inject the voltage you want
Like I said earlier, we are actively working on an official driver. Just wait couple weeks and it will be all explained and better supported. The driver everyone is using is for demonstration purposes only.
Also, the driver is all open source so feel free to open the W5100 datasheet and fix the drivers anyway you find appropriate.
I followed your advice and went through the W5100 datasheet.
Here is a solution to the problem of warm reboot.
in the FEZ_Shields_Ethernet.cs, in the constructor of uSocket you can change the line :
W5100.RegisterWrite(s, W5100.SocketRegisters.MR, (byte)(protocol));
// for
W5100.RegisterWrite(s, W5100.SocketRegisters.MR, (byte)(protocol +128));
the 128 indicates to the W5100 that he must reinitialize itself first (SOFT RESET ;D )
of course… it’s just a temporary fix when we use just one socket at a time…
now i’m working on my second issue… i can connect once to my tinyclr telnet server but not the second time… i ll post something when this will be solved
stay tuned boyz !!!
Now i can close and open again a connection on my tinyclr telnet server…
here is how i did it :
(again… this post is just to help people to quick fix their soft until the magic wizards from ghi or wherever eventually post the new driver)
tested if the connection was closed in AvailableBytes function :
public int AvilableBytes
{
get
{
//< my changes, first check if we are not disconnected or something else bad...
switch ((int)W5100.RegisterRead(_scoket_number, W5100.SocketRegisters.SR))
{
case 0:
case 1:
case 0x1c:
return -1;
default :
break ;
}
// === changes stop here
return W5100.getSn_RX_RSR(_scoket_number);
}
}
the new thing is that availablebytes now return -1 if you have to reinitialize the listening server.
To do it, i changed the constructor of usocket, i moved the logic into ReInit function and called this new Reinit functions when i Detected that my TCPClient was no more connected… so I m ready for a new connection :
private Protocol protocol;
private UInt16 port;
public uSocket(Protocol protocol, UInt16 port)
{
this.protocol = protocol ;
this.port = port;
ReInit();
}
public void ReInit()
{
byte s;
for (s = 0; s < 4; s++)
{
//....
no you can implement a nice socket server (telnet like), this way :
static class MyServer
{
//declarations and stufff...
static public void Initialize()
{
soc = new FEZ_Shields.Ethernet.uSocket(FEZ_Shields.Ethernet.uSocket.Protocol.TCP, 23); //or the port you like
t= new System.Threading.Thread(new System.Threading.ThreadStart(listenLoop));
t.Start();
}
private static void listenLoop()
{
while (true)
{
while (!soc.Listen()) ;
while (true)
{
System.Threading.Thread.Sleep(10);
int n = soc.AvilableBytes;
if (n < 0) break; //disconnected so get out the while
if (n > 0)
{
byte[] buffer = new byte[n];
soc.Receive(buffer, n);
soc.Send(buffer, n); //echo
dosomethingwithyour(buffer);
}
}
soc.Disconnect();
soc.Close();
soc.ReInit(); //reinitialize the socket
}
}
}