Created
January 3, 2021 20:38
-
-
Save teezzan/cb6866372d9130ef10b343e09cc785fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let usb = require('usb') | |
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 .."); | |
} | |
} | |
connectdevice(325, 18) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment