problem with HydraEtherX samples
gonzobrains
Posts: 27
Okay, so I broke down and bought a HydraEtherx...
I am trying the TCP Server test for the first time. If I start the server on the HYDRA before starting the client on the PC everything is all good. But if I start the client first and then start the server, the client waits awhile, then returns and a "received -1 bytes" data is ZZ ZZ ZZ ... error.
If I start the client again it works great.
Is this just an error in the client code because it's not robust? Does it need to retry more? I'm going to look into it more and see if I can improve it. I just wanted to know if anyone else saw this.
Jeff
I am trying the TCP Server test for the first time. If I start the server on the HYDRA before starting the client on the PC everything is all good. But if I start the client first and then start the server, the client waits awhile, then returns and a "received -1 bytes" data is ZZ ZZ ZZ ... error.
If I start the client again it works great.
Is this just an error in the client code because it's not robust? Does it need to retry more? I'm going to look into it more and see if I can improve it. I just wanted to know if anyone else saw this.
Jeff
Comments
By default, when establishing a connection, the W5100 retries 8 times every 200ms. So, if there is no server up and running in 1.6 seconds then it will timeout (you can verify the timeout by looking at a bit in the interrupt register). I imagine this is what is going on for you. The client is simply timing out before you get the server started.
Your going to need to make a few extra API calls if you want to do this. There are two registers you care about, Retry Time and Retry Count. Check out the W5100 data sheet. It is located in the CD that came with the EtherX card. That will tell you what address locations Retry Time, Retry Count, and the interrupt registers are located. Once you know that you can use the "write" API call from the EtherX driver so set the values you want.
Hope this helps.
The problem is still the same although I don't know of the top of my head how you would tell the client on the OS to retry more.
Bottom line, always start the server first.
Thanks,
Jeff
To make the driver more robust you could for example monitor the timeout interrupt bit and if you detect a timeout then close the socket and re-open it.