Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4375bdd5fe | ||
|
|
61f24738b4 | ||
|
|
71e1c20512 |
@@ -21,8 +21,8 @@ control. In addition, the library contains the following extensions:
|
|||||||
|
|
||||||
## Versions
|
## Versions
|
||||||
|
|
||||||
- Latest development version: **1.0.0-SNAPSHOT**
|
- Latest development version: **1.0.2-SNAPSHOT**
|
||||||
- Latest production version: **none**
|
- Latest production version: **1.0.1**
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>SmartBotKit Serial</name>
|
<name>SmartBotKit Serial</name>
|
||||||
<description>SmartBotKit Serial Communication Library</description>
|
<description>SmartBotKit Serial Communication Library</description>
|
||||||
<version>1.0.0</version>
|
<version>1.0.1</version>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<version.android>4.4.2_r4</version.android>
|
<version.android>4.4.2_r4</version.android>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>serial</artifactId>
|
<artifactId>serial</artifactId>
|
||||||
<groupId>com.smartbotkit</groupId>
|
<groupId>com.smartbotkit</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.1</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>serial-android</artifactId>
|
<artifactId>serial-android</artifactId>
|
||||||
|
|||||||
@@ -100,9 +100,9 @@ public class CP210XSerialPort extends AbstractSerialPort {
|
|||||||
initConnection();
|
initConnection();
|
||||||
try {
|
try {
|
||||||
throwIfNegative(sendControlTransfer(IFC_ENABLE, UART_ENABLE, null), "Failed to enable uart (error: %d).");
|
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(initParameters(), "Failed to set parameters (error: %d).");
|
||||||
throwIfNegative(initFlowControl(), "Failed to set flow control (error: %d).");
|
throwIfNegative(initFlowControl(), "Failed to set flow control (error: %d).");
|
||||||
throwIfNegative(initBaudRate(), "Failed to set baud rate (error: %d).");
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
close();
|
close();
|
||||||
throw e;
|
throw e;
|
||||||
@@ -116,8 +116,10 @@ public class CP210XSerialPort extends AbstractSerialPort {
|
|||||||
* @throws IOException Thrown if something fails.
|
* @throws IOException Thrown if something fails.
|
||||||
*/
|
*/
|
||||||
protected int initParameters() throws IOException {
|
protected int initParameters() throws IOException {
|
||||||
int config = getStopBits() | getDataBits() | getParity();
|
int value = getLineCtl();
|
||||||
return sendControlTransfer(SET_LINE_CTL, config, null);
|
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) 0x80, (byte) 0x00, (byte) 0x00,
|
||||||
(byte) 0x00, (byte) 0x20, (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:
|
case DSR_DTR:
|
||||||
byte[] dataDSRDTR = new byte[]{
|
byte[] dataDSRDTR = new byte[]{
|
||||||
(byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0x00,
|
(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));
|
return Math.min(res, sendControlTransfer(SET_FLOW, 0, dataXONXOFF));
|
||||||
}
|
}
|
||||||
throw new IOException("Unsupported flow control configuration.");
|
throw new IOException("Unsupported flow control configuration.");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>serial</artifactId>
|
<artifactId>serial</artifactId>
|
||||||
<groupId>com.smartbotkit</groupId>
|
<groupId>com.smartbotkit</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.1</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>serial-core</artifactId>
|
<artifactId>serial-core</artifactId>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>serial</artifactId>
|
<artifactId>serial</artifactId>
|
||||||
<groupId>com.smartbotkit</groupId>
|
<groupId>com.smartbotkit</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.1</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>serial-rxtx</artifactId>
|
<artifactId>serial-rxtx</artifactId>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>serial</artifactId>
|
<artifactId>serial</artifactId>
|
||||||
<groupId>com.smartbotkit</groupId>
|
<groupId>com.smartbotkit</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.1</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>serial-test</artifactId>
|
<artifactId>serial-test</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user