kopia lustrzana https://github.com/felHR85/UsbSerial
Adapting style, cleaning some stuff and implementing setRTS in every device driver
rodzic
9acaf1bd24
commit
bbfd863828
|
@ -192,6 +192,12 @@ public class BLED112SerialDevice extends UsbSerialDevice
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRTS(boolean state)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlowControl(int flowControl)
|
||||
{
|
||||
|
|
|
@ -215,6 +215,12 @@ public class CDCSerialDevice extends UsbSerialDevice
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRTS(boolean state)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
private int setControlCommand(int request, int value, byte[] data)
|
||||
{
|
||||
int dataLength = 0;
|
||||
|
|
|
@ -243,6 +243,12 @@ public class CH34xSerialDevice extends UsbSerialDevice
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRTS(boolean state)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
private int init()
|
||||
{
|
||||
if(checkState("init #1", 0x5f, 0, new int[]{-1 /* 0x27, 0x30 */, 0x00}) == -1)
|
||||
|
|
|
@ -283,10 +283,14 @@ public class CP2102SerialDevice extends UsbSerialDevice
|
|||
}
|
||||
}
|
||||
|
||||
public void setRTS(boolean state){
|
||||
if(state){
|
||||
@Override
|
||||
public void setRTS(boolean state)
|
||||
{
|
||||
if(state)
|
||||
{
|
||||
setControlCommand(CP210x_SET_MHS, CP210x_MHS_RTS_ON, null);
|
||||
}else{
|
||||
}else
|
||||
{
|
||||
setControlCommand(CP210x_SET_MHS, CP210x_MHS_RTS_OFF, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -322,6 +322,12 @@ public class FTDISerialDevice extends UsbSerialDevice
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRTS(boolean state)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
private int setControlCommand(int request, int value, int index, byte[] data)
|
||||
{
|
||||
int dataLength = 0;
|
||||
|
|
|
@ -280,6 +280,11 @@ public class PL2303SerialDevice extends UsbSerialDevice
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRTS(boolean state)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
private int setControlCommand(int reqType , int request, int value, int index, byte[] data)
|
||||
{
|
||||
|
@ -290,6 +295,4 @@ public class PL2303SerialDevice extends UsbSerialDevice
|
|||
Log.i(CLASS_ID,"Control Transfer Response: " + String.valueOf(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,44 +8,46 @@ package com.felhr.usbserial;
|
|||
public interface UsbSerialInterface
|
||||
{
|
||||
// Common values
|
||||
public static final int DATA_BITS_5 = 5;
|
||||
public static final int DATA_BITS_6 = 6;
|
||||
public static final int DATA_BITS_7 = 7;
|
||||
public static final int DATA_BITS_8 = 8;
|
||||
int DATA_BITS_5 = 5;
|
||||
int DATA_BITS_6 = 6;
|
||||
int DATA_BITS_7 = 7;
|
||||
int DATA_BITS_8 = 8;
|
||||
|
||||
public static final int STOP_BITS_1 = 1;
|
||||
public static final int STOP_BITS_15 = 3;
|
||||
public static final int STOP_BITS_2 = 2;
|
||||
int STOP_BITS_1 = 1;
|
||||
int STOP_BITS_15 = 3;
|
||||
int STOP_BITS_2 = 2;
|
||||
|
||||
public static final int PARITY_NONE = 0;
|
||||
public static final int PARITY_ODD = 1;
|
||||
public static final int PARITY_EVEN = 2;
|
||||
public static final int PARITY_MARK = 3;
|
||||
public static final int PARITY_SPACE = 4;
|
||||
int PARITY_NONE = 0;
|
||||
int PARITY_ODD = 1;
|
||||
int PARITY_EVEN = 2;
|
||||
int PARITY_MARK = 3;
|
||||
int PARITY_SPACE = 4;
|
||||
|
||||
public static final int FLOW_CONTROL_OFF = 0;
|
||||
public static final int FLOW_CONTROL_RTS_CTS= 1;
|
||||
public static final int FLOW_CONTROL_DSR_DTR = 2;
|
||||
public static final int FLOW_CONTROL_XON_XOFF = 3;
|
||||
int FLOW_CONTROL_OFF = 0;
|
||||
int FLOW_CONTROL_RTS_CTS= 1;
|
||||
int FLOW_CONTROL_DSR_DTR = 2;
|
||||
int FLOW_CONTROL_XON_XOFF = 3;
|
||||
|
||||
// Common Usb Serial Operations (I/O Asynchronous)
|
||||
public boolean open();
|
||||
public void write(byte[] buffer);
|
||||
public int read(UsbReadCallback mCallback);
|
||||
public void close();
|
||||
boolean open();
|
||||
void write(byte[] buffer);
|
||||
int read(UsbReadCallback mCallback);
|
||||
void close();
|
||||
|
||||
// Serial port configuration
|
||||
public void setBaudRate(int baudRate);
|
||||
public void setDataBits(int dataBits);
|
||||
public void setStopBits(int stopBits);
|
||||
public void setParity(int parity);
|
||||
public void setFlowControl(int flowControl);
|
||||
public void setRTS(boolean state);
|
||||
void setBaudRate(int baudRate);
|
||||
void setDataBits(int dataBits);
|
||||
void setStopBits(int stopBits);
|
||||
void setParity(int parity);
|
||||
void setFlowControl(int flowControl);
|
||||
|
||||
// Flow control commands
|
||||
void setRTS(boolean state);
|
||||
|
||||
// Usb Read Callback
|
||||
public interface UsbReadCallback
|
||||
interface UsbReadCallback
|
||||
{
|
||||
public void onReceivedData(byte[] data);
|
||||
void onReceivedData(byte[] data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -286,6 +286,12 @@ public class XdcVcpSerialDevice extends UsbSerialDevice
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRTS(boolean state)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
private int setControlCommand(int request, int value, byte[] data)
|
||||
{
|
||||
int dataLength = 0;
|
||||
|
|
Ładowanie…
Reference in New Issue