Subversion Repositories Programming Utils

Compare Revisions

Ignore whitespace Rev 41 → Rev 42

/trunk/JavaSerial/LICENSE
0,0 → 1,7
Copyright (c) 2013 rm5248
 
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/trunk/JavaSerial/src/com/rm5248/serial/NoSuchPortException.java
1,5 → 1,11
package com.rm5248.serial;
 
/**
* This exception is thrown when you attempt to open up a port that does not exist.
*
* @author rm5248
*
*/
public class NoSuchPortException extends Exception {
 
/**
/trunk/JavaSerial/src/com/rm5248/serial/SerialPort.java
5,6 → 5,15
import java.io.InputStream;
import java.io.OutputStream;
 
/**
* A SerialPort object represents a SerialPort object on the system.
*
* When creating a SerialPort object, you give the SerialPort the name of the port that you
* wish to open.
*
* @author rm5248
*
*/
public class SerialPort implements Closeable {
 
static{
130,10 → 139,11
private Object serialListenSync;
 
/**
* Open the specified port, 8 bit characters, 1 stop bit, no parity, no flow control, 9600 baud.
* Open the specified port, 9600 baud, 8 data bits, 1 stop bit, no parity, no flow control
*
* @param portName The port to open, on Windows "COM1" on Linux "/dev/ttyS0"
* @throws NoSuchPortException If the port does not exist
* @param portName The name of the port to open
* @throws NoSuchPortException If this port does not exist
* @throws NotASerialPortException If the specified port is not a serial port
*/
public SerialPort( String portName ) throws NoSuchPortException, NotASerialPortException {
this( portName, BaudRate.B9600 );
184,35 → 194,71
}
 
/**
* Open the specified port, 8 bit characters, 1 stop bit, no parity, no flow control.
* Open the specified port, no flow control
*
* @param portName The port to open, on Windows "COM1" on Linux "/dev/ttyS0"
* @param rate The Baud Rate to open this port at
* @throws NoSuchPortException
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @throws NoSuchPortException If this port does not exist
* @throws NotASerialPortException If the specified port is not a serial port
*/
public SerialPort( String portName, BaudRate rate )throws NoSuchPortException, NotASerialPortException {
this( portName, rate, DataBits.DATABITS_8 );
}
 
/**
* Open the specified port, 1 stop bit, no parity, no flow control.
/**
* Open the specified port, no flow control
*
* @param portName The port to open
* @param rate The Baud Rate to open this port at
* @param data The number of data bits.
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @param data The number of data bits
* @throws NoSuchPortException If this port does not exist
* @throws NotASerialPortException If the specified port is not a serial port
*/
public SerialPort( String portName, BaudRate rate, DataBits data ) throws NoSuchPortException, NotASerialPortException {
this( portName, rate, data, StopBits.STOPBITS_1 );
}
 
/**
* Open the specified port, no parity or flow control
*
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @param data The number of data bits
* @param stop The number of stop bits
* @throws NoSuchPortException If this port does not exist
* @throws NotASerialPortException If the specified port is not a serial port
*/
public SerialPort( String portName, BaudRate rate, DataBits data, StopBits stop ) throws NoSuchPortException, NotASerialPortException {
this( portName, rate, data, stop, Parity.NONE );
}
 
/**
* Open the specified port, no flow control
*
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @param data The number of data bits
* @param stop The number of stop bits
* @param parity The parity of the line
* @throws NoSuchPortException If this port does not exist
* @throws NotASerialPortException If the specified port is not a serial port
*/
public SerialPort( String portName, BaudRate rate, DataBits data, StopBits stop, Parity parity ) throws NoSuchPortException, NotASerialPortException {
this( portName, rate, data, stop, parity, FlowControl.NONE );
}
 
/**
* Open the specified port, defining all options
*
* @param portName The name of the port to open
* @param rate The Buad Rate to open this port at
* @param data The number of data bits
* @param stop The number of stop bits
* @param parity The parity of the line
* @param flow The flow control of the line
* @throws NoSuchPortException If this port does not exist
* @throws NotASerialPortException If the specified port is not a serial port
*/
public SerialPort( String portName, BaudRate rate, DataBits data, StopBits stop, Parity parity, FlowControl flow ) throws NoSuchPortException, NotASerialPortException {
int myRate = 0;
int myData = 0;
586,6 → 632,11
return cont;
}
/**
* Set the flow control for the serial port
*
* @param flow
*/
public void setFlowControl( FlowControl flow ){
switch( flow ){
case HARDWARE: setFlowControl( 1 ); break;
/trunk/JavaSerial/src/com/rm5248/serial/NotASerialPortException.java
1,5 → 1,11
package com.rm5248.serial;
 
/**
* This exception is thrown when the device that you have opened is not a serial port.
*
* @author rm5248
*
*/
public class NotASerialPortException extends Exception {
 
/**
/trunk/JavaSerial/src/com/rm5248/serial/SerialLineState.java
5,7 → 5,7
* You can also use this class to set the state of the serial port.
*
* Note that all of these options may not be available depending on the
* serial port that is in use.
* serial port that is in use, and/or the platform that you are running on.
*
*/
public class SerialLineState {
/trunk/JavaSerial/README
0,0 → 1,8
Java Serial
=========================================
 
This software is open-source software.
 
The home of Java Serial is at http://svn.rm5248.com/RMProgrammingUtilities/?page_id=19
 
Use of this code is subject to license terms as laid out in LICENSE