2

Is there any way to send data to USB port like echo "hello world!" > /dev/usb/lp1?

Edit

I've been using label printers from different brands by only issuing some simple EPL commands:

sR
q455
Q479,010
D8
S3
JF
ZB
OD
TDdd.mn.y4
N
GG15,40,"LOGO1"
A180,181,0,3,1,1,N,TT
A165,321,0,3,1,1,N,TD
P1

I can print a label from printer by sending this string to /dev/usb/lp1.

I can also use continuous printers by issuing echo "hello world!" > /dev/usb/lp1 in order to print a line.

https://github.com/tessel/node-usb seems very complex to me. There is no example in their home page either.

I need to send data like I can use serial port, by only a few additional parameters like manufacturer id/serial number or physical port number, like I would find out with lsusb.

Is there any library that meets these simplicity requirements?

ceremcem
  • 3,900
  • 4
  • 28
  • 66
  • What have you tried so far? Check out https://www.npmjs.com/package/usb and see if that helps. – Fabian Schultz Jan 09 '17 at 17:07
  • 1
    You'll have to be more specific about exactly what type of USB device you have and what kind of data you are trying to send to it. Different USB devices have different protocols and drivers, and the appropriate way to send data depends on those details. – David Grayson Jan 09 '17 at 17:55

1 Answers1

0

no, USB is more complex than serial port RS232 because it has more functionality than RS232. however if you have a USB CDC ACM class on your device you can have a virtual com port, emulating RS232. this would be the easiest solution. if not you have to send data to endpoints of the usb device via bulk transfer or other type of usb transfers (isochronous,...)

in How to send data to USB device in node.js using libusb is a node-usb example (https://github.com/tessel/node-usb), see also USB in a nutshell

Community
  • 1
  • 1
ralf htp
  • 9,149
  • 4
  • 22
  • 34