Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. USB Device not found
Forum Updated to NodeBB v4.3 + New Features

USB Device not found

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 286 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi

    I am new to Qt and Android development so please be kind.

    I am trying to talk to a USB device using Qt and LibUsb-1.0.23.

    I have set up the AndroidManifest as follows and the USB device is detected and the application automatically opened upon connecting the USB device so all good.
    I also have 'Serial USB Terminal' installed which can see the device has the correct VID and PID as defined in the device_filter.xml.

    However the call to libusb_get_device_list always returns 0.

    Is there some other android access/permission setting I am missing?
    Any help greatly appreciated as I have spent a lot of time on this. TIA

    <?xml version="1.0"?>
    <manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
    <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
    Remove the comment if you do not require these default permissions. -->
    <!-- %%INSERT_PERMISSIONS -->
    <uses-permission android:name="android.permission.USB_PERMISSION"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
         Remove the comment if you do not require these default features. -->
    <!-- %%INSERT_FEATURES -->
    <uses-feature android:name="android.hardware.usb.host"/>
    
    <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
    <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:extractNativeLibs="true">
        <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
            </intent-filter>
            <!-- Application arguments -->
            <!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
            <!-- Application arguments -->
            <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter"/>
            <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
    

    Calling code from Qt
    // get list of usb
    libusb_context* context;
    int result = libusb_init (&context);
    if (result < 0)
    {
    restartOk = false;
    qDebug() <<"UNABLE_INITAILIZE_LIBUSB";
    }

    ssize_t cnt; // holding number of devices in list
    libusb_device **list_of_devices;
    cnt = libusb_get_device_list(context, &list_of_devices);
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved