UDP mode - clearing receive buffer
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: UDP mode - clearing receive buffer
by rm69 ·
Just a stupid question. A confusing piece of code. Data length appears after 14 bytes (6 times read of *S5_RX_FIFOR0, and 1. Wiznet is directly memory mapped. Definitions are shown at the top of the code.
uint8 xdata *S5_IR1 = (uint8 xdata *)0x2347;
uint8 xdata *S5_SSR1 = (uint8 xdata *)0x2349;
uint8 xdata *S5_RX_RSR3 = (uint8 xdata *)0x236B;
uint8 xdata *S5_RX_FIFOR0 = (uint8 xdata *)0x2370;
uint8 xdata *S5_RX_FIFOR1 = (uint8 xdata *)0x2371;
uint8 head0;
uint8 head1;
uint8 udpsizelsb;
if(*S5_SSR1 == 0X22) // check if the socket is in udp mode
{
/// get the length of the recv packet, LSB will indicate a minimum length. assuming it won’t be zero.
udpsizelsb = *S5_RX_RSR3;
if(*S5_IR1 & 0X04 || udpsizelsb > 0x08) // if minimum 8 bytes are recvd or if interrupt is set
{
*S5_IR1 = 0X04; // clear the recv interrupt bit of socket
//totally 8 bytes
//totally 14 bytes
// now, next 2 bytes indicate datalength. Actually, it should have been the last 2 bytes of the header (7 and 8), and not 15 and 16. But some how, 15/16 matches datalength. From 17nth onwards, it is data.
for(index = 0 ; index < datalength; index++) // copy the data contents of recv memory of he socket to user memory. variables are defined elsewhere.
{
mydata[index] = *S5_RX_FIFOR0;
index++;
mydata[index] = *S5_RX_FIFOR1;
}
Now, mydata has UDP data. Actually, I am reading from 17, 18 … of the buffer, instead of 9,10… So my data has to be incorrect, but it seems to be correct. Is this some datatype conversion issue?
Please comment. Code seems to be right, but something is wrong. (In the actual code, we are using a header array as per the sample code.). Code gives correct receive size o 15/16 reads. Some stupid interpretation, but if you can comment on this, we would appreciate it.