W5300 delay in sending real-time DATA packets over TCP socket
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: W5300 delay in sending real-time DATA packets over TCP socket
by Eugeny ·
I did not program W5300, but it seems you skip one important step:
I think in your case you try to launch another SEND process while previous did not finish yet.
While TCP is reliable communication, sometimes it may not be up to speed, and this is what you see. It may be issue with/caused by any network device, and it is a reality. For high loaded networks you will see even worse picture with bigger delays and other transmission problems.
If dropping frames is not an option, then you must check for SEND command complete as described in datasheet, and store pending data in MCU’s buffers, implementing simple memory management so that when SEND command finally completes you send all waiting data at once (as an example, then there will be larger packets than 348 data bytes). Timing will not be accurate, but at least no data loss.
If dropping of sampling data is allowed and timing is more important, then you’d better use UDP. It does not require ACK, but your application will not know if frame was delivered and when it happened.
RE: W5300 delay in sending real-time DATA packets over TCP socket
by jmattfeld ·
Eugeny, thank you for your response.
The following code is intended to check the Sn_IR that the SEND cmd has completed and then clear the SENDOK bit:
I should add that the LAN that I am using to transmit the DATA has only two hosts (my PC and the MCU device) so I feel that it could not be characterized as a “high loaded network”.
I think that unless I find some other root cause of the issue my next step would be to buffer up frames in the MCU as you suggested when I detect the event starting to occur then send them in larger packets in hopes of recovering from the delay.
RE: RE: W5300 delay in sending real-time DATA packets over TCP socket
by Eugeny ·
I see now, apologies.
May it happen that interrupt occurs when previous service did not finish yet, and you just corrupt the workflow? Do you disable interrupts in the ISR?
RE: W5300 delay in sending real-time DATA packets over TCP socket
by jmattfeld ·
This is possible as the ISR is complex and I am sampling from 16 ADC channels (4 at a time) and I am disabling / enabling interrupts so as not to reenter the ISR handler function.
Perhaps what I need to do as a test would be to attempt to send similar sized packets at the same rate from a large static file to see if the issue is with the W5300 or as a result of the ISR handling.
RE: W5300 delay in sending real-time DATA packets over TCP socket
by Eugeny ·
You just set flag that you are currently in ISR, and check it on the entrance and log event that you have entered ISR if ISR flag is set.
Update: I propose you to change architecture of the software. You log data using ISR into MCU’s RAM, and in main loop send accumulated data when socket becomes ready. Most of the times it will send 348 bytes packet, but in case two or more interrupts occur in between, you send 348 * number of interrupts happened at once.