Oh! what a tangled web we weave... My Spider

(Walter Scott - Marmion poem)

I have a problem that I can’t seem to solve… (Again!)

As an experiment, I have connected a Netgear Universal WiFi Internet Adapter (WNCE2001) using a J11D ethernet module on my Fez.Spider.
The WNCE2001 is a bridge which I ‘Assume’ is bidirectional (read and write). See image snap1.gif

I am using a Windows TaskTray application that reads/writes to ‘Udp ports’. I can ‘write’ successfully to the Spider but I never can ‘read’ a message
at the TaskTray application sent by the Spider?

I have tried MANY different ways but always, I can send but never receive. I have used DHCP and Static IP with the same results.
I can always send but never receive.

Currently I favor using a static IP for the WNCE2001 as then I know what the IP should be.

Spider code used to send Udp


        const int listenPort = 22000;    //Text from TaskTray App.
        const int sendPort = 22001;      //Text to the tasktray App.
        const string SpiderIP = "192.168.2.6";  //Spider - NETGEAR WNCE2001
        const string subnetMask = "255.255.255.0";
        const string gatewayAddress = "192.168.2.1";

 //A socket that sends typically connects, and a socket that listens typically binds?

        private void Sendbutton_ButtonPressed(Button sender, Button.ButtonState state)
        { 
            Sendbutton.TurnLEDOff();
            string s = "**A test message sent from SPIDER**";
            byte[] sendbuf = Encoding.UTF8.GetBytes(s);

            sendSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            //Not working
            IPAddress ipa = IPAddress.Parse(SpiderIP);
            IPEndPoint ep = new IPEndPoint(ipa, sendPort);

            //Also Not working
            //IPEndPoint ep = new IPEndPoint(IPAddress.Any, sendPort);

            //Neither makes a difference (or not using at all)
            //sendSocket.Bind(ep);
            //sendSocket.Connect(ep);

            sendSocket.SendTo(sendbuf, ep);
            sendSocket.Close();

            display_T35.SimpleGraphics.DisplayText("Sending: " + s, NBFont, Colors.Black, 10, 154);
            display_T35.SimpleGraphics.DisplayText(ep.ToString(), NBFont, Colors.Black, 10, 169);
            Sendbutton.TurnLEDOn();
        }
        //

TaskTray App 'Listen" code


        void SetupListener()
        {
            listenerThread = new Thread(new ThreadStart(ListenIncommingThread));
            listenerThread.Start();
        }
        //

        //WSAEADDRNOTAVAIL 10049 
        
        private void ListenIncommingThread()
        {
            readSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            //// Did not work
            //EndPoint anyEndPoint = new IPEndPoint(IPAddress.Any, 0);
            //readSocket.Bind(anyEndPoint);
            //ep = (EndPoint)anyEndPoint;

            //// Did not work
            EndPoint listenEP = new IPEndPoint(IPAddress.Parse(SpiderIP), listenPort);

            //// WSAEADDRNOTAVAIL 10049 - using Bind - Cannot assign requested address.
            //readSocket.Bind(listenEP); 

            readSocket.Connect(listenEP);

            ep = (EndPoint)listenEP;

            while (true)
            {
                if (readSocket.Poll(-1, SelectMode.SelectRead))
                {
                    byte[] inBuffer = new byte[readSocket.Available];
                    int length = readSocket.ReceiveFrom(inBuffer, ref ep);
                    if (length > 0)
                    {
                        TestDataReceive(inBuffer, length);
                        readSocket.Close();
                    }
                }
            }
        }
        //

        private void TestDataReceive(byte[] data, int length)
        {
            char[] text = new char[length];
            for (int i = 0; i < length; i++)
            {
                text[i] = (char)data[i];
            }
            string s = new string(text);

            if (useWriteLine) { Console.WriteLine("Data Received: " + s); }

            int x = s.CompareTo("EXIT");
            if (x == 0) //If 0 equal
            {
                if (useWriteLine) { Console.WriteLine("The Spider Application is no longer running"); }
            }
        }
        //

Any suggestions?

Have a GREAT DAY!

UDP you say.
UDP has a bug in FW 4.2.7
For me UDP works on G120, but not on EMX (which is spider)

Geee… and I wanted UPD for the speed… Off to TCP and see if that changes things.

I would still wonder why it works going one way but not the other way?

I even thought that maybe I had a bad J11D module but I have nothing to test it with. Long ago we tested Ethernet modules transformers
but I recall we used ‘pulse’ transformers connected to them. I no longer have any of them. (I use to develop test fixtures for ‘core’ memory and
different types of communication hardware)

It is some kind of Checksum error says GHI. May be only one direction has a bug.
According to Gus it is fixed in the next FW which should come within the next days/week(s).

that’s some kind of creativity this bug brings with it :slight_smile:

Hay! That is the way my brain works all the time!

For me it was different
Sending UDP worked just fine on G120.
If I send with EMX I do not even get correct ethernet frames (according to Wireshark).
The minimum Frame has 64 Bytes, my EMX sent frames of 60 Bytes. Only Wireshark showed them, my PC app never received anything.