SerialPort

Enables applications to use a serial port (aka COM-port, ttyS). Usage is similar to that of File:

auto serCond = new SerialPort("ttyS0");
serCond.speed = 38400;
serCond.write("Hello world!");
serCond.close();

Constructors

this
this(const(char)[] port)

Create a new SerialPort instance. The port will be opened and set to raw mode with 9600-8N1.

Members

Functions

speed
SerialPort speed(uint speed)

Sets the baud rate of this port. Usually, the baud rate can only be set to fixed values (common values are 1200 * 2^n).

toString
string toString()

Returns a string describing this serial port. For example: "ttyS0", "COM1", "cuad0".

Static functions

ports
const(char)[][] 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".

Inherited Members

From Device

error
alias error = Conduit.error

expose superclass definition also

error
void error()

Throw an IOException noting the last error.

toString
immutable(char)[] toString()

Return the name of this device.

bufferSize
size_t bufferSize()

Return a preferred size for buffering conduit I/O.

IO
struct IO

Windows-specific code.

io
IO io;

Windows-specific code.

reopen
void reopen(Handle handle)

Allow adjustment of standard IO handles.

fileHandle
Handle fileHandle [@property getter]

Return the underlying OS handle of this Conduit.

dispose
void dispose()
detach
void detach()

Release the underlying file. Note that an exception is not thrown on error, as doing so can induce some spaggetti into error handling. Instead, we need to change this to return a bool instead, so the caller can decide what to do.

read
size_t read(void[] dst)

Read a chunk of bytes from the file into the provided array. Returns the number of bytes read, or Eof where there is no further data.

write
size_t write(const(void)[] src)

Write a chunk of bytes to the file from the provided array. Returns the number of bytes written, or Eof if the output is no longer available.

wait
size_t wait(scheduler.Type type, uint bytes, uint timeout)
handle
int handle;

Unix-specific code.

reopen
void reopen(Handle handle)

Allow adjustment of standard IO handles.

fileHandle
Handle fileHandle [@property getter]

Return the underlying OS handle of this Conduit.

detach
void detach()

Release the underlying file.

read
size_t read(void[] dst)

Read a chunk of bytes from the file into the provided array. Returns the number of bytes read, or Eof where there is no further data.

write
size_t write(const(void)[] src)

Write a chunk of bytes to the file from the provided array. Returns the number of bytes written, or Eof if the output is no longer available.

Meta