Subversion Repositories Programming Utils

Compare Revisions

Ignore whitespace Rev 9 → Rev 10

/JavaSerial/src/com/rm5248/serial/SerialPort.java
179,6 → 179,7
* Set the Baud Rate for this port.
*
* @param rate
* @throws IllegalStateException if the port has already been closed.
*/
public void setBaudRate( BaudRate rate ){
int myRate = 0;
213,6 → 214,7
* Get the input stream to be used to read from this SerialPort.
*
* @return The input stream.
* @throws IllegalStateException if the port has already been closed.
*/
public InputStream getInputStream(){
if( closed ){
225,6 → 227,7
/** Get the output stream used to write data to this device.
*
* @return The output stream.
* @throws IllegalStateException if the port has already been closed.
*/
public OutputStream getOutputStream(){
if( closed ){
259,6 → 262,7
* Set the stop bits of the serial port, after the port has been opened.
*
* @param stop
* @throws IllegalStateException if the port has already been closed.
*/
public void setStopBits( StopBits stop ){
int myStop = 0;
279,6 → 283,7
* Set the data bits size, after the port has been opened.
*
* @param data
* @throws IllegalStateException if the port has already been closed.
*/
public void setDataSize( DataBits data ){
int myData = 0;
297,11 → 302,17
setCharSize( myData );
}
/**
* Set the parity of the serial port, after the port has been opened.
*
* @param parity
* @throws IllegalStateException if the port has been closed.
*/
public void setParity( Parity parity ){
int myParity = 0;
if( closed ){
throw new IllegalStateException( "Cannot set the DataBits once the port has been closed." );
throw new IllegalStateException( "Cannot set the parity once the port has been closed." );
}
switch( parity ){
312,6 → 323,75
setParity( myParity );
}
/**
* Get the serial line state for the specified serial port.
*
* @return
*/
public SerialLineState getSerialLineState(){
SerialLineState state = new SerialLineState();
if( closed ){
throw new IllegalStateException( "Cannot get the serial line state once the port has been closed." );
}
return state;
}
/**
* Set the serial line state to the parameters given.
*
* @param state
*/
public void setSerialLineState( SerialLineState state ){
}
/**
* Get the baud rate of the serial port.
*
* @return
*/
public SerialPort.BaudRate getBaudRate(){
return BaudRate.B0;
}
/**
* Get the number of data bits.
*
* @return
*/
public SerialPort.DataBits getDataBits(){
return DataBits.DATABITS_8;
}
/**
* Get the number of stop bits.
*
* @return
*/
public SerialPort.StopBits getStopBits(){
return StopBits.STOPBITS_1;
}
/**
* Get the parity of the serial port.
*
* @return
*/
public SerialPort.Parity getParity(){
return Parity.NONE;
}
/**
* Get the flow control for the serial port.
*
* @return
*/
public SerialPort.FlowControl getFlowControl(){
return FlowControl.NONE;
}
 
/**
* Open the specified port, return an internal handle to the data structure for this port.
/JavaSerial/src/com/rm5248/serial/SerialLineState.java
0,0 → 1,26
package com.rm5248.serial;
 
/**
* This class represents the current state of the lines on the serial port.
* You can also use this class to set the state of the serial port.
*
*/
public class SerialLineState {
public boolean carrierDetect;
public boolean clearToSend;
public boolean dataSetReady;
public boolean dataTerminalReady;
public boolean ringIndicator;
public boolean requestToSend;
public SerialLineState(){
carrierDetect = false;
clearToSend = false;
dataSetReady = false;
dataTerminalReady = false;
ringIndicator = false;
requestToSend = false;
}
 
}