Hi all,
I am busy programming the wiz550io as a TCP client to communicate with a server. Unfortunately i ran into some problems connecting to the server. Every time it runs the ‘connect()’ function it returns a time out error. While debugging the code i learned that establishing a connection with the server succesfully was only possible if a 3 - 4 sec delay was inserted before any of the socket programming commands. without this delay it goes straight to the time-out.
In other topics i saw that it was due to the status of link of the PHY that the module wasn’t ready to set-up a connection yet. I tried implementing that by polling bit 0 of the PHYCFGR register, but without any luck…
I’ll post my code here:
retVal = init_spi();
if (STATUS_FAIL == retVal){
while(1);
}
init_w5500();
init_network(&pnetinfo);
// __delay_cycles(2000000); <-- This is where i inserted the delay to make the connect() function work.
while(getPHYCFGR() & PHYCFGR_LNK_ON); // PHYCFGR_LNK_ON (1<<0)
mysock = socket(socketNum, Sn_MR_TCP, 5000, 0x00);
if(mysock != socketNum)
{
while(1);
}
retVal = connect(mysock, addr, PORT_TCPC);
if(retVal < 0)
{
while(1);
}
retVal = send(mysock, GREETING_MSG, strlen(GREETING_MSG));
if(retVal < 0)
{
while(1);
}
retVal = close(mysock);
if(retVal < 0)
{
while(1);
}
while(1);
As you can see it’s just a very simple code to open a socket, connect, send a message and lastly close the connection.
What i also checked for were the packets send over the network through wireshark. The first picture posted is the code without the delay, where the connect() returns time out. The second shows a succesfull connection.
For clarification, the BelkinIn is the USB-C to ethernet adapter i use to connect to the module. This device has been given the IP address where the Wiz550io module is looking for.
The ARP message does get send out, but doesn’t get any response back, so maybe it’s something else than the module? Or maybe the network of the wiz550io hasn’t fully initialized yet, so it’s impossible for the host to send back a response?
I hope someone can help me with this problem.
Cheers,
Caspar