Public Member Functions | |
Rs232SerialFactory (GlobalSettings settings, ScheduledExecutorService coreExecutor) | |
void | startPortScan (SerialPortType portType, Consumer< SerialPortInfo > portInfoConsumer) |
void | stopPortScan () |
Optional< RemoteMenuController > | getPortByIdWithBaud (String deviceId, int baud) throws IOException |
boolean | attemptPairing (String deviceId, int baud, Consumer< AuthStatus > authStatusConsumer) throws IOException |
This factory has two main usages, firstly it is used to scan for available ports for use in UIs and other places where a list of ports is needed. Secondly it is used to create a port based on a previously obtained ID. This implementation is based on jSerialComm and provides all serial ports supported by that library.
boolean com.thecoderscorner.embedcontrol.core.rs232.Rs232SerialFactory.attemptPairing | ( | String | deviceId, |
int | baud, | ||
Consumer< AuthStatus > | authStatusConsumer | ||
) | throws IOException |
Create a connection for pairing and block in this method until the process is completed, so therefore never call on the UI thread. You will be called back as status updates are available but these updates are not on the UI thread.
deviceId | the device ID from a prior port scan |
baud | the baud rate to connect at if applicable |
authStatusConsumer | the consumer that should receive status updates, not on UI thread. |
IOException | if the controller cannot be created. |
Implements com.thecoderscorner.embedcontrol.core.serial.PlatformSerialFactory.
Optional<RemoteMenuController> com.thecoderscorner.embedcontrol.core.rs232.Rs232SerialFactory.getPortByIdWithBaud | ( | String | deviceId, |
int | baud | ||
) | throws IOException |
Creates a serial port controller based on a previously obtained device ID returned during a scan. Throws an exception if unable to recreate.
deviceId | the device ID from a prior port scan |
baud | the baud rate to connect at if applicable. |
IOException | if the controller cannot be created. |
Implements com.thecoderscorner.embedcontrol.core.serial.PlatformSerialFactory.
void com.thecoderscorner.embedcontrol.core.rs232.Rs232SerialFactory.startPortScan | ( | SerialPortType | portType, |
Consumer< SerialPortInfo > | portInfoConsumer | ||
) |
Start scanning for ports calling the portInfoConsumer for each one that is found. Note that the consumer is NOT called on the UI thread.
portType | the type of port to scan for |
portInfoConsumer | the consumer for each port found |
Implements com.thecoderscorner.embedcontrol.core.serial.PlatformSerialFactory.
void com.thecoderscorner.embedcontrol.core.rs232.Rs232SerialFactory.stopPortScan | ( | ) |
Stop scanning for ports after a call to startPortScan will stop scanning.
Implements com.thecoderscorner.embedcontrol.core.serial.PlatformSerialFactory.