ProgrammingPescador
Posts: 1
Joined: Sat Aug 05, 2017 12:00 pm

libusb, node.js zebra printer

Sat Aug 05, 2017 12:10 pm

Hi

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
device.open();
The debug output is
Debugger listening on ws://127.0.0.1:31919/b862b060-27ed-4186-943e-2d483978a2a8
Debugger attached.
Error: LIBUSB_ERROR_ACCESS
at Device.usb.Device.open (/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
lsusb
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

TIA

User avatar
topguy
Posts: 3293
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.
https://stackoverflow.com/questions/405 ... udev-rules

Return to “Java”

Who is online

Users browsing this forum: No registered users and 2 guests