Set maximum captured packet size to 1027 #56
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Report untruncated packet size to host
Do not immediately proceed to writing header when packet larger than MAX_PACKET_SIZE is captured on the bus. Keep counting packet length so the value can be reported to the host.
When Truncated flag is set the size reported in header is untruncated packet size and only MAX_PACKET_SIZE bytes are included. In order to not increase header size, and thus limit the maximum capture throughput, the MAX_PACKET_SIZE value must match between gateware and host.
Because change modifies gateware to host software protocol and hence is backwards incompatible. I believe the gateware should be considered integral part of software package and therefore I do not consider this protocol incompatibility to be a problem, especially that the gateware is only loaded to volatile memory.
Reporting actual length as seen on the bus allows USBInterpreter to display for example "Truncated 2 bytes" instead of "Unexpected ERR CRC". Similarly, when exporting to pcap format, Wireshark can display "[Packet size limited during capture]" instead of reporting CRC errors.
USB 2.0 maximum possible packet size is 1027. The packet is 1027 bytes when wMaxPacketSize is 1024 (interrupt or isochronous high-speed) and 1024 bytes are transferred in single transaction (1 byte PID + 1024 bytes data + 2 bytes CRC).
Fixes: #29