Open bailout00 opened 4 months ago
Hey! Thank you for opening an issue.
How much data are you trying to write and how long does it block? If you send enough data to fill the kernel buffers, then it should block. So we need to figure out if this is what is happening.
Also note that there was a bugfix recently that may be related to this: https://github.com/de-vri-es/serial2-tokio-rs/pull/7
So if you're not on v0.1.11
, please update to make sure that is not the issue you are seeing.
So I did just bump to 0.1.12, now it no longer blocks but I'm seeing "Error writing command: Elapsed(())". This happens immediately and for every variation of write. Also tried multiple adapters. It does not happen when using a socat virtual port (pipe)
Removing the tokio layer, I get Error writing command: Kind(TimedOut) on the serial2 lib alone, mabye I should move this over there.
Would it be possible to share your code and the details of your serial converter and the device you're trying to communicate with?
serial2-tokio
doesn't enforce any tokio level timeouts at all, but Elapsed
sounds like a tokio timeout.
You're correct, it is a tokio timeout because otherwise it will just block the thread forever. Still unsure whats causing this but if its any help, with the changes you made in .13, now it won't open a port at all:
let mut port = SerialPort::open("/dev/tty.usbserial-16485", 115200).expect("Failed to open port");
Results in:
thread 'tokio-runtime-worker' panicked at src/serial.rs:27:61:
Failed to open port: Custom { kind: Other, error: "failed to apply some or all settings" }
I've tried several USB adapters, settings, and running under sudo. Even on a very minimal app with literally only that line, I'm getting the same error. Maybe something with the USB/serial driver? I've tried every variation I have laying around with no luck.
I've also tried virtual ports just for the sake of troubleshooting, but they aren't recognized as a valid TTY:
Failed to open port: Os { code: 25, kind: Uncategorized, message: "Inappropriate ioctl for device" }
Just for completeness:
use serial2_tokio::SerialPort;
fn main() {
let mut port = SerialPort::open("/dev/tty.usbserial-14430", 115200).expect("Failed to open port");
}
thread 'main' panicked at src/main.rs:4:73:
Failed to open port: Custom { kind: Other, error: "failed to apply some or all settings" }
from lock file
[[package]]
name = "serial2-tokio"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e21594c39572e9a1ef73844dbb3e0499c8486cd7e7742b18d03e3c06d9208492"
dependencies = [
"libc",
"serial2",
"tokio",
"winapi",
]
I'm on an M3 running Sonoma 14.7.1, but same thing before I upgraded last week from Ventura.
Ah, I think that problem was introduced with https://github.com/de-vri-es/serial2-rs/pull/39. Sadly it is difficult for me to properly test on macOS, so this slipped past. There should be a fix open in https://github.com/de-vri-es/serial2-rs/pull/45, but I would really like someone to verify if it works before I release it :]
/edit: ah, I see you already found that thread. Still good to know for other people reading this issue though :)
I just released v0.1.14
with the same fixed in serial2
. It should allow you to at-least open a serial port without errors again.
Curious if anyone is running into this? Writing shouldn't block but it is. When writing to a pipe on MacOS or a serial port on a linux device, no issue. But during development I'm using a usbserial adapter and its blocking on port.write() and I don't understand why.