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]

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 if path 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 AsRawFd for TTYPort[src]

impl Debug for TTYPort[src]

impl Drop for TTYPort[src]

impl FromRawFd for TTYPort[src]

impl IntoRawFd for TTYPort[src]

impl Read for TTYPort[src]

impl SerialPort for TTYPort[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.

impl Write for TTYPort[src]

Auto Trait Implementations

impl RefUnwindSafe for TTYPort

impl Send for TTYPort

impl Sync for TTYPort

impl Unpin for TTYPort

impl UnwindSafe for TTYPort

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.