|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectedu.berkeley.guir.ptk.PTK
edu.berkeley.guir.ptk.util.SerialReadWrite
Enables reading from and writing to the serial port. You can read/write Strings or byte[] ("packets"). The default port is COM1 and the default packet size is 25 The packet size is applicable only when calling readPacket(). As an alternative, readLine() will read all bytes up to a new line. You can set these data fields by passing new values into a constructor.
| Field Summary | |
protected java.lang.String |
CLASS_NAME
|
protected boolean |
m_bInitialized
|
protected boolean |
m_bShutdown
|
protected java.io.InputStream |
m_is
|
protected java.io.OutputStream |
m_os
|
protected int |
packet_size
|
protected java.lang.String |
port
|
protected javax.comm.SerialPort |
serialPort
|
| Fields inherited from class edu.berkeley.guir.ptk.PTK |
debug, MAX_DEBUG, MED_DEBUG, MIN_DEBUG, NO_DEBUG |
| Constructor Summary | |
SerialReadWrite()
|
|
SerialReadWrite(int packet_size)
|
|
SerialReadWrite(java.lang.String port)
|
|
SerialReadWrite(java.lang.String port,
int packet_size)
|
|
| Method Summary | |
boolean |
closeSource()
Close the serial port. |
boolean |
openSource()
Opens the serial port for reading and writing. |
void |
printAllPorts()
Print the ports your machine has available. |
java.lang.String |
readLine()
Read a line (up until the first newline) from the serial port. |
byte[] |
readPacket()
Read a packet of size SerialReadWrite.packet_size from the serial port and return it as a byte array. |
boolean |
writePacket(java.lang.String message)
Write a String to the serial port as a byte array. |
boolean |
writeString(java.lang.String message)
Write a String to the serial port. |
| Methods inherited from class edu.berkeley.guir.ptk.PTK |
getMAX, getMED, getMIN, getNO, printDebug, printDebug, printError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected int packet_size
protected java.lang.String port
protected java.io.InputStream m_is
protected java.io.OutputStream m_os
protected java.lang.String CLASS_NAME
protected boolean m_bInitialized
protected boolean m_bShutdown
protected javax.comm.SerialPort serialPort
| Constructor Detail |
public SerialReadWrite()
public SerialReadWrite(java.lang.String port,
int packet_size)
public SerialReadWrite(java.lang.String port)
public SerialReadWrite(int packet_size)
| Method Detail |
public boolean openSource()
public java.lang.String readLine()
public byte[] readPacket()
public boolean closeSource()
public boolean writeString(java.lang.String message)
message - the String to write.
public boolean writePacket(java.lang.String message)
message - the String to write.
public void printAllPorts()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||