Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/dist
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<pathelement path="${classpath}"/>
<pathelement path="${build}"/>
<pathelement location="lib/jssc-2.8.0.jar"/>
<pathelement location="lib/slf4j-api-1.7.2.jar"/>
</path>

<target name="clean">
Expand Down
Binary file added lib/slf4j-api-1.7.2.jar
Binary file not shown.
16 changes: 9 additions & 7 deletions src/de/fischl/usbtin/USBtin.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jssc.SerialPort;
import jssc.SerialPortException;
import jssc.SerialPortTimeoutException;
Expand All @@ -38,6 +38,8 @@
*/
public class USBtin implements SerialPortEventListener {

private final Logger logger = LoggerFactory.getLogger(USBtin.class);

/** Serial port (virtual) to which USBtin is connected */
protected SerialPort serialPort;

Expand Down Expand Up @@ -234,15 +236,15 @@ public void openCANChannel(int baudrate, OpenMode mode) throws USBtinException {

this.transmit("s" + String.format("%02x", brpopt | 0xC0) + String.format("%04x", cnfvalues[xopt - 11]));

System.out.println("No preset for given baudrate " + baudrate + ". Set baudrate to " + (FOSC / ((brpopt + 1) * 2) / xopt));
logger.info("No preset for given baudrate {}. Set baudrate to {}", baudrate, (FOSC / ((brpopt + 1) * 2) / xopt));

}

// open can channel
char modeCh;
switch (mode) {
default:
System.err.println("Mode " + mode + " not supported. Opening listen only.");
logger.warn("Mode {} not supported. Opening listen only.", mode);
case LISTENONLY: modeCh = 'L'; break;
case LOOPBACK: modeCh = 'l'; break;
case ACTIVE: modeCh = 'O'; break;
Expand Down Expand Up @@ -353,7 +355,7 @@ public void serialEvent(SerialPortEvent event) {
try {
sendFirstTXFifoMessage();
} catch (USBtinException ex) {
System.err.println(ex);
logger.warn("Error on CAN bus, {}", ex);
}


Expand All @@ -367,7 +369,7 @@ public void serialEvent(SerialPortEvent event) {
try {
sendFirstTXFifoMessage();
} catch (USBtinException ex) {
System.err.println(ex);
logger.warn("Error on CAN bus, {}", ex);
}

} else if (b != '\r') {
Expand All @@ -376,7 +378,7 @@ public void serialEvent(SerialPortEvent event) {
}
}
} catch (SerialPortException ex) {
System.err.println(ex);
logger.warn("Error on CAN bus, {}", ex);
}
}
}
Expand Down