All Manuals > LispWorks® User Guide and Reference Manual > 44 The SERIAL-PORT Package

open-serial-port Function

Summary

Attempts to open the named serial port and return a serial-port object.

Package

serial-port

Signature

open-serial-port name &key baud-rate data-bits stop-bits parity cts-flow-p dsr-flow-p dtr rts read-interval-timeout read-total-base-timeout read-total-byte-timeout write-total-base-timeout write-total-byte-timeout => serial-port

Arguments
name
A string naming a serial port.
baud-rate
A non-negative integer.
data-bits
A non-negative integer.
stop-bits
One of 1, 1.5 (Windows only) or 2.
parity
One of :even, :mark, :none, :odd or :space.
cts-flow-p
A generalized boolean.
dsr-flow-p
A generalized boolean.
dtr
One of nil, t, or :handshake.
rts
One of nil, t, or :handshake.
read-interval-timeout
A non-negative real or :none.
read-total-base-timeout
A non-negative real.
read-total-byte-timeout
A non-negative real.
write-total-base-timeout
A non-negative real.
write-total-byte-timeout
A non-negative real.
Values
serial-port
A serial-port object.
Description

The function open-serial-port attempts to open the serial port name and return a serial-port object.

On Windows, name is passed directly to CreateFile(). For ports COMn where n > 9, you must take care to pass the real port name expected by Windows. At the time of writing this issue is documented at http://support.microsoft.com/kb/115831 .

On non-Windows platforms, name should be the device file name (for example "/dev/cu.usbmodem14111").

If any of baud-rate, data-bits, stop-bits and parity are supplied then the corresponding serial port settings are changed. The values of baud-rate and data-bits should each be an appropriate integer. The value of stop-bits should be 1, 1.5 (Windows only) or 2. The value of parity should be one of the keywords :even, :none or :odd, or on Windows, :mark or :space.

cts-flow-p and dsr-flow-p control whether write operations respond to CTS and DSR flow control. A non-nil value means that the corresponding flow control is used. Note that dsr-flow-p is only supported on Windows.

dtr and rts control whether read operations generate DTR or RTS flow control. If the value is :handshake then the corresponding flow control signal is generated automatically. If the value is nil or t then the initial state of the flow control signal is set and automatic flow control is not used. See set-serial-port-state for manual flow control. Note: the value :handshake for dtr is only supported on Windows.

read-interval-timeout can be used to control the maximum time to wait between each input character. The value :none means that reading will not wait for characters at all, only returning whatever is already in the input buffer.

read-total-base-timeout and read-total-byte-timeout can be used to control the maximum time to wait for a sequence of characters. write-total-base-timeout and write-total-byte-timeout can be used to control the maximum time to wait when transmitting a sequence of characters. For both reading and writing the timeout is given by the expression:

base_timeout + nchars * byte_timeout

The default value of each of read-total-base-timeout, read-total-byte-timeout, write-total-base-timeout and write-total-byte-timeout is nil and this means that the corresponding parameter in the OS is left unchanged and there is zero timeout. Otherwise the value should be a non-negative real number specifying a timeout in seconds.

See also

close-serial-port
set-serial-port-state


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:55