Can I issue an OPEN command to an already open 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: Can I issue an OPEN command to an already open Socket?
by Eugeny ·
You must follow the workflow documented in the datasheet, see W5100 datasheet section 5.2. This is the only guaranteed way for operation. Therefore you must close socket before opening it. And you always must respect TX_RD pointer (and other pointers) and not assume it will always be 0.
RE: RE: Can I issue an OPEN command to an already open Socket?
by PhilipJ ·
Hi, thanks for the information. I am using a W5500 and there doesn’t seem to be a similar section in the W5500 datasheet so is it ok to assume these instructions are compatible for this chip?
I wasn’t planning to assume that the TX_RD was ‘0’ I just hoped that I could reset it back to zero after each message send, but I will follow your advice.
Regards
PhilipJ
RE: Can I issue an OPEN command to an already open Socket?
by Eugeny ·
Yes, algorithms described in W5100 datasheet apply. You can’t, and should not reset pointers, they must be operated (read and some of them updated when needed) as described in that section.
RE: Can I issue an OPEN command to an already open Socket?
by PhilipJ ·
OK thanks
PhilipJ
RE: Can I issue an OPEN command to an already open Socket?
by PhilipJ ·
Hi again, I hope I am not being a pain but I have another oddity happening.
I set up my code as you suggested:
read TX_FSR (this returns 0x0800 as I have 8 sockets)
read TX_RD
write data into the TX_BUF starting at this address
add my message size (in this test case 250 bytes) to TX_RD and write this into TX_WR
issue a SEND command
This is working fine for the first 8 times but when I try to send it a ninth time the problem occurs:
My code is working the buffer pointers as modul0 0x0800 and the data is written into the buffer so that it fills it up to address 0x07FF and then wraps around to write the rest from address 0x0000
The TX_WR pointer becomes 0x00CA.
What actually happens is the W5500 sends 43 messages, each of 1472 bytes and then a 44th message of 442 bytes - total of 63,738 bytes.
It’s almost as if the TX_RD and TX_WR pointers go through the full count of 0 to 65535 and don’t wrap around at 0x07ff.
So my question is:
What is the correct process when the TX_RD pointer is close to the end of the buffer?
regards
PhilipJ
EDIT: I have read the W5500 datasheet about registers TX_RD and TX_WR and it does seem to say (on page 54) that these registers will go all the way to 0xFFFF and then wrap around to 0. So how does this work when the buffer is only 2048 bytes long? How do I know where to put my message data if both TX_RD and TX_WR and pointing at say 0x08ca ?
RE: RE: Can I issue an OPEN command to an already open Socket?
by Eugeny ·
Datasheet says:
You should not touch TX_RD. You must operate TX_WR. TX_WR is a data write pointer for your application. TX_RD is read pointer for W5500 internals. The amount you report also rings the bell - 250 * 8=2000 < 2kB, 250 * 9=2250 > 2 kB, the issue happens at the TX buffer boundary crossing.
That’s why you apply mask to this pointer. Its value is 0…FFFF, but each time it points somewhere within the buffer defined by the configuration (2kB, or 0x800, size in your case).
RE: Can I issue an OPEN command to an already open Socket?
by PhilipJ ·
Hi,
but there is no MASK register in the W5500 chip.
HOWEVER, I have worked it out, it seems the W5500 chip has a “virtual” 64k TX buffer (w5599_ds_v109e.pdf page 28) which you can write into BUT only up to the maximum of FREE BYTES (2048 or less_. The block you write is then “mapped” by the chip into the actual 2k bytes of memory allocated for TX messages!!
So all my messing about with modulo 2048 maths was messing up the pointers causing the chip to send 0x10000 - 0x07d0 + 250 bytes in 44 seperate messages.
regards
PhilipJ