public interface SerialDevice extends TopologyElement
SerialPort
.
SerialDevice
is typically used through
a protocol module that sends the appropriate bytes
to the port and decodes the bytes output by the port.
It is guaranteed that during any call to function returned by
this interface has exclusive access to SerialPort
.
Modifier and Type | Method and Description |
---|---|
<T> Supplier<T> |
getSource(Function<SerialPort,T> driver)
Create a function that can be used to source a
stream from a serial port device.
|
void |
setInitializer(Consumer<SerialPort> initializer)
Set the initialization function for this port.
|
topology
void setInitializer(Consumer<SerialPort> initializer)
initializer.accept(port)
is called once, passing a runtime
SerialPort
for this serial device.initializer
- Function to be called when the application runs.<T> Supplier<T> getSource(Function<SerialPort,T> driver)
get()
on the returned function will result in a call
to driver.apply(serialPort)
passing a runtime SerialPort
for this serial device.
The value returned by driver.apply(serialPort)
is
returned by this returned function.
driver
typically sends instructions to the
serial port using SerialPort.getOutput()
and then
reads the result using SerialPort.getInput()
.
Multiple instances of a supplier function can be created, for example to read different parameters from the device connected to the serial port. While each function is being called it has exclusive use of the serial port.
T
- Tuple typedriver
- Function that interacts with the serial port to produce a value.Topology.poll(Supplier, long, TimeUnit)
Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641