File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,19 @@ class RS232Manager implements Runnable{
9292 return -1;
9393 }
9494 UsbSerialDriver mSerialDriver = availableDrivers.get(0);
95- UsbDeviceConnection mDeviceConnection = mUsbManager.openDevice(mSerialDriver.getDevice());
95+ android.hardware.usb.UsbDevice mUsbDevice = mSerialDriver.getDevice();
96+
97+ for (int i = 0; i < mUsbDevice.getInterfaceCount(); i++) {
98+ boolean success;
99+ if(mUsbDevice.getInterface(i) == null) {
100+ success = false;
101+ } else {
102+ success = true;
103+ }
104+ Log.d("RS232Manager", Integer.toString(i) + Boolean.toString(success));
105+ }
106+
107+ UsbDeviceConnection mDeviceConnection = mUsbManager.openDevice(mUsbDevice);
96108 if (mDeviceConnection == null) {
97109 return -1;
98110 }
@@ -185,10 +197,15 @@ class RS232Manager implements Runnable{
185197 }
186198 }
187199 public void setrts(int dev,boolean val){
188- try {
189- mSerialPort.setRTS(val);
190- } catch (IOException e){
191- Log.d("RS232Manager","Exception: "+e);
200+ Log.i("RS232Manager","Setting RTS");
201+ if(mSerialPort != null) {
202+ try {
203+ mSerialPort.setRTS(val);
204+ } catch (IOException e){
205+ Log.d("RS232Manager","Exception: "+e);
206+ }
207+ } else {
208+ Log.e("RS232Manager","null Serial Port");
192209 }
193210 }
194211}
You can’t perform that action at this time.
0 commit comments