SerialPort

Main class encapsulating platform dependent files handles and algorithms to work with serial port.

You can open serial port only once, after calling close any nonstatic method will throw DeviceClosedException.

Note: Serial port enumerating is robust only on Windows, due other platform doesn't strictly bound serial port names.

Constructors

this
this(string port)

Creates new serial port instance.

this
this(string port, Duration readTimeout, Duration writeTimeout)

Creates new serial port instance.

this
this(string port, Duration readTimeoutMult, Duration readTimeoutConst, Duration writeTimeoutMult, Duration writeTimeoutConst)

Creates new serial port instance.

Destructor

~this
~this()
Undocumented in source.

Members

Functions

close
void close()

Closing underlying serial port. You shouldn't use port after it closing.

closed
bool closed()

Returns true if serial port was closed.

convertPosixSpeed
speed_t convertPosixSpeed(BaudRate baud)
Undocumented in source. Be warned that the author may not have intended to support it.
dataBits
SerialPort dataBits(DataBits data)

Sets the standard length of data bits per byte

dataBits
DataBits dataBits()
Undocumented in source. Be warned that the author may not have intended to support it.
getBaudRates
BaudRate[] getBaudRates()

Iterates over all bauds rate and tries to setup port with it.

makeRaw
void makeRaw(termios options)
Undocumented in source. Be warned that the author may not have intended to support it.
parity
SerialPort parity(Parity parity)

Set the parity-checking protocol.

parity
Parity parity()

Returns current parity .

read
size_t read(void[] arr)

Fills up provided array with bytes from com port.

setup
void setup(string file)
Undocumented in source. Be warned that the author may not have intended to support it.
speed
SerialPort speed(BaudRate speed)

Set the baud rate for this serial port. Speed values are usually restricted to be 1200 * i ^ 2.

speed
BaudRate speed()

Returns current port speed. Can return BR_UNKNONW baud rate if speed was changed not by speed property or wreid errors are occured.

stopBits
SerialPort stopBits(StopBits stop)

Set the number of stop bits

stopBits
StopBits stopBits()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()

Converts serial port to it port name.

write
void write(const(void[]) arr)

Writes down array of bytes to serial port.

Static functions

getBaudSpeed
BaudRate getBaudSpeed(uint value)
Undocumented in source. Be warned that the author may not have intended to support it.
ports
string[] ports()

Tries to enumerate all serial ports. While this usually works on Windows, it's more problematic on other OS. Posix provides no way to list serial ports, and the only option is searching through "/dev".

Meta