|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectroombacomm.RoombaComm
roombacomm.RoombaCommSerial
public class RoombaCommSerial
The serial-port based implementation of RoombaComm. Handles both physical RS-232 ports, USB adapter ports like Keyspan USA-19HS, and Bluetooth serial port profiles.
Some code taken from processing.serial.Serial. Thanks guys!
The interaction model for setting the port and protocol and WaitForDSR parameters is as follows.On creation, the class initializes the parameters, then tries to read .roomba_config. If it can read the config file and parse out the parameters, it sets the parameters to the values in the config file. Apps can read the current settings for display using methods on the class. Apps can override the settings by accepting user input and setting the parameters using methods on the class, or the connect() method. Parameters that are changed by the app are re-written in the config file, for use as defaults next run. Command-line apps can make these parameters optional, by using the defaults if the user doesn't specify them.
Field Summary | |
---|---|
boolean |
flushOutput
RXTX bombs when flushing output sometimes, so by default do not flush the output stream. |
java.io.InputStream |
input
the serial input stream, normally you don't need access to this |
java.io.OutputStream |
output
the serial output stream, normally you don't need access to this |
gnu.io.SerialPort |
port
The RXTX port object, normally you don't need access to this |
static int |
updateSensorsPause
The time to wait in milliseconds after sending sensors command before attempting to read |
boolean |
waitForDSR
Some "virtual" serial ports like Bluetooth serial on Windows return weird errors deep inside RXTX if an opened port is used before the virtual COM port is ready. |
Constructor Summary | |
---|---|
RoombaCommSerial()
|
|
RoombaCommSerial(boolean autoupdate)
|
|
RoombaCommSerial(boolean autoupdate,
int updateTime)
|
Method Summary | |
---|---|
void |
computeSensors()
called by serialEvent when we have enough bytes to make sensors valid |
boolean |
connect(java.lang.String portid)
Connect to a serial port specified by portid doesn't guarantee connection to Roomba, just to serial port |
void |
disconnect()
Disconnect from serial port |
java.lang.String |
getPortname()
|
java.lang.String |
getProtocol()
|
static boolean |
isPortInUse(java.lang.String pname)
Let you check to see if a port is in use by another Rooomba before trying to use it. |
boolean |
isWaitForDSR()
|
java.lang.String[] |
listPorts()
If this just hangs and never completes on Windows, it may be because the DLL doesn't have its exec bit set. |
boolean |
send(byte[] bytes)
subclassed. |
boolean |
send(int b)
This will handle both ints, bytes and chars transparently. |
void |
serialEvent(gnu.io.SerialPortEvent serialEvent)
callback for SerialPortEventListener (from processing.serial.Serial) |
void |
setPortname(java.lang.String p)
|
void |
setProtocol(java.lang.String protocol)
|
void |
setWaitForDSR(boolean waitForDSR)
|
boolean |
updateSensors()
Update sensors. |
boolean |
updateSensors(int packetcode)
Update sensors. |
void |
wakeup()
toggles DD line via serial port DTR (if available) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int updateSensorsPause
public gnu.io.SerialPort port
public java.io.InputStream input
public java.io.OutputStream output
public boolean flushOutput
public boolean waitForDSR
Constructor Detail |
---|
public RoombaCommSerial()
public RoombaCommSerial(boolean autoupdate)
public RoombaCommSerial(boolean autoupdate, int updateTime)
Method Detail |
---|
public static boolean isPortInUse(java.lang.String pname)
public boolean connect(java.lang.String portid)
connect
in class RoombaComm
portid
- name of port, e.g. "/dev/cu.KeySerial1" or "COM3"
public void disconnect()
disconnect
in class RoombaComm
public boolean send(byte[] bytes)
send
in class RoombaComm
bytes
- byte array of ROI commands to send
public boolean send(int b)
send
in class RoombaComm
b
- byte of an ROI command to send
public void wakeup()
wakeup
in class RoombaComm
public boolean updateSensors()
updateSensors
in class RoombaComm
public boolean updateSensors(int packetcode)
public void computeSensors()
public java.lang.String[] listPorts()
listPorts
in class RoombaComm
public java.lang.String getProtocol()
public void setProtocol(java.lang.String protocol)
public boolean isWaitForDSR()
public void setWaitForDSR(boolean waitForDSR)
public java.lang.String getPortname()
public void setPortname(java.lang.String p)
public void serialEvent(gnu.io.SerialPortEvent serialEvent)
serialEvent
in interface gnu.io.SerialPortEventListener
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |