ChromeBook USB API

93 views
Skip to first unread message

jason wu

unread,
Aug 11, 2015, 11:16:09 PM8/11/15
to Chromium Apps
Hi, 
    I am using HP ChormeBook and want to try the sample code from here, the usb device_info. 
    but i am stuck on the function "chrome.usb.getDevices", seems like the function can run. 
    but always found 0 devices? I just copy all the files from the sample file. 
Thanks for the help.
    
    

jason wu

unread,
Aug 12, 2015, 2:17:40 AM8/12/15
to Chromium Apps
just passed last step. 
now stuck at 

chrome.usb.requestAccess(..)

this function can pass. but has no effect, 
so the next function chrome.usb.openDevice(...) will always fail. 
on chorme os only. 

why?

Reilly Grant

unread,
Aug 12, 2015, 2:00:46 PM8/12/15
to jason wu, Chromium Apps
What failure are you seeing? There should be a message in chrome.runtime.lastError.

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

jason wu

unread,
Aug 13, 2015, 3:31:17 AM8/13/15
to Chromium Apps, jason...@gmail.com
Actually there's no failing message. 
the sample I am trying to run is 

either function i am trying use to get a device handle is 
2. findDevice 
either of them not working? or I require to input instanceId? (does not know how to get this)
but the sample code is working on windows7 base
what i am trying to work out is on my 
HP chormeBook.  




Reilly Grant於 2015年8月13日星期四 UTC+8上午2時00分46秒寫道:

Reilly Grant

unread,
Aug 13, 2015, 2:17:42 PM8/13/15
to jason wu, Chromium Apps
There is no instanceId parameter in the USB API. I don't know where you got that. Every function will either provide the documented arguments or set chrome.runtime.lastError.

In the sample if opening the device fails the error is displayed. Does opening the device work in the sample?

jason wu

unread,
Aug 14, 2015, 2:41:38 AM8/14/15
to Chromium Apps, jason...@gmail.com
Let me try to explain the full story again.

I am trying to send some vendor command to my USB device under Chrome Book.

after doing a bit research, i tried to use the chrome.usb API from here.

https://developer.chrome.com/apps/app_usb

 

and I have found some samples from here.

https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/usb/device-info

 

the sample I have tried, both working on Windows7, and Ubutnu14, but NOT on chrome Book.

which Ubuntu14 need root privilege, normal mode will show "permission is denied." under chrome.runtime.lastError.message

so I reckon, if we can get enough privilege on Chrome Book? we can also access(unlock) the USB device from chrome api.

 


     Failed chrome book sample













Windows can work














Ubuntu can work.

jason wu

unread,
Aug 14, 2015, 2:46:20 AM8/14/15
to Chromium Apps, jason...@gmail.com

Forget to mentioned the code.

I fail at trying to open USB handle.

Doesn’t matter I am using either one, they failed

 

chrome.usb.openDevice(device, function(handle)

chrome.usb.findDevices({"vendorId": device.vendorId, "productId": device.productId}, function(handles)

 

chrome.usb.openDevice says “permission is denied”

and

chrome.usb.findDevices not return fail message, but the handles it has return, has 0 length.

Means nothing device is found. 




jason wu於 2015年8月14日星期五 UTC+8下午2時41分38秒寫道:

Reilly Grant

unread,
Aug 14, 2015, 1:59:25 PM8/14/15
to jason wu, Chromium Apps
From the screenshot on Windows it looks like the device is an audio device. This means that Chrome OS has a kernel driver loaded for the device. Devices with kernel drivers cannot be opened by the USB API on Chrome OS unless there is an interface that is not claimed by the kernel. Why are you trying to open the device with the USB API instead of using the getUserMedia API to playback or record audio from the device?

--

jason wu

unread,
Aug 18, 2015, 12:12:05 AM8/18/15
to Chromium Apps, jason...@gmail.com
Thanks for reply Reilly. 
That was a Genesys Hub device I am trying to open, the audio is just a sample. sorry for the confusion. 
what I am trying to do is to send some vendor command to the Genesys Hub. 
but at first we need to at least open the USB device. now the problem is the device cannot be open on ChromeOS. 


Reilly Grant

unread,
Aug 18, 2015, 3:48:54 PM8/18/15
to jason wu, Chromium Apps
For this to work the hub must implement these commands on a separate interface from the standard USB hub class implementation. This is done for system security, we don't want Chrome Apps interfering with existing kernel drivers.

jason wu

unread,
Aug 18, 2015, 10:29:15 PM8/18/15
to Chromium Apps, jason...@gmail.com
ok understand. 
Is there any sample i can find to implement those commands on separate interface?
so I can either. 
1. modify kernel driver to execute my genesys hub command on start up. 
2. do some special hub interface (need your help to tell me where is the sample ).
Thanks a lot for help!

Reilly Grant

unread,
Aug 19, 2015, 1:37:27 PM8/19/15
to jason wu, Chromium Apps
For 1, I suggest working on getting support for the command into the Linux kernel.
For 2, do you work for Genesys and have the ability to modify their hub firmware? Otherwise there's no hope of modifying the interfaces it provides.

--

jason wu

unread,
Aug 19, 2015, 10:13:49 PM8/19/15
to Chromium Apps, jason...@gmail.com
Yes I work for Genesys Logic, we could modify the hub firmware, 
i am thinking to trigger a vendor command to turn some effect on/off with 
chrome.usb.xxxx 


Reilly Grant於 2015年8月20日星期四 UTC+8上午1時37分27秒寫道:

Reilly Grant

unread,
Aug 21, 2015, 2:17:42 PM8/21/15
to jason wu, Chromium Apps
For this to work the device must be a composite device with two interfaces, one the standard hub interface and one for your effects. I don't know if hubs are allowed by the specification to be composite devices, so you may have to move the effect functionality into a separate device that is connected to the hub internally. I've seen examples of this (in USB Bluetooth controllers) where the device connection is actually virtual, no real hub port is used, but it allows the hub to have extra functionality not allowed by the specification.

Reply all
Reply to author
Forward
0 new messages