[−][src]Struct serialport::posix::TTYPort
A TTY-based serial port implementation.
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()
.
Methods
impl TTYPort
[src]
pub fn open(path: &Path, settings: &SerialPortSettings) -> Result<TTYPort>
[src]
Opens a TTY device as a serial port.
path
should be the path to a TTY device, e.g., /dev/ttyS0
.
Ports are opened in exclusive mode by default. If this is undesireable
behavior, use TTYPort::set_exclusive(false)
.
Errors
NoDevice
if the device could not be opened. This could indicate that the device is already in use.InvalidInput
ifpath
is not a valid device name.Io
for any other error while opening or initializing the device.
pub fn exclusive(&self) -> bool
[src]
Returns the exclusivity of the port
If a port is exclusive, then trying to open the same device path again will fail.
pub fn set_exclusive(&mut self, exclusive: bool) -> Result<()>
[src]
Sets the exclusivity of the port
If a port is exclusive, then trying to open the same device path again will fail.
See the man pages for the tiocexcl and tiocnxcl ioctl's for more details.
Errors
Io
for any error while setting exclusivity for the port.
pub fn pair() -> Result<(Self, Self)>
[src]
Create a pair of pseudo serial terminals
Returns
Two connected TTYPort
objects: (master, slave)
Errors
Attempting any IO or parameter settings on the slave tty after the master tty is closed will return errors.
On some platforms manipulating the master port will fail and only modifying the slave port is possible.
Examples
use serialport::posix::TTYPort; let (master, slave) = TTYPort::pair().unwrap();
Trait Implementations
impl SerialPort for TTYPort
[src]
fn name(&self) -> Option<String>
[src]
fn settings(&self) -> SerialPortSettings
[src]
Returns a struct with all port settings
fn baud_rate(&self) -> Result<u32>
[src]
Returns the port's baud rate
On some platforms this will be the actual device baud rate, which may differ from the desired baud rate.
fn data_bits(&self) -> Result<DataBits>
[src]
fn flow_control(&self) -> Result<FlowControl>
[src]
fn parity(&self) -> Result<Parity>
[src]
fn stop_bits(&self) -> Result<StopBits>
[src]
fn timeout(&self) -> Duration
[src]
fn set_all(&mut self, settings: &SerialPortSettings) -> Result<()>
[src]
fn set_baud_rate(&mut self, baud_rate: u32) -> Result<()>
[src]
fn set_flow_control(&mut self, flow_control: FlowControl) -> Result<()>
[src]
fn set_parity(&mut self, parity: Parity) -> Result<()>
[src]
fn set_data_bits(&mut self, data_bits: DataBits) -> Result<()>
[src]
fn set_stop_bits(&mut self, stop_bits: StopBits) -> Result<()>
[src]
fn set_timeout(&mut self, timeout: Duration) -> Result<()>
[src]
fn write_request_to_send(&mut self, level: bool) -> Result<()>
[src]
fn write_data_terminal_ready(&mut self, level: bool) -> Result<()>
[src]
fn read_clear_to_send(&mut self) -> Result<bool>
[src]
fn read_data_set_ready(&mut self) -> Result<bool>
[src]
fn read_ring_indicator(&mut self) -> Result<bool>
[src]
fn read_carrier_detect(&mut self) -> Result<bool>
[src]
fn bytes_to_read(&self) -> Result<u32>
[src]
fn bytes_to_write(&self) -> Result<u32>
[src]
fn clear(&self, buffer_to_clear: ClearBuffer) -> Result<()>
[src]
fn try_clone(&self) -> Result<Box<dyn SerialPort>>
[src]
impl Drop for TTYPort
[src]
impl Debug for TTYPort
[src]
impl Write for TTYPort
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
Like write
, except that it writes from a slice of buffers. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
Attempts to write an entire buffer into this writer. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Creates a "by reference" adaptor for this instance of Write
. Read more
impl Read for TTYPort
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut]) -> Result<usize, Error>
1.36.0[src]
Like read
, except that it reads into a slice of buffers. Read more
unsafe fn initializer(&self) -> Initializer
[src]
read_initializer
)Determines if this Read
er can work with buffers of uninitialized memory. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
Read all bytes until EOF in this source, appending them to buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
Read the exact number of bytes required to fill buf
. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Creates a "by reference" adaptor for this instance of Read
. Read more
fn bytes(self) -> Bytes<Self>
1.0.0[src]
Transforms this Read
instance to an [Iterator
] over its bytes. Read more
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
Creates an adaptor which will chain this stream with another. Read more
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
Creates an adaptor which will read at most limit
bytes from it. Read more
impl AsRawFd for TTYPort
[src]
impl FromRawFd for TTYPort
[src]
unsafe fn from_raw_fd(fd: RawFd) -> Self
[src]
impl IntoRawFd for TTYPort
[src]
fn into_raw_fd(self) -> RawFd
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,