Struct ferrous_serialport::TTYPort [−][src]
pub struct TTYPort { /* fields omitted */ }
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()
.
Implementations
impl TTYPort
[src]
impl TTYPort
[src]pub fn open(builder: &SerialPortBuilder) -> 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::TTYPort; let (master, slave) = TTYPort::pair().unwrap();
pub fn send_break(&self, duration: BreakDuration) -> Result<()>
[src]
Sends 0-valued bits over the port for a set duration
pub fn try_clone_native(&self) -> Result<TTYPort>
[src]
Attempts to clone the SerialPort
. This allow you to write and read simultaneously from the
same serial connection. Please note that if you want a real asynchronous serial port you
should look at mio-serial or
tokio-serial.
Also, you must be very careful when changing the settings of a cloned SerialPort
: since
the settings are cached on a per object basis, trying to modify them from two different
objects can cause some nasty behavior.
This is the same as SerialPort::try_clone()
but returns the concrete type instead.
Errors
This function returns an error if the serial port couldn’t be cloned.
Trait Implementations
impl Read for TTYPort
[src]
impl Read for TTYPort
[src]fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
pub fn read_vectored(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
1.36.0[src]
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
pub fn is_read_vectored(&self) -> bool
[src]
pub unsafe fn initializer(&self) -> Initializer
[src]
pub fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]
pub fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
pub fn bytes(self) -> Bytes<Self>
1.0.0[src]
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
pub fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl SerialPort for TTYPort
[src]
impl SerialPort for TTYPort
[src]fn name(&self) -> Option<String>
[src]
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_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]
fn set_break(&self) -> Result<()>
[src]
fn clear_break(&self) -> Result<()>
[src]
impl Write for TTYPort
[src]
impl Write for TTYPort
[src]fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
pub fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
pub fn is_write_vectored(&self) -> bool
[src]
pub fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
pub fn write_all_vectored(
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
[src]
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for TTYPort
impl RefUnwindSafe for TTYPort
impl UnwindSafe for TTYPort
impl UnwindSafe for TTYPort