Expose uhk.sendUsbPackets() and implement uhk.sendUsbPacket() based on it.

This commit is contained in:
László Monda
2017-01-15 03:51:00 +01:00
parent a826bd25cb
commit e2002dd63b

View File

@@ -75,12 +75,12 @@ function sendUsbPacketsByCallback(packetProvider) {
}
function sendUsbPacket(packet) {
let isPacketSent = false;
sendUsbPackets([packet]);
}
function sendUsbPackets(packets) {
sendUsbPacketsByCallback(() => {
if (!isPacketSent) {
isPacketSent = true;
return packet;
}
return packets.shift();
})
}
@@ -89,6 +89,7 @@ exports = module.exports = {
bufferToString,
getUsbEndpoints,
sendUsbPacket,
sendUsbPackets,
sendUsbPacketsByCallback,
usbCommands: {
getProperty: 0,