node usb can't claim interface on OSX

Hi jkridner,
As I can see in BBBlfs code for OSX, a codeless kext is written to claim the interface first before the kernel driver binds it. Can we just write c code to implement the kext and claim the interface and then allow node-usb to claim the interface through node.js server ? Can you test this ?
Also do checkout these workarounds for node-usb on OSX first at https://github.com/tessel/node-usb/issues/61
Thanks
Ravi Kumar Prasad (ravikp7)

Hi jkridner,
As I can see in BBBlfs code for OSX, a codeless kext is written to claim the interface first before the kernel driver binds it. Can we just write c code to implement the kext and claim the interface and then allow node-usb to claim the interface through node.js server ? Can you test this ?

If you give me the code, I will build and run it.

I am pretty sure I avoided the kernel grabbing it, but not 100% sure. If a kext is required, please provide.

If we have a working C module that is portable, we can simply write a node module to be able to add it to etcher.io and other tools via npm.

Also do checkout these workarounds for node-usb on OSX first at https://github.com/tessel/node-usb/issues/61

Can you break down specifics for me to try in the email threads?

Hi jkridner,
As I can see in BBBlfs code for OSX, a codeless kext is written to claim the interface first before the kernel driver binds it. Can we just write c code to implement the kext and claim the interface and then allow node-usb to claim the interface through node.js server ? Can you test this ?

If you give me the code, I will build and run it.

I am pretty sure I avoided the kernel grabbing it, but not 100% sure. If a kext is required, please provide.

I’ll try and extract it from BBBlfs OSX code and give it as a c module.

If we have a working C module that is portable, we can simply write a node module to be able to add it to etcher.io and other tools via npm.

Also do checkout these workarounds for node-usb on OSX first at https://github.com/tessel/node-usb/issues/61

Can you break down specifics for me to try in the email threads?

Sure, here’s first one Calling the semi-private __open() and __claimInterface() functions before the public open function seems to jiggle it into a position where it works.

this.open = function(callback) {
console.log(‘opening device’)
_device = usb.findByIds(0x132b, 0x2101);

_device.__open();
_device.__claimInterface(0);

_device.open();

_ifc = _device.interface();

_ifc.claim();

_wep = _ifc.endpoint(0x02);
_rep = _ifc.endpoint(0x82);

if (callback) callback(null, ‘OK’);

};

Second one,

added the following line in usb.js (line 26) in the open prototype after the this.__open() call (line 25):

    this.__claimInterface(0);  

and it solved the issue.

Hi Jason,
This file .travis.yml at https://github.com/ungureanuvladvictor/BBBlfs/tree/osx describes how to build the codeless kext. Please give it a try now, I’ll prepare the timeline in proposal accordingly. If libusb can claim the interface in OSX then node-usb can too as it just binds libusb.