Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to read data from a USB device "connected to my PC" using tessel/node-usb in my electron application but i am not able to read anything or getting any error ! i am using following js :

function connectdevice(vID, pId){
var device = usb.findByIds(vID, pId);
device.open();
var deviceINTF=device.interface(0);
if (deviceINTF.isKernelDriverActive())
    deviceINTF.detachKernelDriver();
deviceINTF.claim();
var ePs = deviceINTF.endpoints;
var epIN;
$.each( ePs, function( index, ep ){
    if(ep.direction=="in"){
        epIN=ep;
if(epIN){
    epIN.on('data', function (data) {
        alert("1"+data);
    epIN.transferType = 2;
    alert("non empty port : "+epIN);
    epIN.transfer(64, function(error, data) {
        console.log(error, data); 
    alert("after transfer");
}else{
    alert("unable to read .."); 

The code has no issue but my device has 2 interfaces , and my code checking the first interface when i change this line code :

var deviceINTF=device.interface(0);
var deviceINTF=device.interface(1);

It works !

Hope this help anybody.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.