Skip to content

Commit f4889f0

Browse files
author
Mickael Storck
committed
Added setBreak method for CP21012 devices
1 parent d0232ed commit f4889f0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

usbserial/src/main/java/com/felhr/usbserial/CP2102SerialDevice.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class CP2102SerialDevice extends UsbSerialDevice
1919
private static final int CP210x_SET_BAUDDIV = 0x01;
2020
private static final int CP210x_SET_LINE_CTL = 0x03;
2121
private static final int CP210x_GET_LINE_CTL = 0x04;
22+
private static final int CP210X_SET_BREAK = 0x05;
2223
private static final int CP210x_SET_MHS = 0x07;
2324
private static final int CP210x_SET_BAUDRATE = 0x1E;
2425
private static final int CP210x_SET_FLOW = 0x13;
@@ -31,6 +32,9 @@ public class CP2102SerialDevice extends UsbSerialDevice
3132
private static final int CP210x_REQTYPE_HOST2DEVICE = 0x41;
3233
private static final int CP210x_REQTYPE_DEVICE2HOST = 0xC1;
3334

35+
private static final int CP210x_BREAK_ON = 0x0001;
36+
private static final int CP210x_BREAK_OFF = 0x0000;
37+
3438
private static final int CP210x_MHS_RTS_ON = 0x202;
3539
private static final int CP210x_MHS_RTS_OFF = 0x200;
3640
private static final int CP210x_MHS_DTR_ON = 0x101;
@@ -329,7 +333,11 @@ public void setFlowControl(int flowControl)
329333
@Override
330334
public void setBreak(boolean state)
331335
{
332-
//TODO Auto-generated method stub
336+
if (state) {
337+
setControlCommand(CP210X_SET_BREAK, CP210x_BREAK_ON, null);
338+
} else {
339+
setControlCommand(CP210X_SET_BREAK, CP210x_BREAK_OFF, null);
340+
}
333341
}
334342

335343
@Override

0 commit comments

Comments
 (0)