Update CP2102SerialDevice.java

Added method that allows RTS line to be turned on and off. Modified dataRTSCTS byte array to allow the RTS line to be toggled.
pull/22/head
Junaid Khan 2016-01-14 12:04:10 +00:00
rodzic 23c79aa6d8
commit eae5b705e2
1 zmienionych plików z 12 dodań i 1 usunięć

Wyświetl plik

@ -26,6 +26,9 @@ public class CP2102SerialDevice extends UsbSerialDevice
private static final int CP210x_REQTYPE_HOST2DEVICE = 0x41;
private static final int CP210x_REQTYPE_DEVICE2HOST = 0xC1;
private static final int CP210x_MHS_RTS_ON = 0x202;
private static final int CP210x_MHS_RTS_OFF = 0x200;
/***
* Default Serial Configuration
* Baud rate: 9600
@ -245,7 +248,7 @@ public class CP2102SerialDevice extends UsbSerialDevice
case UsbSerialInterface.FLOW_CONTROL_RTS_CTS:
byte[] dataRTSCTS = new byte[]{
(byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x80, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x00
};
@ -280,6 +283,14 @@ public class CP2102SerialDevice extends UsbSerialDevice
}
}
public void setRTS(boolean state){
if(state){
setControlCommand(CP210x_SET_MHS, CP210x_MHS_RTS_ON, null);
}else{
setControlCommand(CP210x_SET_MHS, CP210x_MHS_RTS_OFF, null);
}
}
private int setControlCommand(int request, int value, byte[] data)
{
int dataLength = 0;