public class SerialHelper extends HelperBase
Modifier and Type | Class and Description |
---|---|
class |
SerialHelper.SerialReader
Read from the serial port and emit data.
|
class |
SerialHelper.SerialWriter
Write to the serial port.
|
HelperBase.DATA_TYPE
_actor, _currentObj
Constructor and Description |
---|
SerialHelper(java.lang.Object actor,
jdk.nashorn.api.scripting.ScriptObjectMirror helping,
java.lang.String portName,
java.lang.String ownerName,
int timeout,
java.util.Map<java.lang.String,java.lang.Object> options)
Open a serial port.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_appendToBuffer(java.lang.Object data,
HelperBase.DATA_TYPE type,
java.lang.String imageType,
io.vertx.core.buffer.Buffer buffer)
Append data to be sent to the specified buffer.
|
void |
close()
Close the serial port.
|
void |
open()
Open the serial port.
|
void |
send(java.lang.Object data)
Send data over the serial port.
|
static java.lang.String[] |
supportedReceiveTypes()
Return an array of the types supported by the current host for
receiveType arguments.
|
static java.lang.String[] |
supportedSendTypes()
Return an array of the types supported by the current host for
sendType arguments.
|
_appendNumericToBuffer, _error, _error, _error, _error, _extractFromBuffer, _issueResponse, _removeDuplicates, _sizeOfType, _toJavaBytes, _toJSArray, getHelping
public SerialHelper(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror helping, java.lang.String portName, java.lang.String ownerName, int timeout, java.util.Map<java.lang.String,java.lang.Object> options)
actor
- The actor associated with this helper.helping
- The object that this is helping (SerialPort).portName
- The name of the port to open.ownerName
- The name of the owner assigned to this port, if opening is successful.timeout
- Time in milliseconds before failing.options
- Serial port options (FIXME: define).public void close()
public void open() throws IllegalActionException
If the port is not found, then try each available port in turn and open the first as yet unopened port. Port names that include "Bluetooth" and "/dev/cu." are skipped. Different machines may have different port names so port scanning makes it possible to have models that will open the first N serial ports.
IllegalActionException
- If there is no such port, if
the port is owned by another user, if the port does not
support the specified paramters or if the input or output
fails.public void send(java.lang.Object data)
data
- The data to send.public static java.lang.String[] supportedReceiveTypes()
public static java.lang.String[] supportedSendTypes()
protected void _appendToBuffer(java.lang.Object data, HelperBase.DATA_TYPE type, java.lang.String imageType, io.vertx.core.buffer.Buffer buffer)
_appendToBuffer
in class HelperBase
data
- The data to append.type
- The type of data append.imageType
- If the type is IMAGE, then then the image encoding to use, or
null to use the default (JPG).buffer
- The buffer.