embedCONTROLCore
Public Member Functions | List of all members
com.thecoderscorner.embedcontrol.core.rs232.Rs232SerialFactory Class Reference
Inheritance diagram for com.thecoderscorner.embedcontrol.core.rs232.Rs232SerialFactory:
com.thecoderscorner.embedcontrol.core.serial.PlatformSerialFactory

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
 

Detailed Description

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.

Member Function Documentation

◆ attemptPairing()

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.

Parameters
deviceIdthe device ID from a prior port scan
baudthe baud rate to connect at if applicable
authStatusConsumerthe consumer that should receive status updates, not on UI thread.
Returns
true if successful, otherwise false.
Exceptions
IOExceptionif the controller cannot be created.

Implements com.thecoderscorner.embedcontrol.core.serial.PlatformSerialFactory.

◆ getPortByIdWithBaud()

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.

Parameters
deviceIdthe device ID from a prior port scan
baudthe baud rate to connect at if applicable.
Returns
the created controller
Exceptions
IOExceptionif the controller cannot be created.

Implements com.thecoderscorner.embedcontrol.core.serial.PlatformSerialFactory.

◆ startPortScan()

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.

Parameters
portTypethe type of port to scan for
portInfoConsumerthe consumer for each port found

Implements com.thecoderscorner.embedcontrol.core.serial.PlatformSerialFactory.

◆ stopPortScan()

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.


The documentation for this class was generated from the following file: