Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct and update comment on TTYPort #183

Merged
merged 3 commits into from
May 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Correct and update comment on TTYPort
Teufelchen1 committed May 6, 2024
commit bdea1131452a8005a129ed99185f87815da83ab1
13 changes: 8 additions & 5 deletions src/posix/tty.rs
Original file line number Diff line number Diff line change
@@ -33,10 +33,13 @@

/// A serial port implementation for POSIX TTY ports
///
/// The port will be closed when the value is dropped. However, this struct
/// should not be instantiated directly by using `TTYPort::open()`, instead use
/// the cross-platform `serialport::open()` or
/// `serialport::open_with_settings()`.
/// The port will be closed when the value is dropped. This struct
/// should not be instantiated directly by using `TTYPort::open()`.
/// Instead, use the cross-platform `serialport::new()`. Example:
///
/// ```
/// let mut port = serialport::new("/dev/ttyS0", 115200).open().expect("Unable to open");
/// ```

Check warning on line 42 in src/posix/tty.rs

GitHub Actions / x86_64-unknown-linux-gnu-nightly / build

unused variable: `port`

Check warning on line 42 in src/posix/tty.rs

GitHub Actions / x86_64-unknown-linux-gnu-nightly / build

variable does not need to be mutable

Check warning on line 42 in src/posix/tty.rs

GitHub Actions / x86_64-unknown-linux-gnu / build

unused variable: `port`

Check warning on line 42 in src/posix/tty.rs

GitHub Actions / x86_64-unknown-linux-gnu / build

variable does not need to be mutable
///
/// Note: on macOS, when connecting to a pseudo-terminal (`pty` opened via
/// `posix_openpt`), the `baud_rate` should be set to 0; this will be used to
@@ -53,7 +56,7 @@
///
/// // ... elsewhere
///
/// let mut port = TTYPort::open(&serialport::new(slave.name().unwrap(), 0)).expect("unable to open");
/// let mut port = TTYPort::open(&serialport::new(slave.name().unwrap(), 0)).expect("Unable to open");
///
/// # let _ = &mut port;
/// ```

Unchanged files with check annotations Beta

/// Set the path to the serial port
#[must_use]
pub fn path<'a>(mut self, path: impl Into<std::borrow::Cow<'a, str>>) -> Self {
self.path = path.into().as_ref().to_owned();

Check warning on line 336 in src/lib.rs

GitHub Actions / lint

assigning the result of `ToOwned::to_owned()` may be inefficient
self
}
// └──────────────────────────────────┘
// 2. Write Thread: Write -> Unpark Read -> Park ──────┐
// └──────────────────────────────────┘
std::thread::scope(|scope| {

Check warning on line 216 in examples/loopback.rs

GitHub Actions / lint

current MSRV (Minimum Supported Rust Version) is `1.59.0` but this item is stable since `1.63.0`
// Get handle for writing thread
let wr_thread = std::thread::current();
// Spawn a thread that reads data for n iterations
let handle = scope.spawn(move || {

Check warning on line 221 in examples/loopback.rs

GitHub Actions / lint

current MSRV (Minimum Supported Rust Version) is `1.59.0` but this item is stable since `1.63.0`
for _ in 0..read_stats.iterations {
// Wait for the write to complete
std::thread::park();
write_stats.stop();
// Notify that the write completed
handle.thread().unpark();

Check warning on line 256 in examples/loopback.rs

GitHub Actions / lint

current MSRV (Minimum Supported Rust Version) is `1.59.0` but this item is stable since `1.63.0`
// Wait for read to complete
std::thread::park();