public class Serial
extends Object
implements SerialPortEventListener
| Modifier and Type | Field and Description | 
|---|---|
| SerialPort | port | 
| Constructor and Description | 
|---|
| Serial(PApplet parent) | 
| Serial(PApplet parent,
      int baudRate) | 
| Serial(PApplet parent,
      String portName) | 
| Serial(PApplet parent,
      String portName,
      int baudRate) | 
| Serial(PApplet parent,
      String portName,
      int baudRate,
      char parity,
      int dataBits,
      float stopBits) | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | active()Return true if this port is still active and hasn't run
 into any trouble. | 
| int | available() | 
| void | buffer(int size) | 
| void | bufferUntil(int inByte) | 
| void | clear() | 
| void | dispose()Used by PApplet to shut things down. | 
| boolean | getCTS() | 
| boolean | getDSR() | 
| static Map<String,String> | getProperties(String portName) | 
| int | last() | 
| char | lastChar() | 
| static String[] | list() | 
| void | pre() | 
| int | read() | 
| byte[] | readBytes() | 
| int | readBytes(byte[] dest)Advanced | 
| byte[] | readBytes(int max)Advanced | 
| byte[] | readBytesUntil(int inByte) | 
| int | readBytesUntil(int inByte,
              byte[] dest)Advanced | 
| char | readChar() | 
| String | readString() | 
| String | readStringUntil(int inByte) | 
| void | serialEvent(SerialPortEvent event) | 
| void | setDTR(boolean state)Set the DTR line | 
| void | setRTS(boolean state)Set the RTS line | 
| void | stop() | 
| void | write(byte[] src) | 
| void | write(int src)Advanced | 
| void | write(String src) | 
public Serial(PApplet parent)
parent - typically use "this"public Serial(PApplet parent, int baudRate)
baudRate - 9600 is the defaultpublic Serial(PApplet parent, String portName)
portName - name of the port (COM1 is the default)public Serial(PApplet parent, String portName, int baudRate)
public Serial(PApplet parent, String portName, int baudRate, char parity, int dataBits, float stopBits)
parity - 'N' for none, 'E' for even, 'O' for odd, 'M' for mark, 'S' for space ('N' is the default)dataBits - 8 is the defaultstopBits - 1.0, 1.5, or 2.0 (1.0 is the default)public void dispose()
public boolean active()
public void pre()
public int available()
public void buffer(int size)
size - number of bytes to bufferpublic void bufferUntil(int inByte)
inByte - the value to buffer untilpublic void clear()
public boolean getCTS()
public boolean getDSR()
public static Map<String,String> getProperties(String portName)
public int last()
public char lastChar()
public static String[] list()
public int read()
public byte[] readBytes()
public byte[] readBytes(int max)
max - the maximum number of bytes to readpublic int readBytes(byte[] dest)
public byte[] readBytesUntil(int inByte)
inByte - character designated to mark the end of the datapublic int readBytesUntil(int inByte,
                          byte[] dest)
dest - passed in byte array to be alteredpublic char readChar()
public String readString()
public String readStringUntil(int inByte)
inByte - character designated to mark the end of the datapublic void serialEvent(SerialPortEvent event)
serialEvent in interface SerialPortEventListenerevent - the port where new data is availablepublic void setDTR(boolean state)
public void setRTS(boolean state)
public void stop()
public void write(byte[] src)
src - data to writepublic void write(int src)
src - data to writepublic void write(String src)
src - data to write