mirror of
https://github.com/processing/processing4.git
synced 2026-01-28 19:01:08 +01:00
purge several "applet" references from the code
This commit is contained in:
@@ -32,11 +32,11 @@ import java.net.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
*
|
||||
* A client connects to a server and sends data back and forth. If anything
|
||||
* goes wrong with the connection, for example the host is not there or is
|
||||
*
|
||||
* A client connects to a server and sends data back and forth. If anything
|
||||
* goes wrong with the connection, for example the host is not there or is
|
||||
* listening on a different port, an exception is thrown.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @webBrief The client class is used to create client Objects which connect to a server to exchange data
|
||||
* @instanceName client any variable of type Client
|
||||
@@ -67,8 +67,8 @@ public class Client implements Runnable {
|
||||
int bufferLast;
|
||||
|
||||
boolean disposeRegistered = false;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param host address of the server
|
||||
@@ -113,7 +113,7 @@ public class Client implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param socket any object of type Socket
|
||||
*/
|
||||
@@ -147,15 +147,15 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Disconnects from the server. Use to shut the connection when you're
|
||||
*
|
||||
* Disconnects from the server. Use to shut the connection when you're
|
||||
* finished with the Client.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @webBrief Disconnects from the server
|
||||
* @usage application
|
||||
*/
|
||||
public void stop() {
|
||||
public void stop() {
|
||||
if (disconnectEventMethod != null && thread != null){
|
||||
try {
|
||||
disconnectEventMethod.invoke(parent, this);
|
||||
@@ -181,7 +181,7 @@ public class Client implements Runnable {
|
||||
* Disconnect from the server: internal use only.
|
||||
* <P>
|
||||
* This should only be called by the internal functions in PApplet,
|
||||
* use stop() instead from within your own applets.
|
||||
* use stop() instead from within your own sketches.
|
||||
*/
|
||||
public void dispose() {
|
||||
thread = null;
|
||||
@@ -202,7 +202,7 @@ public class Client implements Runnable {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
@@ -230,7 +230,7 @@ public class Client implements Runnable {
|
||||
while (input != null) {
|
||||
int readCount;
|
||||
|
||||
// try to read a byte using a blocking read.
|
||||
// try to read a byte using a blocking read.
|
||||
// An exception will occur when the sketch is exits.
|
||||
try {
|
||||
readCount = input.read(readBuffer, 0, readBuffer.length);
|
||||
@@ -240,7 +240,7 @@ public class Client implements Runnable {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// read returns -1 if end-of-stream occurs (for example if the host disappears)
|
||||
if (readCount == -1) {
|
||||
System.err.println("Client got end-of-stream.");
|
||||
@@ -303,10 +303,10 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns <b>true</b> if this client is still active and hasn't run
|
||||
* into any trouble.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @webBrief Returns <b>true</b> if this client is still active
|
||||
* @usage application
|
||||
@@ -317,9 +317,9 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns the IP address of the computer to which the Client is attached.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the IP address of the machine as a <b>String</b>
|
||||
@@ -333,10 +333,10 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the number of bytes available. When any client has bytes
|
||||
*
|
||||
* Returns the number of bytes available. When any client has bytes
|
||||
* available from the server, it returns the number of bytes.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the number of bytes in the buffer waiting to be read
|
||||
@@ -349,9 +349,9 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Empty the buffer, removes all the data stored there.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Clears the buffer
|
||||
@@ -365,11 +365,11 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in
|
||||
* the buffer. Returns -1 if there is no byte, although this should be
|
||||
*
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in
|
||||
* the buffer. Returns -1 if there is no byte, although this should be
|
||||
* avoided by first checking <b>available()</b> to see if any data is available.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns a value from the buffer
|
||||
@@ -389,10 +389,10 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or
|
||||
*
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or
|
||||
* <b>0xffff</b> if nothing is there.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the next byte in the buffer as a char
|
||||
@@ -406,21 +406,21 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Reads a group of bytes from the buffer. The version with no parameters
|
||||
* returns a byte array of all data in the buffer. This is not efficient,
|
||||
* but is easy to use. The version with the <b>byteBuffer</b> parameter is
|
||||
* more memory and time efficient. It grabs the data in the buffer and puts
|
||||
* it into the byte array passed in and returns an int value for the number
|
||||
* of bytes read. If more bytes are available than can fit into the
|
||||
*
|
||||
* Reads a group of bytes from the buffer. The version with no parameters
|
||||
* returns a byte array of all data in the buffer. This is not efficient,
|
||||
* but is easy to use. The version with the <b>byteBuffer</b> parameter is
|
||||
* more memory and time efficient. It grabs the data in the buffer and puts
|
||||
* it into the byte array passed in and returns an int value for the number
|
||||
* of bytes read. If more bytes are available than can fit into the
|
||||
* <b>byteBuffer</b>, only those that fit are read.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Return a byte array of anything that's in the serial buffer.
|
||||
* Not particularly memory/speed efficient, because it creates
|
||||
* a byte array on each read, but it's easier to use than
|
||||
* readBytes(byte b[]) (see below).
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Reads a group of bytes from the buffer
|
||||
@@ -479,7 +479,7 @@ public class Client implements Runnable {
|
||||
* Returns an int for how many bytes were read. If more bytes
|
||||
* are available than can fit into the byte array, only those
|
||||
* that will fit are read.
|
||||
*
|
||||
*
|
||||
* @param bytebuffer passed in byte array to be altered
|
||||
*/
|
||||
public int readBytes(byte[] bytebuffer) {
|
||||
@@ -501,18 +501,18 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Reads from the port into a buffer of bytes up to and including a
|
||||
* particular character. If the character isn't in the buffer, 'null' is
|
||||
* returned. The version with no <b>byteBuffer</b> parameter returns a byte
|
||||
* array of all data up to and including the <b>interesting</b> byte. This
|
||||
* is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs
|
||||
* the data in the buffer and puts it into the byte array passed in and
|
||||
* returns an int value for the number of bytes read. If the byte buffer is
|
||||
* not large enough, -1 is returned and an error is printed to the message
|
||||
*
|
||||
* Reads from the port into a buffer of bytes up to and including a
|
||||
* particular character. If the character isn't in the buffer, 'null' is
|
||||
* returned. The version with no <b>byteBuffer</b> parameter returns a byte
|
||||
* array of all data up to and including the <b>interesting</b> byte. This
|
||||
* is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs
|
||||
* the data in the buffer and puts it into the byte array passed in and
|
||||
* returns an int value for the number of bytes read. If the byte buffer is
|
||||
* not large enough, -1 is returned and an error is printed to the message
|
||||
* area. If nothing is in the buffer, 0 is returned.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Reads from the buffer of bytes up to and including a particular character
|
||||
@@ -557,7 +557,7 @@ public class Client implements Runnable {
|
||||
* and an error message is printed on the console.
|
||||
* If nothing is in the buffer, zero is returned.
|
||||
* If 'interesting' byte is not in the buffer, then 0 is returned.
|
||||
*
|
||||
*
|
||||
* @param byteBuffer passed in byte array to be altered
|
||||
*/
|
||||
public int readBytesUntil(int interesting, byte[] byteBuffer) {
|
||||
@@ -601,7 +601,7 @@ public class Client implements Runnable {
|
||||
*
|
||||
* In 4.0 beta 3, changed to using UTF-8 as the encoding,
|
||||
* otherwise the behavior is platform-dependent.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the buffer as a <b>String</b>
|
||||
@@ -616,14 +616,14 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns
|
||||
*
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns
|
||||
* <b>null</b> if it doesn't find what you're looking for.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* In 4.0 beta 3, changed to using UTF-8 as the encoding,
|
||||
* otherwise the behavior is platform-dependent.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the buffer as a <b>String</b> up to and including a particular character
|
||||
@@ -641,9 +641,9 @@ public class Client implements Runnable {
|
||||
/**
|
||||
*
|
||||
* Writes data to a server specified when constructing the client, or writes
|
||||
* data to the specific client obtained from the Server <b>available()</b>
|
||||
* data to the specific client obtained from the Server <b>available()</b>
|
||||
* method.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Writes <b>bytes</b>, <b>chars</b>, <b>ints</b>, <b>bytes[]</b>, <b>Strings</b>
|
||||
|
||||
@@ -33,17 +33,17 @@ import java.net.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* A server sends and receives data to and from its associated clients
|
||||
* (other programs connected to it). When a server is started, it begins
|
||||
* listening for connections on the port specified by the <b>port</b>
|
||||
* parameter. Computers have many ports for transferring data and some are
|
||||
* commonly used so be sure to not select one of these. For example, web
|
||||
*
|
||||
* A server sends and receives data to and from its associated clients
|
||||
* (other programs connected to it). When a server is started, it begins
|
||||
* listening for connections on the port specified by the <b>port</b>
|
||||
* parameter. Computers have many ports for transferring data and some are
|
||||
* commonly used so be sure to not select one of these. For example, web
|
||||
* servers usually use port 80 and POP mail uses port 110.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @usage application
|
||||
* @webBrief The server class is used to create server objects which send
|
||||
* @webBrief The server class is used to create server objects which send
|
||||
* and receives data to and from its associated clients (other programs connected to it)
|
||||
* @instanceName server any variable of type Server
|
||||
*/
|
||||
@@ -61,7 +61,7 @@ public class Server implements Runnable {
|
||||
/** Array of client objects, useful length is determined by clientCount. */
|
||||
public Client[] clients;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param port port used to transfer data
|
||||
@@ -69,12 +69,12 @@ public class Server implements Runnable {
|
||||
public Server(PApplet parent, int port) {
|
||||
this(parent, port, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param port port used to transfer data
|
||||
* @param host when multiple NICs are in use, the ip (or name) to bind from
|
||||
* @param host when multiple NICs are in use, the ip (or name) to bind from
|
||||
*/
|
||||
public Server(PApplet parent, int port, String host) {
|
||||
this.parent = parent;
|
||||
@@ -94,7 +94,7 @@ public class Server implements Runnable {
|
||||
|
||||
parent.registerMethod("dispose", this);
|
||||
|
||||
// reflection to check whether host applet has a call for
|
||||
// reflection to check whether host sketch has a call for
|
||||
// public void serverEvent(Server s, Client c);
|
||||
// which is called when a new guy connects
|
||||
try {
|
||||
@@ -114,9 +114,9 @@ public class Server implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Disconnect a particular client.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @webBrief Disconnect a particular client
|
||||
* @param client the client to disconnect
|
||||
@@ -130,8 +130,8 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void removeIndex(int index) {
|
||||
synchronized (clientsLock) {
|
||||
clientCount--;
|
||||
@@ -143,8 +143,8 @@ public class Server implements Runnable {
|
||||
clients[clientCount] = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void disconnectAll() {
|
||||
synchronized (clientsLock) {
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
@@ -158,8 +158,8 @@ public class Server implements Runnable {
|
||||
clientCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void addClient(Client client) {
|
||||
synchronized (clientsLock) {
|
||||
if (clientCount == clients.length) {
|
||||
@@ -168,8 +168,8 @@ public class Server implements Runnable {
|
||||
clients[clientCount++] = client;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected int clientIndex(Client client) {
|
||||
synchronized (clientsLock) {
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
@@ -181,20 +181,20 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns <b>true</b> if this server is still active and hasn't run
|
||||
* into any trouble.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @webBrief Return <b>true</b> if this server is still active
|
||||
*/
|
||||
public boolean active() {
|
||||
return thread != null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static public String ip() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostAddress();
|
||||
@@ -211,9 +211,9 @@ public class Server implements Runnable {
|
||||
int lastAvailable = -1;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns the next client in line with a new message.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @webBrief Returns the next client in line with a new message
|
||||
* @usage application
|
||||
@@ -247,13 +247,13 @@ public class Server implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Disconnects all clients and stops the server.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Use this to shut down the server if you finish using it while your applet
|
||||
* is still running. Otherwise, it will be automatically be shut down by the
|
||||
* host PApplet using dispose(), which is identical.
|
||||
* Use this to shut down the server if you finish using it while your sketch
|
||||
* is still running. Otherwise, it will be automatically be shut down by the
|
||||
* host PApplet using dispose(), which is identical.
|
||||
* @webref server
|
||||
* @webBrief Disconnects all clients and stops the server
|
||||
* @usage application
|
||||
@@ -323,10 +323,10 @@ public class Server implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Writes a value to all the connected clients. It sends bytes out from the
|
||||
*
|
||||
* Writes a value to all the connected clients. It sends bytes out from the
|
||||
* Server object.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @webBrief Writes data to all connected clients
|
||||
* @param data data to write
|
||||
@@ -344,7 +344,7 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void write(byte data[]) {
|
||||
synchronized (clientsLock) {
|
||||
@@ -359,7 +359,7 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void write(String data) {
|
||||
synchronized (clientsLock) {
|
||||
|
||||
@@ -34,9 +34,9 @@ import jssc.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Class for sending and receiving data using the serial communication protocol.
|
||||
*
|
||||
*
|
||||
* @webref serial
|
||||
* @webBrief Class for sending and receiving data using the serial communication protocol
|
||||
* @instanceName serial any variable of type Serial
|
||||
@@ -186,7 +186,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Returns the number of bytes available.
|
||||
*
|
||||
*
|
||||
* @generate Serial_available.xml
|
||||
* @webref serial
|
||||
* @webBrief Returns the number of bytes available
|
||||
@@ -212,7 +212,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Sets a specific byte to buffer until before calling <b>serialEvent()</b>.
|
||||
*
|
||||
*
|
||||
* @generate Serial_bufferUntil.xml
|
||||
* @webref serial
|
||||
* @webBrief Sets a specific byte to buffer until before calling <b>serialEvent()</b>
|
||||
@@ -266,7 +266,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Returns last byte received or -1 if there is none available.
|
||||
*
|
||||
*
|
||||
* @generate Serial_last.xml
|
||||
* <h3>Advanced</h3>
|
||||
* Same as read() but returns the very last value received
|
||||
@@ -292,7 +292,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Returns the last byte received as a char or -1 if there is none available.
|
||||
*
|
||||
*
|
||||
* @generate Serial_lastChar.xml
|
||||
* @webref serial
|
||||
* @webBrief Returns the last byte received as a char or -1 if there is none available
|
||||
@@ -304,9 +304,9 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Gets a list of all available serial ports. Use <b>println()</b> to write the
|
||||
* Gets a list of all available serial ports. Use <b>println()</b> to write the
|
||||
* information to the text window.
|
||||
*
|
||||
*
|
||||
* @generate Serial_list.xml
|
||||
* @webref serial
|
||||
* @webBrief Gets a list of all available serial ports
|
||||
@@ -320,10 +320,10 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in the buffer.
|
||||
* Returns -1 if there is no byte, although this should be avoided by first cheacking
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in the buffer.
|
||||
* Returns -1 if there is no byte, although this should be avoided by first cheacking
|
||||
* <b>available()</b> to see if data is available.
|
||||
*
|
||||
*
|
||||
* @generate Serial_read.xml
|
||||
* @webref serial
|
||||
* @webBrief Returns a number between 0 and 255 for the next byte that's waiting in the buffer
|
||||
@@ -346,11 +346,11 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Reads a group of bytes from the buffer or <b>null</b> if there are none available. The version
|
||||
* with no parameters returns a byte array of all data in the buffer. This is not efficient, but
|
||||
* is easy to use. The version with the <b>byteBuffer</b> parameter is more memory and time
|
||||
* efficient. It grabs the data in the buffer and puts it into the byte array passed in and returns
|
||||
* an int value for the number of bytes read. If more bytes are available than can fit into the
|
||||
* Reads a group of bytes from the buffer or <b>null</b> if there are none available. The version
|
||||
* with no parameters returns a byte array of all data in the buffer. This is not efficient, but
|
||||
* is easy to use. The version with the <b>byteBuffer</b> parameter is more memory and time
|
||||
* efficient. It grabs the data in the buffer and puts it into the byte array passed in and returns
|
||||
* an int value for the number of bytes read. If more bytes are available than can fit into the
|
||||
* <b>byteBuffer</b>, only those that fit are read.
|
||||
* @generate Serial_readBytes.xml
|
||||
* @webref serial
|
||||
@@ -370,7 +370,7 @@ public class Serial implements SerialPortEventListener {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <h3>Advanced</h3>
|
||||
@@ -432,18 +432,18 @@ public class Serial implements SerialPortEventListener {
|
||||
return toCopy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reads from the port into a buffer of bytes up to and including a particular character. If the
|
||||
* character isn't in the buffer, <b>null</b> is returned. The version with without the
|
||||
* <b>byteBuffer</b> parameter returns a byte array of all data up to and including the
|
||||
* <b>interesting</b> byte. This is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs the data in the buffer
|
||||
* and puts it into the byte array passed in and returns an int value for the number of bytes read.
|
||||
* If the byte buffer is not large enough, -1 is returned and an error is printed to the message
|
||||
* Reads from the port into a buffer of bytes up to and including a particular character. If the
|
||||
* character isn't in the buffer, <b>null</b> is returned. The version with without the
|
||||
* <b>byteBuffer</b> parameter returns a byte array of all data up to and including the
|
||||
* <b>interesting</b> byte. This is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs the data in the buffer
|
||||
* and puts it into the byte array passed in and returns an int value for the number of bytes read.
|
||||
* If the byte buffer is not large enough, -1 is returned and an error is printed to the message
|
||||
* area. If nothing is in the buffer, 0 is returned.
|
||||
*
|
||||
*
|
||||
* @generate Serial_readBytesUntil.xml
|
||||
* @webref serial
|
||||
* @webBrief Reads from the port into a buffer of bytes up to and including a particular character
|
||||
@@ -527,7 +527,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or <b>0xffff</b>
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or <b>0xffff</b>
|
||||
* if nothing is there.
|
||||
*
|
||||
* @generate Serial_readChar.xml
|
||||
@@ -541,9 +541,9 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Returns all the data from the buffer as a <b>String</b> or <b>null</b> if there is nothing available.
|
||||
* This method assumes the incoming characters are ASCII. If you want to transfer Unicode data,
|
||||
* first convert the String to a byte stream in the representation of your choice (i.e. UTF8 or
|
||||
* Returns all the data from the buffer as a <b>String</b> or <b>null</b> if there is nothing available.
|
||||
* This method assumes the incoming characters are ASCII. If you want to transfer Unicode data,
|
||||
* first convert the String to a byte stream in the representation of your choice (i.e. UTF8 or
|
||||
* two-byte Unicode data), and send it as a byte array.
|
||||
*
|
||||
* @generate Serial_readString.xml
|
||||
@@ -560,7 +560,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns <b>null</b>
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns <b>null</b>
|
||||
* if it doesn't find what you're looking for.
|
||||
*
|
||||
* @generate Serial_readStringUntil.xml
|
||||
@@ -585,11 +585,11 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Called when data is available. Use one of the <b>read()</b> methods to capture this data.
|
||||
* The <b>serialEvent()</b> can be set with <b>buffer()</b> to only trigger after a certain
|
||||
* number of data elements are read and can be set with <b>bufferUntil()</b> to only trigger
|
||||
* after a specific character is read. The <b>which</b> parameter contains the name of the
|
||||
* port where new data is available, but is only useful when there is more than one serial
|
||||
* Called when data is available. Use one of the <b>read()</b> methods to capture this data.
|
||||
* The <b>serialEvent()</b> can be set with <b>buffer()</b> to only trigger after a certain
|
||||
* number of data elements are read and can be set with <b>bufferUntil()</b> to only trigger
|
||||
* after a specific character is read. The <b>which</b> parameter contains the name of the
|
||||
* port where new data is available, but is only useful when there is more than one serial
|
||||
* connection open and it's necessary to distinguish between the two.
|
||||
*
|
||||
* @generate serialEvent.xml
|
||||
@@ -630,7 +630,7 @@ public class Serial implements SerialPortEventListener {
|
||||
// serialAvailable() does not provide any real benefits over using
|
||||
// available() and read() inside draw - but this function has no
|
||||
// thread-safety issues since it's being invoked during pre in the context
|
||||
// of the Processing applet
|
||||
// of the Processing sketch
|
||||
serialEventMethod.invoke(parent, this);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error, disabling serialEvent() for "+port.getPortName());
|
||||
@@ -676,7 +676,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Stops data communication on this port. Use to shut the connection when you're finished with the Serial.
|
||||
*
|
||||
*
|
||||
* @generate Serial_stop.xml
|
||||
* @webref serial
|
||||
* @webBrief Stops data communication on this port
|
||||
@@ -723,7 +723,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Writes <b>bytes</b>, <b>chars</b>, <b>ints</b>, <b>bytes[]</b>, <b>Strings</b> to the serial port
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Write a String to the output. Note that this doesn't account
|
||||
* for Unicode (two bytes per char), nor will it send UTF8
|
||||
|
||||
Reference in New Issue
Block a user