|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.nau.cs.scu.SignalInterpreter
public class SignalInterpreter
This class provides the methods for sending and receiving signals
over a serial port. Calling enumeratePorts()
will initialize
the communications drivers. The comm port can be set using
setPort(CommPortIdentifier)
. When the port is set, the communication
is still not started. Communication can be started using
enableCommunication()
. Communications can be stopped using
disableCommunication()
.
Field Summary | |
---|---|
static int |
COMM_PORT_TIMEOUT
This constant defines how long the communications driver should wait (in milliseconds) when trying to open a port. |
Method Summary | |
---|---|
static byte |
calculateChecksum(byte[] command)
This method calculates the checksum of a command byte packet. |
void |
disableCommunication()
This will stop communications on the current port. |
boolean |
enableCommunication()
This is the method used to start communications on a port which was previously selected using setPort(CommPortIdentifier) . |
javax.comm.CommPortIdentifier[] |
enumeratePorts()
The first call to this method will initialize the serial communications drivers. |
void |
forceCommunicationBreak(boolean forceBreak)
This method is used to force a break in communication. |
static SignalInterpreter |
getInstance()
This method is used to retrieve the singleton instance of the SignalInterpreter |
boolean |
isCommunicating()
This returns whether the SignalInterpreter currently has open communications on a serial port. |
void |
setPort(javax.comm.CommPortIdentifier port)
Sets the port for future communication. |
void |
setSerialConfig(SerialConfiguration sc)
Set the baud rate and serial communication configuration. |
boolean |
write(byte[] response)
This method is used to write information to to the serial port. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int COMM_PORT_TIMEOUT
Method Detail |
---|
public static SignalInterpreter getInstance()
public static byte calculateChecksum(byte[] command)
command
- The byte packet to calculate the checksum for
public boolean enableCommunication() throws javax.comm.PortInUseException, javax.comm.UnsupportedCommOperationException, java.io.IOException, java.lang.NoClassDefFoundError
setPort(CommPortIdentifier)
. If no
port has been previously selected, this method will fail.
javax.comm.PortInUseException
- If the port is currently being used by another application. Establishing communications failed
javax.comm.UnsupportedCommOperationException
- If setting the port baud rate and configuration fails. Communications will still be operational, but may not operate correctly
java.io.IOException
- If there was a problem opening the port. Establishing communications failed.
java.lang.NoClassDefFoundError
- If the serial communications driver is not loaded.public boolean write(byte[] response)
response
- The byte packet to write to the serial stream.
public void forceCommunicationBreak(boolean forceBreak)
forceBreak
- If true, a break will be forced in communicationpublic void disableCommunication()
enableCommunication()
is called again.
public boolean isCommunicating()
public void setPort(javax.comm.CommPortIdentifier port)
enableCommunication()
is called again.
port
- The port to communicate on.public void setSerialConfig(SerialConfiguration sc) throws javax.comm.UnsupportedCommOperationException
sc
- The SerialConfiguration enumeration detailing the settings
javax.comm.UnsupportedCommOperationException
- If the chosen baud rate and settings are not supported. Communications are still running, but may operate in unpredictable ways.public javax.comm.CommPortIdentifier[] enumeratePorts() throws java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError
- If the serial communications drivers are not loaded in the system
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |