Android Question Old issue about USB serial port ans allow access...

Pietro Pancino

Member
Licensed User
Longtime User
HI all,

Like in this post USB-device Trouble I have the same mistake: each time at power up, I have the same question "Allow the App XXX to access USB device?",

I tried all Erels post with the XML file and so on, not better. I tried it with all the libs ('fellusb", usbserial), libs are greats!
I have tested the app (see joined zip) on several platform under android, always the same mistake. It's like Android don't store the usb ID, and restart like if ti's a new interface.

I am working on a game with almost 20 computers and I wanted to use little board like Tinkerboard on Android in order to save money, but It's not possible for my customer to clic on on 20 checkboxs each morning !
The only platform where there is no problems is PC with B4J, but it's More expensive in computer ammount :(

Hopping some one has a solution... Before coding in B4J :)

:) Pietro
 

Attachments

  • pietro_UsbSerialDemo.zip
    10.8 KB · Views: 176
Last edited:

Pietro Pancino

Member
Licensed User
Longtime User
Hi,

I have modified the device_filter.xml to his simple expression acording to the develloper.android site, I have always the same mistake at power up.
My device_filte.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <usb-device vendor-id="9025" product-id="66" class="2" subclass="0" protocol="1" />
</resources>
My manifest:
manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
    
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.



AddActivityText(main, <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/device_filter" />)
        

CreateResource(xml, device_filter.xml,
<resources>
    <usb-device vendor-id="9025" product-id="66" class="2" subclass="0" protocol="1" />
</resources>
)

I am always obliged to accept to connect USB device.
At the begenning I had a lot of devices in the xml file, and finally I have reduced the device list to only one arduino usb device.
I was wondering if it was a mistake according to the serial library so I did two applications one with Fellusb and one with serialsub, same problem at power up.
Once the USB permission is accepeted, every thing is working very fine.

I don't understand wat's wrong ?
- We are running apps on android 7.1.1 and 7.1.2 maybe version are too old?
- Platforms are Tinkerboard or Santino.. maybe not compatible?
- does the permission is really stored in the system?
- In manifest for </intent-filter>... AddActivitytext or AddApplicationText ?

As JordiCP sujest I tried also to define vendor-id(and others) in hex like this 2341 and like this 0x2341 no change...

If there is no other solution I will communicate in Bluetooth, it's working, but I'm not sure that 20 boards communicating in BT will not raise other radio issues...

Tell-me :)
 
Last edited:
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Just a guess. Have you tried with the vendor-id and product-id hex values instead of the decimal ones? If they are compared as strings, it would make sense.

B4X:
CreateResource(xml, device_filter.xml,
<resources>
    ...
    <!-- 0x0403 / 0x6001: FTDI FT232R UART -->
    <!-- usb-device vendor-id="1027" product-id="24577" / -->
    <usb-device vendor-id="0403" product-id="6001" />
    ...
    ...
 
Upvote 0

Pietro Pancino

Member
Licensed User
Longtime User
Hi,

as I said in my last post I tried it always the same...

In case , I join the two applications working with the two libs, except the mistake at power up, test apps works, if some one like to have a look ?

:)
 

Attachments

  • USB_serial_USBserial_lib.zip
    11.4 KB · Views: 180
  • USB_serial_Fellusb_lib.zip
    11.4 KB · Views: 142
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
As JordiCP sujest I tried also to define vendor-id(and others) in hex like this 2341 and like this 0x2341 no change...
Just noticed the anti-causal reply ?



I think that I had an old app (based on the same USB-serial example) which worked with no issues. But now I don't remember if my only use-case was when I attached the USB once the device had booted. Will search for it later if the issue has not been resolved before.

So, when you say "at power-up", do you mean that you power-up the device with the USB attached? If this is the case, what happens if you just power it up (with no USB) and attach the USB later? I mean, perhaps the filter (in any of its dec/hex variants) is correctly defined and the problem is somewhere else.
 
Upvote 0

Pietro Pancino

Member
Licensed User
Longtime User
When I say power up, meens when the usb dongle is pluged on the device at power off.
AT device power on, android start, after I launch B4A bridge and after my app. At this moment I got the message box with:
"Allow the app start B4A xxxx to access the usb Device", with the check box "use by default this usb device".

I tried to plug the usb device manually after app start, still the same message box. :-(
 
Upvote 0

Pietro Pancino

Member
Licensed User
Longtime User
Well no more good ideas :(

I spend two day more to find a solution, nothing. Maybe the Android versions 7.1.x doesn't support this function and I have no other platform to test the apps.

Well I'm giving up ! I will devellope the app on B4J, so i'm sure that I'm not going to have problems.

Thank you EREL and JordiCP for your help!

See you soon....
 
Upvote 0
Top