mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
introducing jSSC: an RXTX replacement
This commit is contained in:
Binary file not shown.
BIN
app/lib/jssc.jar
Normal file
BIN
app/lib/jssc.jar
Normal file
Binary file not shown.
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
package processing.app;
|
package processing.app;
|
||||||
|
|
||||||
|
import jssc.SerialPortList;
|
||||||
import processing.app.debug.*;
|
import processing.app.debug.*;
|
||||||
import processing.app.syntax.*;
|
import processing.app.syntax.*;
|
||||||
import processing.app.tools.*;
|
import processing.app.tools.*;
|
||||||
@ -43,8 +44,6 @@ import javax.swing.event.*;
|
|||||||
import javax.swing.text.*;
|
import javax.swing.text.*;
|
||||||
import javax.swing.undo.*;
|
import javax.swing.undo.*;
|
||||||
|
|
||||||
import gnu.io.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main editor panel for the Processing Development Environment.
|
* Main editor panel for the Processing Development Environment.
|
||||||
*/
|
*/
|
||||||
@ -979,36 +978,19 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
serialMenu.removeAll();
|
serialMenu.removeAll();
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
|
|
||||||
try
|
String[] portNames = SerialPortList.getPortNames();
|
||||||
{
|
for (String curr_port : portNames) {
|
||||||
for (Enumeration enumeration = CommPortIdentifier.getPortIdentifiers(); enumeration.hasMoreElements();)
|
|
||||||
{
|
|
||||||
CommPortIdentifier commportidentifier = (CommPortIdentifier)enumeration.nextElement();
|
|
||||||
//System.out.println("Found communication port: " + commportidentifier);
|
|
||||||
if (commportidentifier.getPortType() == CommPortIdentifier.PORT_SERIAL)
|
|
||||||
{
|
|
||||||
//System.out.println("Adding port to serial port menu: " + commportidentifier);
|
|
||||||
String curr_port = commportidentifier.getName();
|
|
||||||
rbMenuItem = new JCheckBoxMenuItem(curr_port, curr_port.equals(Preferences.get("serial.port")));
|
rbMenuItem = new JCheckBoxMenuItem(curr_port, curr_port.equals(Preferences.get("serial.port")));
|
||||||
rbMenuItem.addActionListener(serialMenuListener);
|
rbMenuItem.addActionListener(serialMenuListener);
|
||||||
//serialGroup.add(rbMenuItem);
|
//serialGroup.add(rbMenuItem);
|
||||||
serialMenu.add(rbMenuItem);
|
serialMenu.add(rbMenuItem);
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
//System.out.println("enabling the serialMenu");
|
//System.out.println("enabling the serialMenu");
|
||||||
serialMenu.setEnabled(true);
|
serialMenu.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
System.out.println(_("error retrieving port list"));
|
|
||||||
exception.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serialMenu.getItemCount() == 0) {
|
if (serialMenu.getItemCount() == 0) {
|
||||||
serialMenu.setEnabled(false);
|
serialMenu.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,10 @@
|
|||||||
package processing.app;
|
package processing.app;
|
||||||
//import processing.core.*;
|
//import processing.core.*;
|
||||||
|
|
||||||
|
import jssc.*;
|
||||||
import processing.app.debug.MessageConsumer;
|
import processing.app.debug.MessageConsumer;
|
||||||
import static processing.app.I18n._;
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
import gnu.io.*;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -53,15 +52,6 @@ public class Serial implements SerialPortEventListener {
|
|||||||
int stopbits;
|
int stopbits;
|
||||||
boolean monitor = false;
|
boolean monitor = false;
|
||||||
|
|
||||||
// read buffer and streams
|
|
||||||
|
|
||||||
InputStream input;
|
|
||||||
OutputStream output;
|
|
||||||
|
|
||||||
byte buffer[] = new byte[32768];
|
|
||||||
int bufferIndex;
|
|
||||||
int bufferLast;
|
|
||||||
|
|
||||||
MessageConsumer consumer;
|
MessageConsumer consumer;
|
||||||
|
|
||||||
public Serial(boolean monitor) throws SerialException {
|
public Serial(boolean monitor) throws SerialException {
|
||||||
@ -102,31 +92,16 @@ public class Serial implements SerialPortEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean touchPort(String iname, int irate) throws SerialException {
|
public static boolean touchPort(String iname, int irate) throws SerialException {
|
||||||
SerialPort port;
|
SerialPort port = new SerialPort(iname);
|
||||||
boolean result = false;
|
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
port.openPort();
|
||||||
Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
|
port.setParams(irate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, false, true);
|
||||||
while (portList.hasMoreElements()) {
|
port.closePort();
|
||||||
CommPortIdentifier portId = portList.nextElement();
|
return true;
|
||||||
if ((CommPortIdentifier.PORT_SERIAL == portId.getPortType()) && (portId.getName().equals(iname))) {
|
} catch (SerialPortException e) {
|
||||||
port = (SerialPort) portId.open("tap", 2000);
|
throw new SerialException(I18n.format(_("Error touching serial port ''{0}''."), iname), e);
|
||||||
port.setSerialPortParams(irate, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
|
|
||||||
port.close();
|
|
||||||
result = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (PortInUseException e) {
|
|
||||||
throw new SerialException(
|
|
||||||
I18n.format(_("Serial port ''{0}'' already in use. Try quitting any programs that may be using it."), iname)
|
|
||||||
);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SerialException(
|
|
||||||
I18n.format(_("Error touching serial port ''{0}''."), iname), e
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Serial(String iname, int irate,
|
public Serial(String iname, int irate,
|
||||||
char iparity, int idatabits, float istopbits)
|
char iparity, int idatabits, float istopbits)
|
||||||
@ -148,46 +123,15 @@ public class Serial implements SerialPortEventListener {
|
|||||||
if (istopbits == 2) stopbits = SerialPort.STOPBITS_2;
|
if (istopbits == 2) stopbits = SerialPort.STOPBITS_2;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
port = null;
|
port = new SerialPort(iname);
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Enumeration<CommPortIdentifier> portList = CommPortIdentifier.getPortIdentifiers();
|
|
||||||
while (portList.hasMoreElements()) {
|
|
||||||
CommPortIdentifier portId = portList.nextElement();
|
|
||||||
|
|
||||||
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
|
|
||||||
//System.out.println("found " + portId.getName());
|
|
||||||
if (portId.getName().equals(iname)) {
|
|
||||||
//System.out.println("looking for "+iname);
|
//System.out.println("looking for "+iname);
|
||||||
port = (SerialPort)portId.open("serial madness", 2000);
|
port.openPort();
|
||||||
port.setDTR(true);
|
port.setParams(rate, databits, stopbits, parity, false, true);
|
||||||
port.setRTS(true);
|
|
||||||
input = port.getInputStream();
|
|
||||||
output = port.getOutputStream();
|
|
||||||
port.setSerialPortParams(rate, databits, stopbits, parity);
|
|
||||||
port.addEventListener(this);
|
port.addEventListener(this);
|
||||||
port.notifyOnDataAvailable(true);
|
|
||||||
//System.out.println("opening, ready to roll");
|
//System.out.println("opening, ready to roll");
|
||||||
}
|
} catch (SerialPortException e) {
|
||||||
}
|
throw new SerialException(I18n.format(_("Error opening serial port ''{0}''."),iname),e);
|
||||||
}
|
|
||||||
} catch (PortInUseException e) {
|
|
||||||
throw new SerialException(
|
|
||||||
I18n.format(
|
|
||||||
_("Serial port ''{0}'' already in use. Try quiting any programs that may be using it."),
|
|
||||||
iname
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SerialException(
|
|
||||||
I18n.format(
|
|
||||||
_("Error opening serial port ''{0}''."),
|
|
||||||
iname
|
|
||||||
),
|
|
||||||
e
|
|
||||||
);
|
|
||||||
// //errorMessage("<init>", e);
|
|
||||||
// //exception = e;
|
|
||||||
// //e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port == null) {
|
if (port == null) {
|
||||||
@ -221,18 +165,7 @@ public class Serial implements SerialPortEventListener {
|
|||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
try {
|
try {
|
||||||
// do io streams need to be closed first?
|
if (port != null) port.closePort(); // close the port
|
||||||
if (input != null) input.close();
|
|
||||||
if (output != null) output.close();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
input = null;
|
|
||||||
output = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (port != null) port.close(); // close the port
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -246,270 +179,34 @@ public class Serial implements SerialPortEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
synchronized public void serialEvent(SerialPortEvent serialEvent) {
|
public synchronized void serialEvent(SerialPortEvent serialEvent) {
|
||||||
//System.out.println("serial port event"); // " + serialEvent);
|
switch (serialEvent.getEventType()) {
|
||||||
//System.out.flush();
|
case SerialPortEvent.RXCHAR:
|
||||||
//System.out.println("into");
|
case SerialPortEvent.RXFLAG:
|
||||||
//System.out.flush();
|
|
||||||
//System.err.println("type " + serialEvent.getEventType());
|
|
||||||
//System.err.println("ahoooyey");
|
|
||||||
//System.err.println("ahoooyeysdfsdfsdf");
|
|
||||||
if (serialEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
|
|
||||||
//System.out.println("data available");
|
|
||||||
//System.err.flush();
|
|
||||||
try {
|
try {
|
||||||
while (input.available() > 0) {
|
byte[] bytes = port.readBytes();
|
||||||
//if (input.available() > 0) {
|
String bytesAsString = new String(bytes);
|
||||||
//serial = input.read();
|
if(monitor) {
|
||||||
//serialEvent();
|
System.out.print(bytesAsString);
|
||||||
//buffer[bufferCount++] = (byte) serial;
|
|
||||||
synchronized (buffer) {
|
|
||||||
if (bufferLast == buffer.length) {
|
|
||||||
byte temp[] = new byte[bufferLast << 1];
|
|
||||||
System.arraycopy(buffer, 0, temp, 0, bufferLast);
|
|
||||||
buffer = temp;
|
|
||||||
}
|
}
|
||||||
//buffer[bufferLast++] = (byte) input.read();
|
if (this.consumer != null) {
|
||||||
if(monitor == true)
|
this.consumer.message(bytesAsString);
|
||||||
System.out.print((char) input.read());
|
|
||||||
if (this.consumer != null)
|
|
||||||
this.consumer.message("" + (char) input.read());
|
|
||||||
|
|
||||||
/*
|
|
||||||
System.err.println(input.available() + " " +
|
|
||||||
((char) buffer[bufferLast-1]));
|
|
||||||
*/ //}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (SerialPortException e) {
|
||||||
//System.out.println("no more");
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
errorMessage("serialEvent", e);
|
errorMessage("serialEvent", e);
|
||||||
//e.printStackTrace();
|
|
||||||
//System.out.println("angry");
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//System.out.println("out of");
|
|
||||||
//System.err.println("out of event " + serialEvent.getEventType());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of bytes that have been read from serial
|
|
||||||
* and are waiting to be dealt with by the user.
|
|
||||||
*/
|
|
||||||
public int available() {
|
|
||||||
return (bufferLast - bufferIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ignore all the bytes read so far and empty the buffer.
|
|
||||||
*/
|
|
||||||
public void clear() {
|
|
||||||
bufferLast = 0;
|
|
||||||
bufferIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a number between 0 and 255 for the next byte that's
|
|
||||||
* waiting in the buffer.
|
|
||||||
* Returns -1 if there was no byte (although the user should
|
|
||||||
* first check available() to see if things are ready to avoid this)
|
|
||||||
*/
|
|
||||||
public int read() {
|
|
||||||
if (bufferIndex == bufferLast) return -1;
|
|
||||||
|
|
||||||
synchronized (buffer) {
|
|
||||||
int outgoing = buffer[bufferIndex++] & 0xff;
|
|
||||||
if (bufferIndex == bufferLast) { // rewind
|
|
||||||
bufferIndex = 0;
|
|
||||||
bufferLast = 0;
|
|
||||||
}
|
|
||||||
return outgoing;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the next byte in the buffer as a char.
|
|
||||||
* Returns -1, or 0xffff, if nothing is there.
|
|
||||||
*/
|
|
||||||
public char readChar() {
|
|
||||||
if (bufferIndex == bufferLast) return (char)(-1);
|
|
||||||
return (char) read();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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).
|
|
||||||
*/
|
|
||||||
public byte[] readBytes() {
|
|
||||||
if (bufferIndex == bufferLast) return null;
|
|
||||||
|
|
||||||
synchronized (buffer) {
|
|
||||||
int length = bufferLast - bufferIndex;
|
|
||||||
byte outgoing[] = new byte[length];
|
|
||||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
|
||||||
|
|
||||||
bufferIndex = 0; // rewind
|
|
||||||
bufferLast = 0;
|
|
||||||
return outgoing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Grab whatever is in the serial buffer, and stuff it into a
|
|
||||||
* byte buffer passed in by the user. This is more memory/time
|
|
||||||
* efficient than readBytes() returning a byte[] array.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
public int readBytes(byte outgoing[]) {
|
|
||||||
if (bufferIndex == bufferLast) return 0;
|
|
||||||
|
|
||||||
synchronized (buffer) {
|
|
||||||
int length = bufferLast - bufferIndex;
|
|
||||||
if (length > outgoing.length) length = outgoing.length;
|
|
||||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
|
||||||
|
|
||||||
bufferIndex += length;
|
|
||||||
if (bufferIndex == bufferLast) {
|
|
||||||
bufferIndex = 0; // rewind
|
|
||||||
bufferLast = 0;
|
|
||||||
}
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads from the serial port into a buffer of bytes up to and
|
|
||||||
* including a particular character. If the character isn't in
|
|
||||||
* the serial buffer, then 'null' is returned.
|
|
||||||
*/
|
|
||||||
public byte[] readBytesUntil(int interesting) {
|
|
||||||
if (bufferIndex == bufferLast) return null;
|
|
||||||
byte what = (byte)interesting;
|
|
||||||
|
|
||||||
synchronized (buffer) {
|
|
||||||
int found = -1;
|
|
||||||
for (int k = bufferIndex; k < bufferLast; k++) {
|
|
||||||
if (buffer[k] == what) {
|
|
||||||
found = k;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found == -1) return null;
|
|
||||||
|
|
||||||
int length = found - bufferIndex + 1;
|
|
||||||
byte outgoing[] = new byte[length];
|
|
||||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
|
||||||
|
|
||||||
bufferIndex = 0; // rewind
|
|
||||||
bufferLast = 0;
|
|
||||||
return outgoing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads from the serial port into a buffer of bytes until a
|
|
||||||
* particular character. If the character isn't in the serial
|
|
||||||
* buffer, then 'null' is returned.
|
|
||||||
*
|
|
||||||
* If outgoing[] is not big enough, then -1 is returned,
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
public int readBytesUntil(int interesting, byte outgoing[]) {
|
|
||||||
if (bufferIndex == bufferLast) return 0;
|
|
||||||
byte what = (byte)interesting;
|
|
||||||
|
|
||||||
synchronized (buffer) {
|
|
||||||
int found = -1;
|
|
||||||
for (int k = bufferIndex; k < bufferLast; k++) {
|
|
||||||
if (buffer[k] == what) {
|
|
||||||
found = k;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found == -1) return 0;
|
|
||||||
|
|
||||||
int length = found - bufferIndex + 1;
|
|
||||||
if (length > outgoing.length) {
|
|
||||||
System.err.println(
|
|
||||||
I18n.format(
|
|
||||||
_("readBytesUntil() byte buffer is too small for the {0}" +
|
|
||||||
" bytes up to and including char {1}"),
|
|
||||||
length,
|
|
||||||
interesting
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
//byte outgoing[] = new byte[length];
|
|
||||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
|
||||||
|
|
||||||
bufferIndex += length;
|
|
||||||
if (bufferIndex == bufferLast) {
|
|
||||||
bufferIndex = 0; // rewind
|
|
||||||
bufferLast = 0;
|
|
||||||
}
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return whatever has been read from the serial port so far
|
|
||||||
* as a String. It assumes that the incoming characters are ASCII.
|
|
||||||
*
|
|
||||||
* If you want to move Unicode data, you can 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.
|
|
||||||
*/
|
|
||||||
public String readString() {
|
|
||||||
if (bufferIndex == bufferLast) return null;
|
|
||||||
return new String(readBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Combination of readBytesUntil and readString. See caveats in
|
|
||||||
* each function. Returns null if it still hasn't found what
|
|
||||||
* you're looking for.
|
|
||||||
*
|
|
||||||
* If you want to move Unicode data, you can 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.
|
|
||||||
*/
|
|
||||||
public String readStringUntil(int interesting) {
|
|
||||||
byte b[] = readBytesUntil(interesting);
|
|
||||||
if (b == null) return null;
|
|
||||||
return new String(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will handle both ints, bytes and chars transparently.
|
* This will handle both ints, bytes and chars transparently.
|
||||||
*/
|
*/
|
||||||
public void write(int what) { // will also cover char
|
public void write(int what) {
|
||||||
try {
|
try {
|
||||||
output.write(what & 0xff); // for good measure do the &
|
port.writeInt(what & 0xff); // for good measure do the &
|
||||||
output.flush(); // hmm, not sure if a good idea
|
} catch (SerialPortException e) { // null pointer or serial port dead
|
||||||
|
|
||||||
} catch (Exception e) { // null pointer or serial port dead
|
|
||||||
errorMessage("write", e);
|
errorMessage("write", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -517,12 +214,9 @@ public class Serial implements SerialPortEventListener {
|
|||||||
|
|
||||||
public void write(byte bytes[]) {
|
public void write(byte bytes[]) {
|
||||||
try {
|
try {
|
||||||
output.write(bytes);
|
port.writeBytes(bytes);
|
||||||
output.flush(); // hmm, not sure if a good idea
|
} catch (SerialPortException e) {
|
||||||
|
errorMessage("write", e);
|
||||||
} catch (Exception e) { // null pointer or serial port dead
|
|
||||||
//errorMessage("write", e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,11 +238,19 @@ public class Serial implements SerialPortEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDTR(boolean state) {
|
public void setDTR(boolean state) {
|
||||||
|
try {
|
||||||
port.setDTR(state);
|
port.setDTR(state);
|
||||||
|
} catch (SerialPortException e) {
|
||||||
|
errorMessage("write", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRTS(boolean state) {
|
public void setRTS(boolean state) {
|
||||||
|
try {
|
||||||
port.setRTS(state);
|
port.setRTS(state);
|
||||||
|
} catch (SerialPortException e) {
|
||||||
|
errorMessage("write", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -557,33 +259,7 @@ public class Serial implements SerialPortEventListener {
|
|||||||
* Why the hell that'd be the case, who knows.
|
* Why the hell that'd be the case, who knows.
|
||||||
*/
|
*/
|
||||||
static public List<String> list() {
|
static public List<String> list() {
|
||||||
List<String> list = new ArrayList<String>();
|
return Arrays.asList(SerialPortList.getPortNames());
|
||||||
try {
|
|
||||||
//System.err.println("trying");
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
|
||||||
//System.err.println("got port list");
|
|
||||||
while (portList.hasMoreElements()) {
|
|
||||||
CommPortIdentifier portId =
|
|
||||||
(CommPortIdentifier) portList.nextElement();
|
|
||||||
//System.out.println(portId);
|
|
||||||
|
|
||||||
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
|
|
||||||
String name = portId.getName();
|
|
||||||
list.add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (UnsatisfiedLinkError e) {
|
|
||||||
//System.err.println("1");
|
|
||||||
errorMessage("ports", e);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
//System.err.println("2");
|
|
||||||
errorMessage("ports", e);
|
|
||||||
}
|
|
||||||
//System.err.println("move out");
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,9 +34,7 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import processing.app.I18n;
|
import processing.app.I18n;
|
||||||
import processing.app.Preferences;
|
import processing.app.Preferences;
|
||||||
import processing.app.Serial;
|
|
||||||
import processing.app.SerialException;
|
import processing.app.SerialException;
|
||||||
import processing.app.SerialNotFoundException;
|
|
||||||
|
|
||||||
public abstract class Uploader implements MessageConsumer {
|
public abstract class Uploader implements MessageConsumer {
|
||||||
static final String BUGS_URL =
|
static final String BUGS_URL =
|
||||||
@ -56,6 +54,7 @@ public abstract class Uploader implements MessageConsumer {
|
|||||||
|
|
||||||
public abstract boolean burnBootloader() throws RunnerException;
|
public abstract boolean burnBootloader() throws RunnerException;
|
||||||
|
|
||||||
|
/*
|
||||||
protected void flushSerialBuffer() throws RunnerException, SerialException {
|
protected void flushSerialBuffer() throws RunnerException, SerialException {
|
||||||
// Cleanup the serial buffer
|
// Cleanup the serial buffer
|
||||||
try {
|
try {
|
||||||
@ -85,6 +84,7 @@ public abstract class Uploader implements MessageConsumer {
|
|||||||
throw new RunnerException(e.getMessage());
|
throw new RunnerException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
protected boolean executeUploadCommand(Collection<String> commandDownloader)
|
protected boolean executeUploadCommand(Collection<String> commandDownloader)
|
||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
|
Reference in New Issue
Block a user