Snapshot, replace tabs with spaces

This commit is contained in:
2015-09-01 13:19:40 +01:00
parent 394a413691
commit 46b377bf9a
10 changed files with 291 additions and 257 deletions

View File

@@ -15,6 +15,15 @@ public abstract class AbstractArduino extends Listen<Object> implements Arduino
public AbstractArduino() { public AbstractArduino() {
super(Worker.Type.DIRECT); 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() {} public void start() {}

View File

@@ -37,7 +37,6 @@ public class Local extends AbstractArduino {
public void send(byte[] buffer) throws ArduinoException { public void send(byte[] buffer) throws ArduinoException {
try { try {
outputStream.write(buffer); outputStream.write(buffer);
outputStream.flush();
} catch (IOException e) { } catch (IOException e) {
throw new ArduinoException("Failed to write to arduino"); throw new ArduinoException("Failed to write to arduino");
} }

View File

@@ -27,6 +27,6 @@ public class ParsingPort extends Port {
for (Listen<Object> listen : listenList) { for (Listen<Object> listen : listenList) {
listen.add(object); listen.add(object);
} }
} catch (Exception e) {} catch (Throwable e) {} finally {} } catch (Exception e) {} catch (Throwable e) {}
} }
} }

View File

@@ -75,7 +75,7 @@ public class Port implements SerialPortEventListener {
if (portid.getName().equals(portName) || portid.getName().contains(portName)) { if (portid.getName().equals(portName) || portid.getName().contains(portName)) {
try { try {
serialPort = (SerialPort) portid.open("", TIME_OUT); 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.setFlowControlMode(
SerialPort.FLOWCONTROL_XONXOFF_IN + SerialPort.FLOWCONTROL_XONXOFF_IN +
SerialPort.FLOWCONTROL_XONXOFF_OUT); SerialPort.FLOWCONTROL_XONXOFF_OUT);

View File

@@ -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();
}
}