Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Created January 23, 2021 14:32
Show Gist options
  • Save apaleslimghost/f367e489e2af46640652076a2e77eea4 to your computer and use it in GitHub Desktop.
Save apaleslimghost/f367e489e2af46640652076a2e77eea4 to your computer and use it in GitHub Desktop.
const { usb } = require('webusb')
async function initPrinter() {
const printer = await usb.requestDevice({
filters: [
{
vendorId: 0x0416,
productId: 0x5011
}
]
})
await printer.open();
await printer.selectConfiguration(1)
await printer.claimInterface(0)
await printer.controlTransferOut({
requestType: 'class',
recipient: 'interface',
request: 0x22,
value: 0x01,
index: 0
})
return data => printer.transferOut(1, data)
}
module.exports = initPrinter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment