Ethernet ENC28, socket and supply power

@ Laura -
Connect from FEZ Raptor to PC directly (no switch / hub), beside a special cable, there are some configuration in PC side you have to be done.
For sure you should connect 2 PCs together and make sure they can talk together first.
@ mcalsyn

About DHCP works but static IP doesn’t work. I think you have tried my example, but if you didn’t please try it.
Just a mention that when use static IP, we have to wait for Network ready event. The static IP is set internally but doesn’t mean network already ready.

@ Laura -

USB Client DP is the perfect one to debug, I think.

Yes, I know, it is what I use. But can I use USB serial SP module in the same time? I don’t think so because it also has a power supply which could deteriorate Fez Raptor board (what I read on this link: https://www.ghielectronics.com/docs/101/powering-the-board).
So I wonder if (and how) I can directly use USB Client DP to receive data on my PC C# code.

It is a good idea.
But I can only ping them from cmd…


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace Server
{
    class Program
    {
        static void Main(string[] args)
        {
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            socket.Bind(new IPEndPoint(IPAddress.Parse("192.168.1.90"), 666));
            socket.Listen(1);
            Console.WriteLine("Listening...");
            var sock = socket.Accept();
            Console.WriteLine("Accepted client " + sock.RemoteEndPoint);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;

namespace Client
{
    class Program
    {
        static void Main(string[] args)
        {
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            Console.WriteLine("Client socket created");

            try
            {
                socket.Connect(new IPEndPoint(IPAddress.Parse("192.168.1.90"), 666));
                Console.WriteLine("Client RemoteEndPoint: " + socket.RemoteEndPoint.ToString());
                Console.WriteLine("Client LocalEndPoint: " + socket.LocalEndPoint.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("Socket connected");
            Console.ReadLine();
        }
    }
}

Do I miss something?

I don’t know if it has been mentioned before, but has the PC firewall been disabled/configured to allow listening on port 666. Typically, ports <=1023 are reservered/system ports.

Not sure I can disabled/configured it. What ports can I use in other case?

@ andre.m - Sorry, I saw wrongly. Thanks.

I would use ports above 1023. I like ports around 10000.

The first time you start the server, with a new port number, look for a dialog box which asks for permission to open the port.

Finally, maybe the reason is here: I can’t disable the PC Firewall set by my company to connect two PCs.
So I will look at the USB serial solution.

But, it doesn’t explain why mcsalyn can run an Ethernet connection with a device, but not with an other…

Ok, so I have now managed to power my board through the barrel connector. I was worried that this problem was due to a shortage of juice via USB, but that’s not the case. I’ve reported all this previously, but here it is again…

G400D Development board, powered by 9V DC brick, connected to USB
Loader (TinyBooter) : 4.3.7.10 (the new one)
TinyCLR : 4.3.7.10

Connected to an ethernet switch hosting network 192.168.1.0/24
Using all three client/server test programs posted above (which are more or less the same) with valid static addressing, a call to socket.Connect() will hang for 30 sec or so and then complete without throwing an exception. The local and remote addrs before the connect are 0.0.0.0 and after are random values. Wireshark detects no network activity from the board outside of a IGMP group membership call to 224.0.0.1, which occurs normally when the TCP stack starts up. But it does not show any of the TCP negotiation that should be the result of the Connect call.

The exact same test programs (all three) run properly on my G120E development board.

EDIT: I should have mentioned that the scenario works outside the debugger, but fails only when running the test programs within the debugger.

@ mcalsyn - what if you use G120(E) with ENC28?

Regrettably, I don’t have an ENC28 - just the two development boards, and some other G120/G400 boards and J11D, but no ENC28. (The title of the thread is confusing, I know - I jumped in when I repro’d Laura’s problem on other ethernet devices).

Another odd and possibly related twist. I tried running my G400 Verdant hub code, which is more complex, and I cannot get it to step in the debugger on this same G400D dev board. The debugger simply exits, but the program is running normally - I just can’t get the debugger to initiate properly. Again, the same code on the G120E dev board works fine.

Attempting deployment…
Incrementally deploying assemblies to device
All assemblies on the device are up to date. No assembly deployment was necessary.
Assemblies successfully deployed to device.
Restarting interpreter…
Attaching to device…
Waiting for device to initialize…
The debugging target and the debugger engine failed to initialize because of unspecified device errors.
The debugger engine thread has terminated unexpectedly with error ‘Could not reconnect to the debugging target after rebooting it.’.