Skip to content

Commit 37b2cde

Browse files
committed
SERIAL: Added extra logging to prevent timing-related crashes in specific apps.
1 parent 2c9f152 commit 37b2cde

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

modules/serial/ANDROID_java_additions

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)