目录

FAQs

Failed to Find the Header File During Compilation or Running

[h2]Symptom

The message "usb/usb_ddk_api.h not found" or "hid/hid_ddk_api.h not found" is displayed during compilation or running.

[h2]Solution

Version Mismatch Displayed During HAP Installation

[h2]Symptom

The message "compileSdkVersion and releaseType of the app do not match the apiVersion and releaseType on the device" is displayed during HAP installation.

[h2]Solution

Check whether the API version of the device SDK is supported. according to the mapping provided in Version Mapping.

[h2]Version Mapping

API Type Minimum API Version
Application development APIs (ArkTS APIs) API10
USB DDK APIs API10
HID DDK APIs API11

Failed to Parse the Local .so File During HAP Installation

[h2]Symptom

The message "code:9568347 error: install parse native so failed" is displayed during HAP installation.

[h2]Solution

The ABI type supported by the device does not match the ABI type configured in the C++ project. Follow the solution provided in bm tool error code 9568347. Run param get const.product.cpu.abilist through hdc shell to query the list of ABI types supported by the device, and configure the ABI types supported by the device in the abiFilters parameter of the module-level build-profile.json5.

HAP Installation Fails with Error 9568289 After the ohos.permission.ACCESS_DDK_DRIVERS Permission Is Granted

[h2]Symptom

The ACL permission ohos.permission.ACCESS_DDK_DRIVERS has been granted and packaged into the HAP application package along with the project, but the error "9568289 grant request permissions failed" is reported during HAP installation.

[h2]Solution

Currently, the application and operation process for the ohos.permission.ACCESS_DDK_DRIVERS permission in the application market is under maintenance. If your project uses the bindDriverWithDeviceId and unbindDriverWithDeviceId APIs, you can replace them with the bindDeviceDriver and unbindDevice APIs. The service functions of these APIs are exactly the same.

When Using a DDK API That Sends Data Based on a Buffer, Data Is Not Sent According to the Specified offset and bufferLength

[h2]Symptom

Take OH_Usb_SendPipeRequest as an example. When using this type of buffer-based data transfer API, even if the offset and bufferLength fields of UsbDeviceMemMap are set, the API actually sends the entire buffer based on the size value.

[h2]Solution

The implementation of such APIs uses the entire buffer for transmission according to size. Therefore, when sending a specific portion of data, apply for a buffer of the required size and fill it with the corresponding data to initiate the transmission. Refer to the implementation in the following code block. Note:

/**
 * Assume that data has been filled with valid data, deviceId is the ID of the corresponding peripheral, and pipe is the pipe information to be transferred.
 * Preset scenario: transfer the 32-byte data starting from index 0x10 in data.*/
 uint8_t *data = new uint8_t [128];

/** Create a data buffer. */
UsbDeviceMemMap *devMmap;
OH_Usb_CreateDeviceMemMap(deviceId, 32, &devMmap);

/** Copy only the data to be transferred to the buffer. */
memcpy(devMmap->address, data + 0x10, 32);

/** Initiate the data transfer. */
OH_Usb_SendPipeRequest(pipe, devMmap);

/** After use, destroy the data buffer to reclaim resources. */
OH_Usb_DestroyDeviceMemMap(devMmap);

Calling DDK C-APIs in a Child Process or a Non-Driver Ability Fails

[h2]Symptom

Calling the Driver Development Kit C-APIs in a child process created by a driver Ability or in a non-driver Ability process returns an abnormal error.

[h2]Solution

The C-APIs provided by the Driver Development Kit can be used only in the DriverExtension process. To manage and communicate with peripherals in other processes, use the APIs provided by @ohos.usbManager (USB Management), the libusb third-party library, and so on.

When Multiple Driver Abilities Are Configured for the Same Peripheral Device Model, Inserting the Device Supports Starting Only One Driver Ability

[h2]Symptom

A peripheral device of a certain model is configured in the "vids" and "pids" lists of multiple driver Abilities, but when the device is connected, only one driver Ability can be bound and started.

[h2]Solution

The driver Ability is designed to allow vendors to develop a single driver application for one or more peripheral device models. The specification does not support deploying multiple driver Abilities for the same peripheral device at the same time. A peripheral with the same VID/PID is associated with only one driver Ability. For example, a Ukey vendor provides a driver for online banking applications. If multiple online banking Ukey devices have the same VID/PID, the driver Abilities of these online banking applications cannot be started at the same time, and the current binding API does not distinguish driver Abilities with the same VID/PID. To encapsulate the functions of peripherals with the same VID/PID and provide them to multiple upstream applications, use @ohos.usbManager (USB Management) provided by the USB system service, or the libusb third-party library.