Snapshot, replace tabs with spaces
This commit is contained in:
@@ -15,6 +15,15 @@ public abstract class AbstractArduino extends Listen<Object> implements Arduino
|
||||
|
||||
public AbstractArduino() {
|
||||
super(Worker.Type.DIRECT);
|
||||
listenList = new ArrayList<Listen<Object>>();
|
||||
}
|
||||
|
||||
public void register(Listen<Object> listen) {
|
||||
listenList.add(listen);
|
||||
}
|
||||
|
||||
public void remove(Listen<Object> listen) {
|
||||
listenList.remove(listen);
|
||||
}
|
||||
|
||||
public void start() {}
|
||||
|
||||
@@ -37,7 +37,6 @@ public class Local extends AbstractArduino {
|
||||
public void send(byte[] buffer) throws ArduinoException {
|
||||
try {
|
||||
outputStream.write(buffer);
|
||||
outputStream.flush();
|
||||
} catch (IOException e) {
|
||||
throw new ArduinoException("Failed to write to arduino");
|
||||
}
|
||||
|
||||
@@ -27,6 +27,6 @@ public class ParsingPort extends Port {
|
||||
for (Listen<Object> listen : listenList) {
|
||||
listen.add(object);
|
||||
}
|
||||
} catch (Exception e) {} catch (Throwable e) {} finally {}
|
||||
} catch (Exception e) {} catch (Throwable e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Port implements SerialPortEventListener {
|
||||
if (portid.getName().equals(portName) || portid.getName().contains(portName)) {
|
||||
try {
|
||||
serialPort = (SerialPort) portid.open("", TIME_OUT);
|
||||
serialPort.setSerialPortParams(19200, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
|
||||
serialPort.setSerialPortParams(4800, 8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
|
||||
serialPort.setFlowControlMode(
|
||||
SerialPort.FLOWCONTROL_XONXOFF_IN +
|
||||
SerialPort.FLOWCONTROL_XONXOFF_OUT);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.github.boukefalos.arduino.port;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
import purejavacomm.SerialPortEvent;
|
||||
import base.work.Listen;
|
||||
|
||||
public class StringPort extends Port {
|
||||
public static Port getInstance() {
|
||||
if (port == null) {
|
||||
port = new StringPort();
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
public void serialEvent(SerialPortEvent event) {
|
||||
Scanner scanner = new Scanner(inputStream);
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
for (Listen<Object> listen : listenList) {
|
||||
listen.add(line);
|
||||
}
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user