Network questions

Hi

I have a two questions.
1°) I tried to connect to the network using the 2 examples provided on the GHI site for the SC20260.
If I use the ethernet connector that is on the board, I got the phyReady, but no Ip address nor Mac address is defined at the end. On the other hand, if I use the Eth Click, I got one. Is there something I missed here ?

2°) I tried a basic socket connection

        IPHostEntry hostEntry = Dns.GetHostEntry("httpbin.org");
        IPEndPoint ep = new IPEndPoint(hostEntry.AddressList[0], 80);
        Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        clientSocket.Connect(ep);

        byte[] buffer = Encoding.UTF8.GetBytes("GET / HTTP/1.0\r\n\r\n");
        clientSocket.SendTimeout = 100000;
        clientSocket.Send(buffer);
            
        buffer = new byte[1024];
        clientSocket.ReceiveTimeout = 100000;
        int bytes = clientSocket.Receive(buffer);
        if (bytes > 0)
        {
            Debug.WriteLine(new String(Encoding.UTF8.GetChars(buffer)));
        }
        clientSocket.Close();

I do not get any data back, except if I do a break in debug after the send.
If I increase the Send or ReceiveTimeout, it doesn’t help. What is the unit for the timeout ?

3°) Do you have any basic example of basic data exchange between TinyClr and another TinlyClr device or a pc using sockets ?

@philippeb, I think you have run into the same issues I flagged previously. On preview 3, the onboard ethernet is not getting an IP. You can go back to preview 2 and it should work for the network nuget. As for the read. The timeout is in ms. However, in my testing, the read method would not return if entered before data was present until the size of the data equaled the size of the buffer. So, I had to check the DataAvaliable prior to calling Read to make sure there was some data to be read.

  1. plug cable in, make sure yellow and green leds are on. green led will be on after connec the cable few seconds.

  2. try while loop when you read or add some delay after you sent.

@Phil_C you just remind me one thing. :))

does socket Read() work as you expected?

@philippeb: do you use Spi anywhere in your project beside ethernet?

I don’t know. I can’t get the adapter to take an IP address in preview 3.

You are probably right. I tested while I was still in preview 2 and got my IP. This is the first test since I have installed the preview 3.
With Socket, the receive() method returned data if the size of data received is less than the buffer size. But it doesn’t seems to wait, if sender doesn’t respond at that time, it returns no data (I will recheck tomorrow but it’s quite late now 23:58.

spi is only used for the Eth click

I will check for the Leds tomorrow and will let you know. It works if I add some delay before the receive()

Hi Dat

I checked the leds. Green led is on after connecting the cable.
phyReady is true but IP
image

There is an issue with static IP that we just fixed.

Dhcp should work

I tried both but no luck