public interface SerialDevice extends TopologyElement
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
|Modifier and Type||Method and Description|
Create a function that can be used to source a stream from a serial port device.
Set the initialization function for this port.
void setInitializer(Consumer<SerialPort> initializer)
initializer.accept(port)is called once, passing a runtime
SerialPortfor 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
SerialPortfor this serial device. The value returned by
driver.apply(serialPort)is returned by this returned function.
drivertypically sends instructions to the serial port using
SerialPort.getOutput()and then reads the result using
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 type
driver- Function that interacts with the serial port to produce a value.
Topology.poll(Supplier, long, TimeUnit)
Copyright © 2016–2017 The Apache Software Foundation. All rights reserved.