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.
Read cha data in max packet size chunks
Commit 56c5d37 ("Refactor cha_loop") changed libusb bulk transfer size from endpoint max packet size to 4096. This change inadvertently leads to RX stream desynchronization when there is large traffic on captured link. The data stream gets desynchronized because FTDI FT2232H prepends Modem Status and Line Status on every DATA packet it sends to capture host and the 4096 bytes buffer, when OpenVizsla is connected to High-Speed capture host, can hold up to 8 DATA packets and therefore the completed transfer can contain up to 16 status bytes, but transfer callback only skips the first two status bytes.
Fix the issue by skipping the Modem Status and Line Status on every max packet size chunk within the received buffer.
Do not lose synchronization on truncated packets
In current bitstream introduced in commit d0192dc ("Update to latest FPGA bitstream") only 1027 bytes are captured when HF0_TRUNC flag is set. HF0_TRUNC can happen either when there is babble packet on the bus or when the gateware incoming ULPI buffer gets full. When HF0_TRUNC is set, the packet size stored in header is guaranteed to be larger than 1027 but only 1027 bytes are actually captured. The next packet data are then incorrectly treated as remainder of the packet and therefore the stream gets out of sync.
Fix the issue by respecting gateware maximum captured packet size.