Class Rs232RemoteConnector
- java.lang.Object
-
- com.thecoderscorner.menu.remote.StreamRemoteConnector
-
- com.thecoderscorner.menu.remote.rs232.Rs232RemoteConnector
-
- All Implemented Interfaces:
RemoteConnector,RemoteConnectorContext
public class Rs232RemoteConnector extends StreamRemoteConnector
This is the R232 connector that can talk to a tcMenu library application running on an embedded Arduino. Normally one uses the Rs232ControllerBuilder to construct the whole remote stack instead of creating this directly.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.thecoderscorner.menu.remote.StreamRemoteConnector
StreamRemoteConnector.ReadMode
-
-
Field Summary
-
Fields inherited from class com.thecoderscorner.menu.remote.StreamRemoteConnector
clock, executor, logger, stateMachineMappings
-
-
Constructor Summary
Constructors Constructor Description Rs232RemoteConnector(LocalIdentifier localId, java.lang.String portName, int baud, MenuCommandProtocol protocol, java.util.concurrent.ScheduledExecutorService executor, java.time.Clock clock, ConnectMode connectMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidgetAtLeastBytes(java.nio.ByteBuffer inputBuffer, int len, StreamRemoteConnector.ReadMode mode)Reads at least the number of bytes requested waiting if need be for more data.java.lang.StringgetConnectionName()Gets the name of this connector locallybooleanisDeviceConnected()Indicates if the underlying device is actually connected.voidperformConnection()protected voidsendInternal(java.nio.ByteBuffer outputBuffer)performs a send of all bytes in the output buffer until the output buffer is emptyvoidstart()Starts the communication channel, so it will attempt to connect with the configured devicevoidstop()Stops the library and attempts to also stop any threads and other resources associated.-
Methods inherited from class com.thecoderscorner.menu.remote.StreamRemoteConnector
changeState, changeState, close, doesBufferHaveEOM, getAuthenticationStatus, getClock, getRemoteParty, getScheduledExecutor, handleCoreConnectionStates, logByteBuffer, notifyConnection, notifyListeners, readCommandFromStream, readCompleteMessage, registerConnectionChangeListener, registerConnectorListener, sendAcknowledgement, sendHeartbeat, sendJoin, sendMenuCommand, sendPairing, setRemoteParty
-
-
-
-
Constructor Detail
-
Rs232RemoteConnector
public Rs232RemoteConnector(LocalIdentifier localId, java.lang.String portName, int baud, MenuCommandProtocol protocol, java.util.concurrent.ScheduledExecutorService executor, java.time.Clock clock, ConnectMode connectMode)
-
-
Method Detail
-
start
public void start()
Description copied from interface:RemoteConnectorStarts the communication channel, so it will attempt to connect with the configured device
-
stop
public void stop()
Description copied from interface:RemoteConnectorStops the library and attempts to also stop any threads and other resources associated.
-
getConnectionName
public java.lang.String getConnectionName()
Description copied from interface:RemoteConnectorGets the name of this connector locally
-
isDeviceConnected
public boolean isDeviceConnected()
Description copied from interface:RemoteConnectorIndicates if the underlying device is actually connected.- Returns:
- true if the underlying device is connected
-
performConnection
public void performConnection() throws java.io.IOException- Throws:
java.io.IOException
-
sendInternal
protected void sendInternal(java.nio.ByteBuffer outputBuffer) throws java.io.IOExceptionDescription copied from class:StreamRemoteConnectorperforms a send of all bytes in the output buffer until the output buffer is empty- Specified by:
sendInternalin classStreamRemoteConnector- Parameters:
outputBuffer- the buffer data to be sent- Throws:
java.io.IOException- if there are problems writing
-
getAtLeastBytes
protected void getAtLeastBytes(java.nio.ByteBuffer inputBuffer, int len, StreamRemoteConnector.ReadMode mode) throws java.io.IOExceptionDescription copied from class:StreamRemoteConnectorReads at least the number of bytes requested waiting if need be for more data.- Specified by:
getAtLeastBytesin classStreamRemoteConnector- Parameters:
inputBuffer- the buffer to read fromlen- the minimum number of bytes needed- Throws:
java.io.IOException- if there are problems reading.
-
-