Posts: 14
Joined: Sat Aug 05, 2017 12:00 pm
Location: UK

libusb, node.js zebra printer

Sat Aug 05, 2017 12:10 pm


I have a Zebra printer that I wish to send ZPL/EPL commands to from my Node.js program. I am using libusb and have stumbled at the first hurdle, when I attempt to open the device I get LIBUSB_ERROR_ACCESS. I have had a quick google and a few things have come up regarding permissions etc but nothing that gives me an exact answer!!

I am running the script in debug mode in Code - OSS logged in as the pi user. The code is as below;

Code: Select all

var usb = require('usb');

// get the device
var device = usb.findByIds(0x0A5F, 0x0080);

// open the device to allow the device to be used;
The debug output is
Debugger listening on ws://
Debugger attached.
at (/home/pi/Printing/node_modules/usb/usb.js:33:7)
at Object.<anonymous> (/home/pi/Printing/index.js:7:8)
at Module._compile (module.js:566:14)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3

My understanding from looking the libusb documentation is that the device needs to be opened before the interface can be accessed and claimed, is this correct?

The libusb command output is
Bus 001 Device 006: ID 0a5f:0080 Zebra
Bus 001 Device 005: ID 1c4f:0027 SiGma Micro
Bus 001 Device 004: ID 1c4f:0065 SiGma Micro
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast

The ProgrammingPescador

User avatar
Posts: 5320
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: libusb, node.js zebra printer

Sun Aug 06, 2017 10:06 pm

You should try to start the script with sudo and see if the problem goes away.

Or you can change the permissions on the device itself. ... udev-rules

Return to “Java”