UsbSerial icon indicating copy to clipboard operation
UsbSerial copied to clipboard

Provide a default `device_filter.xml` resource

Open ge0rg opened this issue 8 years ago • 7 comments

The USB Host SDK provides an intent filter for USB attach events, that can be used to auto-launch your app when a certain USB device is attached.

It would be great to have such a device_filter.xml file as part of the usbserial source code (or even AAR), based on the vendor/product IDs supported by UsbSerial. It is possible to create a momentary snapshot of the supported IDs thanks to the consistent style in the deviceids directory, using this black magic incantation (you just need to mix in some XML boilerplate):

perl -lne 'print "\t<usb-device vendor-id=\"$1\" product-id=\"$2\" />" if /new ConcreteDevice.0x([0-9a-f]{4}), 0x([0-9a-f]{4})/i' java/com/felhr/deviceids/*.java

However, it would be nicer and cleaner to have the XML either auto-generated in the build process or (manually?) updated with new device IDs. It is probably also possible to replace many of the entries by a vendor/class or similar combination, instead of listing all supported IDs.

ge0rg avatar Feb 23 '16 18:02 ge0rg

I guess this would allow to auto open the serial port when the device is just connected. Am I right?

felHR85 avatar Mar 10 '16 07:03 felHR85

Exactly. If you have only one supporting app installed, it is opened directly; if you have multiple apps, you get a ttypical chooser intent dialog.

ge0rg avatar Mar 10 '16 07:03 ge0rg

This should be implemented by the application and not by the library. Including it by default would mean every app would have this behavior even if they didnt want it.

csobsidian avatar Jul 19 '16 19:07 csobsidian

The application needs to include a device filter XML for this feature to work. My suggestion is merely to provide such an XML file as part of the library, so that app developers have an easier time integrating.

ge0rg avatar Jul 29 '16 16:07 ge0rg

Indeed XML file(s) ready populated with the vid+pid pairs in the /java/com/felhr/deviceids namespace source files would be very handy.

bill-chadwick avatar Dec 14 '17 13:12 bill-chadwick

xml attached in text file below - created from sources off github

bill-chadwick avatar Dec 14 '17 14:12 bill-chadwick