|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.raben.telescope.comm.SerialConnection
A class to handle communications with a serial connection
| Field Summary |
| Fields inherited from interface javax.comm.CommPortOwnershipListener |
PORT_OWNED, PORT_OWNERSHIP_REQUESTED, PORT_UNOWNED |
| Constructor Summary | |
SerialConnection()
Create a SerialConnection using default settings of 8 bits, 9600 baud, no parity, no flow control, and 1 stop bit on port named COM1 . |
|
| Method Summary | |
void |
closeConnection()
Close the port and clean up associated elements. |
static java.lang.String |
displayCharArrayAsHexString(char[] chars)
Convert array of bytes to space separated hex string for debug display |
static java.lang.String[] |
getAvailablePorts()
Get serial ports |
int |
getBaudRate()
Get baud rate |
int |
getDatabits()
Get data bits |
int |
getFlowControl()
Get flow control |
int |
getParity()
Get current parity setting |
java.lang.String |
getPortName()
Get the port name being used by this connection |
int |
getStopbits()
Get stop bits |
boolean |
isDebug()
Check debug flag return true if set |
boolean |
isOpen()
Check if the serial port is open |
void |
openConnection()
Open a serial connection and IO streams using the current parameters |
void |
ownershipChange(int type)
Handle ownership change event. |
char[] |
receiveChars()
Receive character array from serial connection |
java.lang.String |
receiveString()
Receive String from serial connection |
void |
sendChars(char[] chars)
Send an array of chars to the serial connection |
void |
sendString(java.lang.String str)
Send string to the serial connection |
void |
serialEvent(javax.comm.SerialPortEvent evt)
Handle Serial Port Events. |
void |
setBaudRate(int baudRate)
Set baud rate. |
void |
setDatabits(int databits)
Set new data bits. |
void |
setDebug(boolean debug)
Set debug flag |
void |
setFlowControl(int flowControl)
Set flow control Formed by "or-ing" both "in" and "out" flow control settings. |
void |
setParity(int parity)
Set parity |
void |
setPortName(java.lang.String portName)
Set name of port to open |
void |
setStopbits(int stopbits)
Set stop bits. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SerialConnection()
| Method Detail |
public void openConnection()
throws java.io.IOException
java.io.IOException - may occurpublic void closeConnection()
public boolean isOpen()
public void serialEvent(javax.comm.SerialPortEvent evt)
serialEvent in interface javax.comm.SerialPortEventListenerevt - SerialPortEventpublic void ownershipChange(int type)
ownershipChange in interface javax.comm.CommPortOwnershipListenertype - Type of owernership event
public void sendChars(char[] chars)
throws java.io.IOException
chars - Array of chars
java.io.IOException - may occur
public void sendString(java.lang.String str)
throws java.io.IOException
str - The string to send
java.io.IOException - may occurpublic java.lang.String receiveString()
public char[] receiveChars()
public void setPortName(java.lang.String portName)
portName - (example for MS Windows COM1 or COM2)public java.lang.String getPortName()
public void setStopbits(int stopbits)
stopbits - New stop bits setting.public int getStopbits()
public void setParity(int parity)
parity - New parity setting.public int getParity()
public int getBaudRate()
public void setBaudRate(int baudRate)
baudRate - New baud rate (9600 is default)public int getDatabits()
public void setDatabits(int databits)
databits - New data bits setting.public void setFlowControl(int flowControl)
flowControl - Flow control settings settingfor flow control definitionspublic int getFlowControl()
public static java.lang.String displayCharArrayAsHexString(char[] chars)
chars - Array of chars
public void setDebug(boolean debug)
debug - Set to true to list cmds sent, responses receivedpublic boolean isDebug()
public static java.lang.String[] getAvailablePorts()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||