Repository navigation
u_send / u_recv - #998
u_send / u_recv#998
Conversation
U-SEND and U-RECV communication with up to 4 data blocks. Sending: u_send(number of blocks). b_recv() and as_b_recv() process both b_send and u_send data. Since the payload of `u_send` transmissions can be splitted into up to 4 parts, new helpers are required for the data buffers: - set_u_send_data(data_1, data_2, data_3, data_4) - get_u_recv_data()
pre-commit fix
pre-commit fixes
pre-commit fixes
pre-commit fix
pre-commit fix
pre-commit fix
pre-commit fix
remove test_u_send_nodata
gijzelaerr
left a comment
There was a problem hiding this comment.
Thanks, @hs2bws. This is a solid second step. A plain BSend works exactly as before, set_recv_callback still takes one argument, and the parser tests use frames from your captures, so it's close.
What I checked:
- The full suite, mypy, ruff and pre-commit pass on the branch.
_build_partner_data_pdu_u(b"\x3b\x00", b"\x00", b"\x3b", b"\x01\x00", 4, r_id=2)reproduces the captured 4-block frame fromtest_parse_partner_usend4_pdubyte for byte.- A plain
b_send()/b_recv()round trip still returns the same data, andget_u_recv_data()reports block count 0 for it.
Two things need fixing:
- The size check in
u_send()measures the wrong blocks. For blocks 2, 3 and 4 it useslen(self._send_data), the first block, instead ofself._send_data2,_send_data3and_send_data4. So a large second block passes the check: with a 1-byte first block,u_send(2)accepted a 2,000-byte second block and sent it, although the limit for a 480-byte PDU is 452 bytes. And a short block can be refused when the first one is long. A test that sends a block 2 over the limit and expectsValueErrorwould pin this. - The
CHANGES.mdentry is under 3.6.0, which was released this morning. Please move it to a newUnreleasedsection at the top. Two small things there: the list mixes a tab with spaces, and "splitted" should be "split".
Smaller points:
- In
_async_recv_loop,self._datablock_count = datablock_countshould beself._recv_datablock_count. The queue carries the right value, socheck_as_b_recv_completion()is fine, but the attribute name is a typo. - Could you add a test that builds the 1-block and 4-block frames and compares them with the captured bytes? Today only parsing is pinned to the captures.
- If a USend frame arrives in the middle of a fragmented BSend,
_b_recv_loopreturns the USend data and drops the fragments it has collected so far. Is that what the CPUs do? If you don't know, raising an error there would be safer than silently losing data.
Once 1 and 2 are fixed, this can go in.
|
I hope that everything is correct now. All points should be corrected. |
gijzelaerr
left a comment
There was a problem hiding this comment.
Thanks, @hs2bws — everything from the last round is fixed. I re-checked on the branch: the size check in u_send() is now exact (452 bytes fit a 480-byte PDU, 453 are refused, also when split across two blocks), the build tests match your captures byte for byte, and a USend arriving mid-BSend now raises instead of dropping the fragments. Tests, mypy and ruff pass.
Two optional follow-ups, fine to leave for later: a test that an oversized block raises ValueError, and adding data 2–4 to the Returns line of _parse_partner_data_pdu's docstring. I'll squash-merge this.
Support for u_send and u_recv:
u_send(number of blocks)for sendingb_recv()andas_b_recv()process both b_send and u_send dataset_u_send_data(data_1, data_2, data_3, data_4)andget_u_recv_data()