serial.device

Module providing instruments to work with serial port on Windows and Posix OS. SerialPort class can enumerate available serial ports (works robust only on Windows), check available baud rates.

Members

Aliases

posixClose
alias posixClose = core.sys.posix.unistd.close
Undocumented in source.
posixRead
alias posixRead = core.sys.posix.unistd.read
Undocumented in source.
posixWrite
alias posixWrite = core.sys.posix.unistd.write
Undocumented in source.

Classes

DataBitsUnsupportedException
class DataBitsUnsupportedException
Undocumented in source.
DeviceClosedException
class DeviceClosedException

Thrown when trying to accept closed device.

DeviceReadException
class DeviceReadException

Thrown when reading from serial port is failed.

DeviceWriteException
class DeviceWriteException

Thrown when writing to serial port is failed.

InvalidDeviceException
class InvalidDeviceException

Thrown when tried to open invalid serial port file.

InvalidParametersException
class InvalidParametersException

Thrown when setting up new serial port parameters has failed.

ParityUnsupportedException
class ParityUnsupportedException
Undocumented in source.
SerialPort
class SerialPort

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

SpeedUnsupportedException
class SpeedUnsupportedException

Thrown when trying to setup serial port with unsupported baud rate by current OS.

StopBitsUnsupportedException
class StopBitsUnsupportedException
Undocumented in source.
TimeoutException
class TimeoutException

Thrown when read/write operations failed due timeout.

Enums

BaudRate
enum BaudRate

Represents allowed baud rate speeds for serial port.

DataBits
enum DataBits
Undocumented in source.
Parity
enum Parity
Undocumented in source.
StopBits
enum StopBits
Undocumented in source.

Functions

GetCommState
bool GetCommState(HANDLE hFile, DCB* lpDCB)
Undocumented in source but is binding to Windows. You might be able to learn more by searching the web for its name.
SetCommState
bool SetCommState(HANDLE hFile, DCB* lpDCB)
Undocumented in source but is binding to Windows. You might be able to learn more by searching the web for its name.
SetCommTimeouts
bool SetCommTimeouts(HANDLE hFile, COMMTIMEOUTS* lpCommTimeouts)
Undocumented in source but is binding to Windows. You might be able to learn more by searching the web for its name.

Manifest constants

B115200
enum B115200;
Undocumented in source.
B14400
enum B14400;
Undocumented in source.
B230400
enum B230400;
Undocumented in source.
B28800
enum B28800;
Undocumented in source.
B57600
enum B57600;
Undocumented in source.
B57600
enum B57600;
Undocumented in source.
B7200
enum B7200;
Undocumented in source.
B76800
enum B76800;
Undocumented in source.
EVENPARITY
enum EVENPARITY;
Undocumented in source.
MARKPARITY
enum MARKPARITY;
Undocumented in source.
NOPARITY
enum NOPARITY;
Undocumented in source.
ODDPARITY
enum ODDPARITY;
Undocumented in source.
ONE5STOPBITS
enum ONE5STOPBITS;
Undocumented in source.
ONESTOPBIT
enum ONESTOPBIT;
Undocumented in source.
SPACEPARITY
enum SPACEPARITY;
Undocumented in source.
TWOSTOPBITS
enum TWOSTOPBITS;
Undocumented in source.

Structs

COMMTIMEOUTS
struct COMMTIMEOUTS
Undocumented in source.
DCB
struct DCB
Undocumented in source.

Examples

auto com = new SerialPort("COM1"); // ttyS0 on GNU/Linux, for instance
string test = "Hello, World!";
com.write(test.ptr);

ubyte[13] buff;
com.read(buff);
writeln(cast(string)buff);

Note: Some points were extracted from Tango D2 library. TODO: Serial port tweaking, asynchronous i/o.

Meta