0

Reposting from https://groups.google.com/a/chromium.org/d/topic/chromium-apps/noGfn29Aed8/discussion for public reply.

I'm trying to develop a chrome app to communicate with an HID using the chrome.usb API. I am using these functions.

  1. chrome.usb.findDevices
  2. chrome.usb.controlTransfer

What I've tried so far does not work. The info in chrome://device-log/ shows this error message.

USB     Event   [13:54:01] Failed to open device: Entity not found

I am using right VendorId and ProductId in decimal format, Which I have extracted from device manager info.

Here is the code snippet I am using.

chrome.usb.findDevices(DEVICE_INFO, function (devices) {
    if (!devices || !devices.length) {
        console.log('device not found');
    }

    console.log("Devices: " + devices);
    console.log(devices[0]);

    var TransferData = {
       "requestType": "class",
       "recipient": "interface",
       "direction": "out",
       "request": 0xx9,
       "value": 0xxx0,
       "index": 0,
       "data": new Uint8Array([00,05, 47, 76, 66, 48, 47,00]).buffer
    };


    setTimeout(function () {
        chrome.usb.controlTransfer(devices[0], TransferData, function (config) {
            if (chrome.runtime.lastError) {
                console.log(chrome.runtime.lastError);
            } else {
                console.log('Data Transfer completed');
            }
        });
    }, 3000);
});

1 Answer 1

1

I see two issues in your question.

  1. Check your vendor/product ids. You said you had decimal ids but the DEVICE_INFO definition is missing. I see in the snippet of code that you're using 0xx9 in the request field of TransferData which is not a valid hex literal. Are you doing the same thing in the DEVICE_INFO? If the vid is 1234 decimal, make sure you're not saying 0x1234.

  2. There are separate chrome. APIs for USB and HID. I'm pretty sure the USB interface will not allow you to manipulate devices that advertise as HID. You must instead use the chrome.hid interface for these devices.

There are a few questions here that could have some helpful info for you:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.