Hi
I have an Ubuntu laptop and a Android 9 Tablet (Samsung Active 2). The tablet is connected to the laptop with FTDI connectors and a NULL cable. The code to connect to the laptop through the FTDI connectors and NULL cable is below:
I have the following in my manifest.xml
I have the following device filter under res/
This is the logcat output, including the exception:
Edit:
This is my rules files for USB devices (/etc/udev/rules.d/my-newrule.rules):
Any suggestions as to how to fix this would be appreciated.
Thanks...
I have an Ubuntu laptop and a Android 9 Tablet (Samsung Active 2). The tablet is connected to the laptop with FTDI connectors and a NULL cable. The code to connect to the laptop through the FTDI connectors and NULL cable is below:
Java:
import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbManager;
import com.hoho.android.usbserial.driver.UsbSerialDriver;
import com.hoho.android.usbserial.driver.UsbSerialPort;
import com.hoho.android.usbserial.driver.UsbSerialProber;
.
.
.
try
{
UsbManager usbManager = (UsbManager) view.getContext().getSystemService(Context.USB_SERVICE);
if( usbManager != null )
{
Log.i("USB COMMS USBMANAGER", usbManager.toString());
Map<String, UsbDevice> deviceList = usbManager.getDeviceList();
Log.i("USB COMMS DeviceList Size: ", String.valueOf(deviceList.size()));
UsbSerialDriver usbDriver = null;
UsbSerialPort usbPort = null;
UsbDeviceConnection usbConnection = null;
for( UsbDevice usbDevice : deviceList.values() )
{
Log.i("USB COMMS UsbDevice: ", usbDevice.toString());
String deviceName = usbDevice.getManufacturerName();
Log.i("USB COMMS deviceName: ", deviceName);
if( deviceName.toLowerCase().contains("ftdi") )
{
usbDriver = UsbSerialProber.getDefaultProber().probeDevice(usbDevice);
Log.i("USB COMMS driver: ", usbDriver.toString());
usbConnection = usbManager.openDevice(usbDriver.getDevice());
if( usbConnection != null ) {
Log.i("USB COMMS connection: ", usbConnection.toString());
usbPort = usbDriver.getPorts().get(0);
Log.i("USB COMMS port: ", usbPort.toString());
usbPort.open(usbConnection);
Log.i("USB COMMS port is open ", "");
usbPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE);
}
else
{
Log.i("USB COMMS connection is null", "");
}
break;
}
}
if( usbPort != null )
{
Log.i("USB COMMS calling SerialMsgThread with port: ", usbPort.toString());
SerialMsgThread st = new SerialMsgThread(usbPort, mapView);
st.start();
}
else
{
Log.i("SerialMsgThread ", "USBSerialDriver is Null");
}
}
else
{
Log.i("USB COMMS USBMANAGER", "IS NULL");
}
}
catch(Exception e)
{
Log.i("USB COMMS EXCEPTION: ", e.toString());
}
I have the following in my manifest.xml
HTML:
<service
android:name="com.android.notification.NotificationService"
android:label="Plugin Notification Service">
<intent-filter>
<action android:name="com.android.notification.NotificationService"/>
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/accessory_filter" />
</service>
I have the following device filter under res/
HTML:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- The following is the FTDI parameters -->
<usb-device vendor-id="1027" product-id="24577" model="FT232" manufacturer="FTDI" version="6.0"/>
</resources>
This is the logcat output, including the exception:
Java:
2020-11-24 08:22:28.599 1578-1578/Â USBÂ COMMSÂ USBMANAGER: android.hardware.usb.UsbManager@7de64a6
2020-11-24 08:22:28.601 1578-1578/ USB COMMS DeviceList Size:: 1
2020-11-24 08:22:28.606 1578-1578/Â USBÂ COMMSÂ UsbDevice:: UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=1027,mProductId=24577,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=FTDI,mProductName=USB Serial Converter,mVersion=6.00,mSerialNumber=FTBVMD1M,mConfigurations=[
'-->UsbConfiguration[mId=1,mName=null,mAttributes=160,mMaxPower=22,mInterfaces=[
'-->UsbInterface[mId=0,mAlternateSetting=0,mName=USB Serial Converter,mClass=255,mSubclass=255,mProtocol=255,mEndpoints=[
'-->UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=64,mInterval=0]
'-->UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=64,mInterval=0]]]]
2020-11-24 08:22:28.606 1578-1578/Â USBÂ COMMSÂ deviceName:: FTDI
2020-11-24 08:22:28.612 1578-1578/Â USBÂ COMMSÂ driver:: com.hoho.android.usbserial.driver.FtdiSerialDriver@abf9ee7
2020-11-24 08:22:28.617 1578-1578/ E/UsbManager: exception in UsbManager.openDevice
java.lang.SecurityException: User has not given permission to device UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=1027,mProductId=24577,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=FTDI,mProductName=USB Serial Converter,mVersion=6.00,mSerialNumber=FTBVMD1M,mConfigurations=[
UsbConfiguration[mId=1,mName=null,mAttributes=160,mMaxPower=22,mInterfaces=[
UsbInterface[mId=0,mAlternateSetting=0,mName=USB Serial Converter,mClass=255,mSubclass=255,mProtocol=255,mEndpoints=[
UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=64,mInterval=0]
UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=64,mInterval=0]]]]
at android.os.Parcel.createException(Parcel.java:1966)
at android.os.Parcel.readException(Parcel.java:1934)
at android.os.Parcel.readException(Parcel.java:1884)
at android.hardware.usb.IUsbManager$Stub$Proxy.openDevice(IUsbManager.java:614)
at android.hardware.usb.UsbManager.openDevice(UsbManager.java:791)
at android.view.View.performClick(View.java:7348)
at android.widget.TextView.performClick(TextView.java:14215)
at android.view.View.performClickInternal(View.java:7314)
at android.view.View.access$3200(View.java:846)
at android.view.View$PerformClick.run(View.java:27803)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7179)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.usb.UsbUserSettingsManager.checkPermission(UsbUserSettingsManager.java:243)
at com.android.server.usb.UsbHostManager.openDevice(UsbHostManager.java:560)
at com.android.server.usb.UsbService.openDevice(UsbService.java:368)
at android.hardware.usb.IUsbManager$Stub.onTransact(IUsbManager.java:70)
at android.os.Binder.execTransact(Binder.java:739)
Edit:
This is my rules files for USB devices (/etc/udev/rules.d/my-newrule.rules):
Code:
KERNEL=="ttyACM0", MODE="0777"
KERNEL=="ttyUSB0", MODE="0777"
Any suggestions as to how to fix this would be appreciated.
Thanks...
Last edited: