|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--vga_1_4
Example class that uses javax.comm and serial events This class implements SerialPortEventListener in order to receive the DataAvailable event.
| Field Summary | |
protected java.io.InputStream |
inStream
reference to the serial input stream |
(package private) Motor |
mElbow
|
private byte |
msgIndex
|
private byte |
msgSize
Number of bytes total in a message from the LCD. |
private byte |
msgValue
This is the value of the message if it is a byte, such as LCD doing a get byte or sending an RPC 03, in this case the value is 0x03. |
(package private) Motor |
mWrist
|
protected java.io.OutputStream |
outStream
reference to the serial output stream |
(package private) static byte[] |
readBuffer
The incoming data buffer, will hold request from the LCD |
| Constructor Summary | |
vga_1_4()
|
|
| Method Summary | |
private byte |
ascHex(byte[] barray,
byte offset)
|
void |
blockThread()
method to block a thread |
void |
echo(java.io.InputStream inStream,
java.io.OutputStream outStream)
Method that reads the input stream and echo's the data out the uart. If no data is available it will block waiting for incomming data What we want here is to look for a variable length packet from the LCD, build up an array until the packet is complete, then process it and start all over. |
void |
initializeSerialPort()
Method to initialize the serial port (9600N81)and set up the input and output streams. |
static void |
main(java.lang.String[] args)
Main entry point for the program. Initializes the serial port, sends a message, then blocks. |
void |
processMsg()
Process the message, which exists in readBuffer |
void |
sendMessage(java.lang.String msgString)
Sends a string out the serial port. |
void |
serialEvent(javax.comm.SerialPortEvent ev)
Javax.comm will call this method whenever a Data Available event occurs |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected java.io.InputStream inStream
protected java.io.OutputStream outStream
private byte msgSize
private byte msgValue
private byte msgIndex
static byte[] readBuffer
final Motor mElbow
final Motor mWrist
| Constructor Detail |
public vga_1_4()
| Method Detail |
public static void main(java.lang.String[] args)
public void blockThread()
public void sendMessage(java.lang.String msgString)
msgString - is the string to be send out the serial port
public void echo(java.io.InputStream inStream,
java.io.OutputStream outStream)
public void processMsg()
private byte ascHex(byte[] barray,
byte offset)
public void serialEvent(javax.comm.SerialPortEvent ev)
serialEvent in interface javax.comm.SerialPortEventListenerpublic void initializeSerialPort()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||