Comments (2)
Since serialport-rs uses a RAII philosophy, if you have access to a port it is also open.
I think this results in the issue you describe, so I might suggest something like:
port: Option<Box<dyn SerialPort>>
When you initialize your structure, the port will be None
; when you acquire/open a port it will be Some(Box<dyn SerialPort>)
.
This does create some boilerplate when reading/writing to the port, since you need to be checking if the port is Some
-- but I think this is conceptually the same as needing to check that a port is 'open'.
The other option, of course, is simply to open/create the port when you create your structure.
from serialport-rs.
Thank you so much for your quick and explicit answer. I am having such a hard time getting used to rust... And it is clearly not about the syntax !
from serialport-rs.
Related Issues (20)
- Unplug serial device cause system shutdown on windows HOT 8
- Fast receive missing beginning of packet HOT 3
- Tracking issue for WebSerial support. HOT 1
- Can Add Mark and Space to Parity? HOT 1
- Configurable buffer size HOT 1
- Update dependency on nix to 0.28 HOT 3
- Potentially confusing read_exact timeout semantics HOT 1
- wrong serial number for FTDI modules ? HOT 1
- Timeout reading SerialUSB from Arduino DUE or GIGA HOT 3
- Outdated documentation for TTYPort HOT 2
- Opening a COM port on Windows fails HOT 5
- Cannot list virtual serial ports on Windows 10 HOT 3
- Data misread from serial adapter (serialport only) HOT 12
- Serial port operation has different performance in (windows10 \ MacOS) HOT 3
- Wrong serial number and missing interface number for FTDI multi-port device on Windows HOT 4
- Serial port doesn't properly open on Windows 11 HOT 5
- How to close the open port? HOT 3
- SerialPortBuilder.timeout(Duration::MAX) gives "Invalid argument" HOT 3
- Please add build instructions HOT 2
- macos and Windows disagree on interface numbering for Black Magic Probe HOT 12
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.