Comments (2)
Reproduced this on my system (not including the baudrate failures; those are likely unrelated):
$ lsusb
0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
$ uname -ar
5.13.0-27-generic #29~20.04.1-Ubuntu
from serialport-rs.
The issue can be trivially fixed by setting the port timeout on my system:
diff --git a/examples/hardware_check.rs b/examples/hardware_check.rs
index 881b680..2107e50 100644
--- a/examples/hardware_check.rs
+++ b/examples/hardware_check.rs
@@ -247,11 +247,13 @@ fn test_single_port(port: &mut dyn serialport::SerialPort, loopback: bool) {
.expect("Unable to write bytes.");
println!("success");
- print!("Testing data reception...");
if loopback {
+ print!("Testing data reception...");
+ port.set_timeout(Duration::from_millis(1000)).ok();
+
let mut buf = [0u8; 12];
- if port.read_exact(&mut buf).is_err() {
- println!("FAILED");
+ if let Err(e) = port.read_exact(&mut buf) {
+ println!("FAILED ({})", e);
} else {
assert_eq!(
str::from_utf8(&buf).unwrap(),
The default timeout is zero:
serialport-rs/examples/hardware_check.rs
Line 430 in a84a245
I'm not sure what the expected behavior of 'read_exact' with a zero-duration timeout is, however.
Edit:
The timeout duration is eventually consumed by either nix::poll::ppoll or nix::poll::poll on posix systems:
serialport-rs/src/posix/poll.rs
Line 32 in a84a245
Both of these functions support a format for specifying 'no timeout', however, serialport-rs can't currently express this as its timeout is not optional. I think that supporting Option<Duration>
would be a nice feature for serialport-rs, but constitutes a fairly significant change.
For the scope of this issue, adding a non-zero timeout to the example seems reasonable.
from serialport-rs.
Related Issues (20)
- UsbPorts are detected as PciPorts on Raspberry Pi 4b HOT 9
- Dependency on unmaintained crates HOT 12
- Publish 4.2.2 version on crates.io HOT 2
- Type of a serialport HOT 2
- Last port.write does not send all bytes on FTDI dongle HOT 7
- Read always timeout in arm-unknown-linux-musleabihf HOT 5
- Serial write stalls application on some Windows machines HOT 7
- Windows USB001 possible? HOT 2
- Wrong informations with Com port HOT 2
- FlowControl::Hardware not set on Siliconlabs Ember dongle on Linux HOT 9
- Linux: `serialport::available_ports()` returns generic USB strings instead of actual descriptor values HOT 3
- Add supported architecture HOT 2
- windows: UsbPortInfo: Provide the same info about Manufacturer and Product name as POSIX HOT 2
- Auto reconnect HOT 1
- use read_to_end always return TimedOut err HOT 2
- Stuck when writing data to the serial port if paired port is not open [Windows 11] HOT 2
- USB ports detected as unknown in docker HOT 1
- Print to COM port via USB to SERIAL converter cable on Windows HOT 1
- Set a Custom Baudrate HOT 1
- Unplug serial device cause system shutdown on windows HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serialport-rs.