Fix streaming bug affecting mostly the pm5
Bug triggered with: lf read -s 50000 hw ping ReadLF_realtime() in lfsampling.c never knew how many samples the client wanted — for the realtime path, lf_sample_payload_t.samples was never populated on the client side, and the ARM handler in appmain.c (CMD_LF_ACQ_RAW_ADC/CMD_LF_SNIFF_RAW_ADC) ignored it anyway. So the device just streamed samples indefinitely, only checking for a stop request roughly once per 64-sample USB burst, and even after noticing it, flushed one more trailing partial burst via async_usb_write_stop(). Meanwhile the client (WaitForRawDataTimeout in comms.c) stops listening in raw mode the instant it has collected exactly the number of bytes it asked for (e.g. 50000), then switches back to normal framed-packet parsing. Since the device kept sending more bytes past that point, those extra bytes sat unread in the pipe and got misinterpreted as a PacketResponseNGPreamble/OLD-frame header, corrupting every subsequent USB exchange (hw ping, etc.) — reproducible even with a plain lf read -s 50000, no trigger/COTAG needed. Moreover, we make sure the client doesn't stop listening, even briefly, during stream reception.
This commit is contained in:
6 files changed
+37
-18
No files matched your search
+2
-1
@@ -57,9 +57,10 @@ uint32_t SampleLF(bool verbose, uint32_t sample_size, bool ledcontrol, bool cota
|
||||
* Uses parameters in config. Only bits_per_sample = 8 is working now
|
||||
*
|
||||
* @param reader_field - true for reading tags, false for sniffing
|
||||
* @param sample_limit - stop once this many samples have been streamed, 0 = unlimited
|
||||
* @return sampling result
|
||||
**/
|
||||
int ReadLF_realtime(bool reader_field, bool cotag);
|
||||
int ReadLF_realtime(bool reader_field, bool cotag, uint32_t sample_limit);
|
||||
|
||||
/**
|
||||
* Initializes the FPGA for sniff-mode (field off), and acquires the samples.
|
||||
|
||||
Reference in new issue
Block a user