SignStixSerial
The general procedure for using a serial device is as follows:
Modifier and Type | Function and Description |
---|---|
void |
close(int connectionId)
Close down the argument connection.
|
void |
closeAll()
Close down all open connections.
|
int |
connect(String devicePath,
String driverName,
int baudRate,
int stopBits,
int dataBits,
int parity)
Attempt to connect to the serial device identified by the devicePath.
|
String |
getDevicesInfo()
Find information about the USB devices currently connected to the Player.
|
void |
requestPermission(String devicePath,
String jsFunctionName)
Request permission to use the USB serial device identified by the devicePath.
|
void |
startReading(int connectionId,
String jsFunctionName)
Start reading data from the argument connection.
|
void |
stopReading(int connectionId)
Stop reading from the argument connection.
|
void |
write(int connectionId,
String hexData)
Send the bytes represented by the hexData to the serial device associated
with the connectionId.
|
void |
writePreClose(int connectionId,
String hexData)
Arrange for the argument hex data to be sent to the serial device
associated with the argument connection ID immediately before the
connection is closed.
|
String getDevicesInfo()
devicePath
(string) - the device path e.g.
"/dev/bus/usb/001/003"vendorId
(string) - the ID of the device vendor in
HEX.productId
(string) - the ID of the product vendor
in HEX.productName
(string) - the name of the product (if
known - this may be null).void requestPermission(String devicePath, String jsFunctionName)
devicePath
- the path of the serial device as determined from
getDevicesInfo()
.jsFunctionName
- the name of a Javascript function which will be
called when the permission request process completes. It should
take parameters as follows:
int connect(String devicePath, String driverName, int baudRate, int stopBits, int dataBits, int parity)
devicePath
- the path of the serial device as determined from
getDevicesInfo()
.driverName
- pass in "ch34" to use the CH34xUART driver. Pass in "usb" to use
FTDI or PL2303. Further drivers/devices may be supported in future.baudRate
- one of {600, 1200, 2400, 4800, 9600, 19200, 38400, 57600,
115200, 230400, 460800, 921600}.stopBits
- one of {1, 2}.dataBits
- one of {5, 6, 7, 8}.parity
- one of {0=None, 1=Odd, 2=Even, 3=Mark, 4=Space}.void write(int connectionId, String hexData)
connectionId
- the connection to communicate with.hexData
- a String of bytes in hexadecimal format.void writePreClose(int connectionId, String hexData)
This can be used to ensure an orderly disconnection from a device in the case when the connection is closed automatically e.g. when moving to a different sign.
connectionId
- the connection to communicate with.hexData
- a String of bytes in hexadecimal format, or null to cancel
a previous instruction.void startReading(int connectionId, String jsFunctionName)
connectionId
- the ID of the connection.jsFunctionName
- the name of a Javascript function which will be
called when data is received. It should take parameters as
follows:
void stopReading(int connectionId)
connectionId
- the ID of the connection.void close(int connectionId)
This should be called when communication is over to free-up resources. Do not attempt further operations on a closed connection.
connectionId
- the ID of the connection.void closeAll()
This should be called when communication is over to free-up resources. Do not attempt further operations on closed connections.