mio-serial icon indicating copy to clipboard operation
mio-serial copied to clipboard

Invalid stop bits setting encountered

Open chenxuuu opened this issue 1 year ago • 4 comments

let mut rx = serialport::new(&args.port, args.baud_rate).open_native_async()?;

error on this line

Error: Custom { kind: Other, error: "Invalid stop bits setting encountered" }

some software serialport doesen't support this (like esp32c3's usb software serialport)

I change that line code to this, then it's ok

let stop_bits = port.stop_bits().unwrap_or(StopBits::One);

chenxuuu avatar Aug 29 '23 04:08 chenxuuu

I am getting the same sort of error, but for the DataBits rather than the stop bit. It only happens on my Windows PC though and the current solution works great on my linux machine. I posted something similar to this issue over on tokio-serial too (berkowski/tokio-serial#71). With your suggestion (just putting it on the data_bits), I managed to get this to work too.

I feel like a quick and dirty solution for this would be to keep the builder within the SerialStream struct and do an .unwrap_or(...) for each of the variables afterwards. Thoughts?

DerAndereJohannes avatar Mar 11 '24 20:03 DerAndereJohannes

I no longer use this library. I still use the blocking library serialport.😂

many software serialports(emulate by mcu/soc) are very strange on windows.

chenxuuu avatar Mar 12 '24 02:03 chenxuuu

Ah I see! May I ask how you are using the serial port? For me I have a signal of around 1Hz and I need my program to react to it with minimal latency (hence why I am interested in async to get around wasting a core). The example here with your changes and a buffer of 1 seems to be doing the job well enough, but I do question the reliability based on your comment.

Since we are on windows, would you recommend me to use some C# tooling instead? Or does that not matter?

Thank you for your time.

DerAndereJohannes avatar Mar 12 '24 09:03 DerAndereJohannes

Might be related to serialport/serialport-rs#195, as 1.5 stop bits appears to be currently not supported, maybe it somehow ends up with 1.5 stop bits?

Skgland avatar Jun 18 '24 10:06 Skgland