ataradov / usb-sniffer-lite

A simple USB sniffer based on Raspberry Pi RP2040
BSD 3-Clause "New" or "Revised" License
547 stars 49 forks source link

contents of the buffer #19

Open 1250364116 opened 2 months ago

1250364116 commented 2 months ago

hello. As I see, the pio0 for each 32-bit sampled data fills the buffer by two values: the size of the sampled data and the sampled 32-bit data itself. then you add the end time of sampling that data as the third element. thus for each 32 data sampling, the buffer is filled by 3 elements in a row. but sometimes pio0 pushes out another element as a fourth value which is 0xFFFFFFFF. so, what is this value and what does it mean? is it a flag for the end of the frame?

ataradov commented 2 months ago

The size of the data from the PIO is indicated as 0xffffffff-actual size (it counts down from 0xffffffff) and the data is limited to 31 bits. So, highest bit can be used to distinguish size (end of packet) from the data bits.

The only time PIO0 can push 0xffffffff is when the actual size is 0, and that only happens in the case of a line reset (D+=low, D-=low), which appears as a valid start of packet marker, but then does not have synchronization field.

But 0xffffffff is never pushed as an additional data, it is always pushed as a length part.

1250364116 commented 2 months ago

So for each data sample, g.buffer is filled only with 3 elements: size, time, data itself.

در تاریخ یکشنبه ۸ سپتامبر ۲۰۲۴،‏ ۱۸:۵۳ Alex Taradov < @.***> نوشت:

The size of the data from the PIO is indicated as 0xffffffff-actual size (it counts down from 0xffffffff) and the data is limited to 31 bits. So, highest bit can be used to distinguish size (end of packet) from the data bits.

The only time PIO0 can push 0xffffffff is when the actual size is 0, and that only happens in the case of a line reset (D+=low, D-=low), which appears as a valid start of packet marker, but then does not have synchronization field.

But 0xffffffff is never pushed as an additional data, it is always pushed as a length part.

— Reply to this email directly, view it on GitHub https://github.com/ataradov/usb-sniffer-lite/issues/19#issuecomment-2336725079, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2VUWY7YRITJFSGWIIOND5LZVRTYLAVCNFSM6AAAAABN3AZVACVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZWG4ZDKMBXHE . You are receiving this because you authored the thread.Message ID: @.***>

ataradov commented 2 months ago

Correct. You get data + size from the PIO itself and the time is added in the loop after the last element is read from the PIO.