You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am building an embedded device which needs to log a lot of data quite fast to a PC. Right now I have hardcoded the device to send the same 52bytes of data every 2ms, this works fine as seen on logic analyzer.
Now on the PC end, I am using this library to try and receive that data. Since the data is COBS i thought I'd use BufReader::split(SENTINEL_BYTE). However for some reason every about 9-10th received packet is missing its first x bytes, where x varies.
fnmain(){use std::io::{BufReader,BufRead};// This is what the device prints(including the 0 byte) which BufReader::split removes as expectedconstEXPECTED_DATA:[u8;52 - 1] = [1,10,5,29,1,25,2,248,85,51,9,180,16,176,9,182,2,51,3,6,180,36,248,172,1,128,128,192,247,13,180,36,224,93,52,10,152,17,148,10,192,2,52,40,134,3,194,222,152,241,167,// 0 <- End byte];let baud = 460800;let port = serialport::new("/dev/ttyUSB0", baud).open_native().unwrap();letmut reader = BufReader::with_capacity(u16::MAXas_, port);letmut successes_in_a_row:u64 = 0;println!("Prints successed received bytes in a row on failure:");for data in reader.split(0){letOk(data) = data else{continue};if data == EXPECTED_DATA{
successes_in_a_row += 1;}else{println!("{successes_in_a_row}, {}B", data.len());
successes_in_a_row = 0;}}}
Any ideas as to what could be the cause? Some sort of buffer overrun? I have yet to see any wrong bytes in the stream, it is just that data sometimes is missing its first set of bytes
The text was updated successfully, but these errors were encountered:
Hi
I am building an embedded device which needs to log a lot of data quite fast to a PC. Right now I have hardcoded the device to send the same 52bytes of data every 2ms, this works fine as seen on logic analyzer.
Now on the PC end, I am using this library to try and receive that data. Since the data is COBS i thought I'd use
BufReader::split(SENTINEL_BYTE)
. However for some reason every about 9-10th received packet is missing its first x bytes, where x varies.output from cargo r --release
Any ideas as to what could be the cause? Some sort of buffer overrun? I have yet to see any wrong bytes in the stream, it is just that data sometimes is missing its first set of bytes
The text was updated successfully, but these errors were encountered: