Adapting style, cleaning some stuff and implementing setRTS in every device driver

pull/23/head
Felipe Herranz 2016-01-15 19:03:37 +01:00
rodzic 9acaf1bd24
commit bbfd863828
8 zmienionych plików z 85 dodań i 46 usunięć

Wyświetl plik

@ -192,7 +192,13 @@ public class BLED112SerialDevice extends UsbSerialDevice
} }
@Override @Override
public void setRTS(boolean state)
{
//TODO
}
@Override
public void setFlowControl(int flowControl) public void setFlowControl(int flowControl)
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub

Wyświetl plik

@ -215,7 +215,13 @@ public class CDCSerialDevice extends UsbSerialDevice
} }
private int setControlCommand(int request, int value, byte[] data) @Override
public void setRTS(boolean state)
{
//TODO
}
private int setControlCommand(int request, int value, byte[] data)
{ {
int dataLength = 0; int dataLength = 0;
if(data != null) if(data != null)

Wyświetl plik

@ -242,8 +242,14 @@ public class CH34xSerialDevice extends UsbSerialDevice
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
private int init() @Override
public void setRTS(boolean state)
{
//TODO
}
private int init()
{ {
if(checkState("init #1", 0x5f, 0, new int[]{-1 /* 0x27, 0x30 */, 0x00}) == -1) if(checkState("init #1", 0x5f, 0, new int[]{-1 /* 0x27, 0x30 */, 0x00}) == -1)
{ {

Wyświetl plik

@ -27,7 +27,7 @@ public class CP2102SerialDevice extends UsbSerialDevice
private static final int CP210x_REQTYPE_DEVICE2HOST = 0xC1; private static final int CP210x_REQTYPE_DEVICE2HOST = 0xC1;
private static final int CP210x_MHS_RTS_ON = 0x202; private static final int CP210x_MHS_RTS_ON = 0x202;
private static final int CP210x_MHS_RTS_OFF = 0x200; private static final int CP210x_MHS_RTS_OFF = 0x200;
/*** /***
* Default Serial Configuration * Default Serial Configuration
@ -282,11 +282,15 @@ public class CP2102SerialDevice extends UsbSerialDevice
return; return;
} }
} }
public void setRTS(boolean state){ @Override
if(state){ public void setRTS(boolean state)
{
if(state)
{
setControlCommand(CP210x_SET_MHS, CP210x_MHS_RTS_ON, null); setControlCommand(CP210x_SET_MHS, CP210x_MHS_RTS_ON, null);
}else{ }else
{
setControlCommand(CP210x_SET_MHS, CP210x_MHS_RTS_OFF, null); setControlCommand(CP210x_SET_MHS, CP210x_MHS_RTS_OFF, null);
} }
} }

Wyświetl plik

@ -321,8 +321,14 @@ public class FTDISerialDevice extends UsbSerialDevice
break; break;
} }
} }
private int setControlCommand(int request, int value, int index, byte[] data) @Override
public void setRTS(boolean state)
{
//TODO
}
private int setControlCommand(int request, int value, int index, byte[] data)
{ {
int dataLength = 0; int dataLength = 0;
if(data != null) if(data != null)

Wyświetl plik

@ -279,9 +279,14 @@ public class PL2303SerialDevice extends UsbSerialDevice
// TODO // TODO
} }
@Override
private int setControlCommand(int reqType ,int request, int value, int index, byte[] data) public void setRTS(boolean state)
{
//TODO
}
private int setControlCommand(int reqType , int request, int value, int index, byte[] data)
{ {
int dataLength = 0; int dataLength = 0;
if(data != null) if(data != null)
@ -290,6 +295,4 @@ public class PL2303SerialDevice extends UsbSerialDevice
Log.i(CLASS_ID,"Control Transfer Response: " + String.valueOf(response)); Log.i(CLASS_ID,"Control Transfer Response: " + String.valueOf(response));
return response; return response;
} }
} }

Wyświetl plik

@ -8,44 +8,46 @@ package com.felhr.usbserial;
public interface UsbSerialInterface public interface UsbSerialInterface
{ {
// Common values // Common values
public static final int DATA_BITS_5 = 5; int DATA_BITS_5 = 5;
public static final int DATA_BITS_6 = 6; int DATA_BITS_6 = 6;
public static final int DATA_BITS_7 = 7; int DATA_BITS_7 = 7;
public static final int DATA_BITS_8 = 8; int DATA_BITS_8 = 8;
public static final int STOP_BITS_1 = 1; int STOP_BITS_1 = 1;
public static final int STOP_BITS_15 = 3; int STOP_BITS_15 = 3;
public static final int STOP_BITS_2 = 2; int STOP_BITS_2 = 2;
public static final int PARITY_NONE = 0; int PARITY_NONE = 0;
public static final int PARITY_ODD = 1; int PARITY_ODD = 1;
public static final int PARITY_EVEN = 2; int PARITY_EVEN = 2;
public static final int PARITY_MARK = 3; int PARITY_MARK = 3;
public static final int PARITY_SPACE = 4; int PARITY_SPACE = 4;
public static final int FLOW_CONTROL_OFF = 0; int FLOW_CONTROL_OFF = 0;
public static final int FLOW_CONTROL_RTS_CTS= 1; int FLOW_CONTROL_RTS_CTS= 1;
public static final int FLOW_CONTROL_DSR_DTR = 2; int FLOW_CONTROL_DSR_DTR = 2;
public static final int FLOW_CONTROL_XON_XOFF = 3; int FLOW_CONTROL_XON_XOFF = 3;
// Common Usb Serial Operations (I/O Asynchronous) // Common Usb Serial Operations (I/O Asynchronous)
public boolean open(); boolean open();
public void write(byte[] buffer); void write(byte[] buffer);
public int read(UsbReadCallback mCallback); int read(UsbReadCallback mCallback);
public void close(); void close();
// Serial port configuration // Serial port configuration
public void setBaudRate(int baudRate); void setBaudRate(int baudRate);
public void setDataBits(int dataBits); void setDataBits(int dataBits);
public void setStopBits(int stopBits); void setStopBits(int stopBits);
public void setParity(int parity); void setParity(int parity);
public void setFlowControl(int flowControl); void setFlowControl(int flowControl);
public void setRTS(boolean state);
// Flow control commands
void setRTS(boolean state);
// Usb Read Callback // Usb Read Callback
public interface UsbReadCallback interface UsbReadCallback
{ {
public void onReceivedData(byte[] data); void onReceivedData(byte[] data);
} }
} }

Wyświetl plik

@ -285,8 +285,14 @@ public class XdcVcpSerialDevice extends UsbSerialDevice
return; return;
} }
} }
private int setControlCommand(int request, int value, byte[] data) @Override
public void setRTS(boolean state)
{
//TODO
}
private int setControlCommand(int request, int value, byte[] data)
{ {
int dataLength = 0; int dataLength = 0;
if(data != null) if(data != null)