IO on serial ports based on jRXTX.
Any IO operation will throw an exception in case of failure.
IO on serial ports based on jRXTX. Any IO operation will throw an exception in case of failure.
(available-byte+ port)
Estimates how many bytes are available for reading right now.
Estimates how many bytes are available for reading right now.
(available-port+)
Gets a set of available serial ports.
Prints an error if a port is already locked but does not throw.
Gets a set of available serial ports. Prints an error if a port is already locked but does not throw.
Defaut values for keys and options used throughout this namespace.
Defaut values for keys and options used throughout this namespace.
(describe port)
Describes the current status of the given serial port by providing a map containing the same keys as the option for opening a serial port as well as a :rxtx/name and :rxtx/closed?.
See serial-port
.
Describes the current status of the given serial port by providing a map containing the same keys as the option for opening a serial port as well as a :rxtx/name and :rxtx/closed?. See [[serial-port]].
(flush port)
Ensures written bytes are properly flushed.
Ensures written bytes are properly flushed.
(input-stream port)
Given an open serial port, retrieves the associated java.io.InputStream
.
Should not be needed unless really needed.
Given an open serial port, retrieves the associated `java.io.InputStream`. Should not be needed unless really needed.
Anything that can be converted to a byte-array and then be written using a serial port.
Anything that can be converted to a byte-array and then be written using a serial port.
(to-byte-array this)
Converts the given argument to a byte array.
Converts the given argument to a byte array.
(output-stream port)
Given an open serial port, retrieves the associated java.io.OutputStream
.
Should not be needed unless really needed.
Given an open serial port, retrieves the associated `java.io.OutputStream`. Should not be needed unless really needed.
(read port n)
(read port n timeout-ms)
Reads an arbitrary amount of unsigned bytes from the serial port and returns them as a sequence.
If a timeout is provided, unblocks once it is up and returns what has been read up to this point.
It not, blocks until n
have been read, no less.
Reads an arbitrary amount of unsigned bytes from the serial port and returns them as a sequence. If a timeout is provided, unblocks once it is up and returns what has been read up to this point. It not, blocks until `n` have been read, no less.
(reconfigure port port-options)
Reconfigures the given serial port on the fly by providing a map containing the same options as for opening a new port.
Missing options will not resolve to default values.
See serial-port
.
Reconfigures the given serial port on the fly by providing a map containing the same options as for opening a new port. Missing options will not resolve to default values. See [[serial-port]].
(serial-port path)
(serial-port path port-options)
Opens a serial port at the given path.
The configuration map may contain:
Key | Description |
---|---|
:rxtx/baud-rate | Preferably a standard baud rate |
:rxtx/data-bits | How many bits per data char one of #{5 6 7 8} |
:rxtx/flow-control | Handshaking for preventing the sender from sending too much too fast, see below |
:rxtx/parity | Error detection, see below |
:rxtx/stop-bits | Bits sent at the end of each data char, see below |
Flow control is one of:
Keyword | Description |
---|---|
:none | No handshaking |
:rts-cts | Hardware flow-control |
:xon-xoff | Software flow-control |
Parity is one of:
Keyword | Description |
---|---|
:even | An even parity bit will be sent for each data char |
:mark | Mark parity bit |
:none | No parity bit |
:odd | Odd parity will be sent for each data char |
:space | Space parity |
Stop-bits is one of:
See default+
for default values relative to these options.
(serial-port "/dev/ttyUSB0"
{:rxtx/baud-rate 2400
:rxtx/parity :none})
Opens a serial port at the given path. The configuration map may contain: | Key | Description | |---|---| | :rxtx/baud-rate | Preferably a standard baud rate | | :rxtx/data-bits | How many bits per data char one of #{5 6 7 8} | | :rxtx/flow-control | Handshaking for preventing the sender from sending too much too fast, see below | | :rxtx/parity | Error detection, see below | | :rxtx/stop-bits | Bits sent at the end of each data char, see below | Flow control is one of: | Keyword | Description | |---|---| | :none | No handshaking | | :rts-cts | Hardware flow-control | | :xon-xoff | Software flow-control | Parity is one of: | Keyword | Description | |---|---| | :even | An even parity bit will be sent for each data char | | :mark | Mark parity bit | | :none | No parity bit | | :odd | Odd parity will be sent for each data char | | :space |Space parity | Stop-bits is one of: - :stop-bits-1 - :stop-bits-1.5 - :stop-bits-2 See [[default+]] for default values relative to these options. ```clojure (serial-port "/dev/ttyUSB0" {:rxtx/baud-rate 2400 :rxtx/parity :none}) ```
(write port writable)
Writes to the serial port anything satisfying the IWritable
protocol.
Are already available:
Writes to the serial port anything satisfying the [[IWritable]] protocol. Are already available: - Byte arrays - Characters - Sequences of any sort (seqables) - Number converted to a single unsigned byte - Strings
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close