unstable simple web page
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: unstable simple web page
by Eugeny ·
The first idea I got reading your situation is that you try to send data before W5500 is ready to do it (has socket properly initialized). Please post your code related to the W5500 control from the beginning (starting with preparations for socket open and ending at operation completion/socket close).
Edit: but your W5500 receives connection, not opens by itself… Anyway would be very useful to see and analyze how you sense incoming connection, and what you actually do.
RE: unstable simple web page
by mzedan ·
Here is my code uploaded as zip file
The code is working as expected. However, randomly when I click on the home link or refresh the page it become incomplete as explained previously.
Actually, I store the HTML pages in PROGMEM as ATmega32 is very limited in RAM, but in my demonstration here I used very simple HTML page that stored in RAM.
code.zip (3.6 KB)
RE: RE: unstable simple web page
by Eugeny ·
I do not see anything immediately wrong. Missing the initial piece of data is very strange in your scenario as flow is very basic and data is being written into TX buffer at once.
Can you share data from the Wireshark in Wireshark data file format (so that we can dig into the packet contents)? W5500 may fragment the data, and you may not see the first data packet (or it may be lost). Can this packet be filtered by the intermediate device? Would be very useful if you can connect PC with W5500 directly without any router and capture packets on the PC using Wireshark - to be sure you see every packet on the (local direct connect) network. However… if packet would be lost or filtered then PC would keep requesting it from W5500 because it must see sequence number and thus know about missed data! And I suspect W5500 would not clear its TX buffer until it gets ACK from PC.
As a next step of troubleshooting, try reading contents of the TX buffer starting with Sn_TX_RD:
Note that I used function
SPI_RecvBytewhich should be designed accordingly to read one byte from SPI. You can compare values you read to the values ofbufin the loop instead of writing data intotempbuf. Put this code just beforesetSn_CR(sn,Sn_CR_SEND);to see that chip is having all data properly stored into the TX buffer.You did not share contents of
SPI_SndByte(), hope it is designed properly.RE: unstable simple web page
by mzedan ·
Hello Eugeny,
I am attaching the capture file. It was the first time for me to use Wireshark.
The capture include traffic when page loaded completely, and then when refreshed and incomplete. The capture file include both cases.
I do connect W5500 directly to my PC using crossover or straight cables.
Also, I tried to include the piece of code to compare tempbuf and buf but strangely my ATmega hanged and I do not why. I am attaching the SPI driver, and below is the code inserted. It hanged specifically in the part of SPI Send/Receive below"
/* -------------------------- Test Code -------------------------------------*/
ptr = 0;
addrsel = 0;
Also, please note that this time I have reduced the HTML page and stored it in PROGMEM as my MCU is limited in RAM. Note that I used SPI_SndByte(pgm_read_byte(&buf[i])); in the NetSend() function
I am attaching my files again.
Regards
code.zip (9.4 KB)
RE: RE: unstable simple web page
by Eugeny ·
Can you put debug code to identify where it hangs? I suspect it may be in
strcmpas you seem not to terminatetempbufwith null char.PI_SndByte(pgm_read_byte(&buf[i]));what does it do and why did you make these changes? Our goal is to write data the same way as you originally did, and then check if TX buffer has this data written.Will look into the logs and code later.
Edit: looked into the Wireshark logs. It is a mess. You should know that regular browser requests several resources in parallel (e.g. favicon which you can see in he log). But you are using only ONE socket. Thus for every request browser makes in parallel it gets RST, and tries later. Try another browser and you may see the difference. There was a setting in the advanced settings of Firefox to limit number of parallel (concurrent) connections browser is allowed to make… let me see… maybe “network.http.max-connections-per-server”.
Right now try simply getting the web page from the W5500 without using browser, and check if it will always return proper data:
>telnet 192.168.1.124 80GET / HTTP1.1
<cr><cr>and you must get the contents onto the screen. You can output data into the file.
RE: unstable simple web page
by mzedan ·
Hello Eugeny,
Thank you for bearing with me. Your last reply gave me a hint and I have changed my code to use 5 sockets and it seems things are getting improved. The core problem still not fixed but things are better.
Previously I had to refresh several times to get the complete page. Now the page loads from the first time or I have to refresh only two or three times
I noticed something strange that when the page is incomplete, it always start from a specific byte. I found it always skip first 261 bytes. Please have a look on the screen shot from my browser when the page is incomplete. It is always like this when the page is incomplete. I am also attaching two capture files , one when the page is complete and the other hen the page is incomplete.
In the incomplete capture file, in packet # 20 shows the page was not completely send to the browser. It seems that W5500 skip those first 261 bytes sometimes.
I tried to telnet W5500 192.168.1.124 80 but connection not accepted.
Please have a look on the attached files.
code.zip (18.7 KB)
RE: unstable simple web page
by Eugeny ·
It seems chip is really sending part of data, and packet exchange is valid. I do not have any immediate idea, therefore we must continue to investigate. The fact that you use more sockets now and it improves, shows hat there’s some flaw in the program’s logic.
disconnect()from the library as shown here, right? Strange but I can not find code for this routine in the WIZnet github. Can you please display what value disconnect returns (it returns a byte) every time you access the W5500? Would you please put explicit socket close()after everydisconnect();setSn_CR(sn,Sn_CR_SEND);re-readptrtemp = getSn_TX_RD(sn);and compare pointers to ensure that it is still the same valueif(ptr != ptrtemp) <display error>. This is very low probability RD pointer has changed, but as we do not know what is going on it would be beneficial to check it just after data comparison and just before performing SEND.RE: unstable simple web page
by mzedan ·
Yes I am using disconnect from the library shown. The return of disconnect() is always 1 (SOCK_OK).
And I did put explicit socket close
()after everydisconnect()but no effect.I changed the code to compare as advised in 2,3 above just before SEND, but it always not equal either the page loaded completely or not. Here is the code:
RE: RE: unstable simple web page
by Eugeny ·
Of course they will be not equal because you add
lentoptr.The point of the check is to see if original TX pointer matches final RD pointer when you perform SEND, in other words W5500 has correct byte count to send, and pointers are properly positioned in the TX buffer. You must compare original TX pointer you read at the beginning to the RX pointer before sending. You can also read final WR pointer after you written it and see if difference between final WR pointer and original WR pointer is exactly the
len.RE: unstable simple web page
by mzedan ·
I changed the code as shown below
I can see that they are always equal.
Yes, difference exactly = len
This makes me crazy. I believe the problem specifically when the W5500 sending it physically to cable, sometimes miss some bytes.
Could it be something related to the speed & negotiation (10/100 & Auto)?
RE: RE: unstable simple web page
by Eugeny ·
The chip logic is very simple - after socket got open all pointers are initialized, you put data into the buffer, shift pointer, and issue SEND command. Chimp must use all the data between RD and WR pointers, that’s why our exercise to see if RD is the same as was before. Therefore you have proper data in the buffer properly, with properly set pointers, but chip omits first bytes for some reason. I do not believe it happens because pf PHY, there’s some issue in logic.
According to your information problem is not in SPI (protocol and communication). Problem is also not in accessing wrong registers/memory locations.
Write another program which will open socket by itself and send some data to see if problem appears also when socket is being open on the W5500 side. Note that for this program to work someone W5500 sends data to must be listening to respective port at its end.
@lawrence can you look into this case please. There may be something obvious and simple, but we do not see it.
RE: RE: unstable simple web page
by lawrence WIZnet ·
Hi @mzedan ,
Could you share the hardware information?
I would like to know you use WIZnet product or your own designed module.
Thank you,
RE: unstable simple web page
by lawrence WIZnet ·
Hi @mzedan ,
Could you share the hardware information?
I would like to know you use WIZnet product or your own designed module.
Thank you,
RE: unstable simple web page
by mzedan ·
@lawrence @Eugeny
Greetings,
Thank you for bearing with me. My discussion with Eugeny guided me to understand more.
I have written a new program from scratch and used the io library as it is, and I think it is working as supposed to now.
I do not know where is my fault, but it seems I did something wrong when writing my own function. Before, I did not register SPI functions, but this time I registered my SPI functions. Maybe that was the problem.
I tried very simple HTML page and no problem with it. I will continue with my project to see if it is OK.
Thank you again
RE: RE: unstable simple web page
by lawrence WIZnet ·
@mzedan
Glad to hear the news!!
And next time, I will support new issue faster !
Please leave any issues when you need others