Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4375bdd5fe | ||
|
|
61f24738b4 | ||
|
|
71e1c20512 |
@@ -21,8 +21,8 @@ control. In addition, the library contains the following extensions:
|
||||
|
||||
## Versions
|
||||
|
||||
- Latest development version: **1.0.0-SNAPSHOT**
|
||||
- Latest production version: **none**
|
||||
- Latest development version: **1.0.2-SNAPSHOT**
|
||||
- Latest production version: **1.0.1**
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<packaging>pom</packaging>
|
||||
<name>SmartBotKit Serial</name>
|
||||
<description>SmartBotKit Serial Communication Library</description>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<version.android>4.4.2_r4</version.android>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>serial</artifactId>
|
||||
<groupId>com.smartbotkit</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>serial-android</artifactId>
|
||||
|
||||
@@ -100,9 +100,9 @@ public class CP210XSerialPort extends AbstractSerialPort {
|
||||
initConnection();
|
||||
try {
|
||||
throwIfNegative(sendControlTransfer(IFC_ENABLE, UART_ENABLE, null), "Failed to enable uart (error: %d).");
|
||||
throwIfNegative(initBaudRate(), "Failed to set baud rate (error: %d).");
|
||||
throwIfNegative(initParameters(), "Failed to set parameters (error: %d).");
|
||||
throwIfNegative(initFlowControl(), "Failed to set flow control (error: %d).");
|
||||
throwIfNegative(initBaudRate(), "Failed to set baud rate (error: %d).");
|
||||
} catch (IOException e) {
|
||||
close();
|
||||
throw e;
|
||||
@@ -116,8 +116,10 @@ public class CP210XSerialPort extends AbstractSerialPort {
|
||||
* @throws IOException Thrown if something fails.
|
||||
*/
|
||||
protected int initParameters() throws IOException {
|
||||
int config = getStopBits() | getDataBits() | getParity();
|
||||
return sendControlTransfer(SET_LINE_CTL, config, null);
|
||||
int value = getLineCtl();
|
||||
value &= ~0x05F3;
|
||||
value &= getStopBits() | getDataBits() | getParity();
|
||||
return sendControlTransfer(SET_LINE_CTL, value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +197,11 @@ public class CP210XSerialPort extends AbstractSerialPort {
|
||||
(byte) 0x00, (byte) 0x80, (byte) 0x00, (byte) 0x00,
|
||||
(byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x00
|
||||
};
|
||||
return sendControlTransfer(SET_FLOW, 0, dataOff);
|
||||
// work-around for RPLidar, don't set the flow control if it is off
|
||||
// TODO: check Linux driver to figure out how this should be done properly
|
||||
// see https://github.com/torvalds/linux/blob/master/drivers/usb/serial/cp210x.c
|
||||
//return sendControlTransfer(SET_FLOW, 0, dataOff);
|
||||
return 0;
|
||||
case DSR_DTR:
|
||||
byte[] dataDSRDTR = new byte[]{
|
||||
(byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0x00,
|
||||
@@ -228,8 +234,6 @@ public class CP210XSerialPort extends AbstractSerialPort {
|
||||
return Math.min(res, sendControlTransfer(SET_FLOW, 0, dataXONXOFF));
|
||||
}
|
||||
throw new IOException("Unsupported flow control configuration.");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>serial</artifactId>
|
||||
<groupId>com.smartbotkit</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>serial-core</artifactId>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>serial</artifactId>
|
||||
<groupId>com.smartbotkit</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>serial-rxtx</artifactId>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>serial</artifactId>
|
||||
<groupId>com.smartbotkit</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>serial-test</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user