node-escpos / driver

🖨️ ESC/POS Printer driver for Node.js.
Other
287 stars 27 forks source link

Raspberry Pi support #95

Open gongiskhan opened 2 months ago

gongiskhan commented 2 months ago

Hi,

Thanks for the great project!

I successfully implemented invoice printing in my project on a mac. However, on raspberry pi it does not seem to work. Seems it's not supported, which is fair enough, but if you could please confirm if that is the case that would be awesome. Thanks!

e Error: LIBUSB_ERROR_ACCESS at Device.open (/home/ggomes/dev/scuver-rest/node_modules/usb/dist/usb/device.js:63:14) at USBAdapter.open (/home/ggomes/dev/scuver-rest/node_modules/@node-escpos/usb-adapter/dist/index.cjs:87:18) at printEscpos (/home/ggomes/dev/scuver-rest/print.js:48:16) at /home/ggomes/dev/scuver-rest/print.js:40:12 at cors (/home/ggomes/dev/scuver-rest/node_modules/cors/lib/index.js:188:7) at /home/ggomes/dev/scuver-rest/node_modules/cors/lib/index.js:224:17 at originCallback (/home/ggomes/dev/scuver-rest/node_modules/cors/lib/index.js:214:15) at /home/ggomes/dev/scuver-rest/node_modules/cors/lib/index.js:219:13 at optionsCallback (/home/ggomes/dev/scuver-rest/node_modules/cors/lib/index.js:199:9) at corsMiddleware (/home/ggomes/dev/scuver-rest/node_modules/cors/lib/index.js:204:7) { errno: -3

dosubot[bot] commented 2 months ago

Hello, @gongiskhan! I'm a bot here to help you with bugs, questions, and becoming a contributor. Let's work on resolving your issue together.

Yes, Raspberry Pi is supported for this project. To resolve the LIBUSB_ERROR_ACCESS error, you need to ensure that you have the necessary permissions to access the USB device. This typically involves setting up udev rules on your Raspberry Pi.

Here is a step-by-step guide to resolve the LIBUSB_ERROR_ACCESS error:

  1. Create a udev rule: Create a new udev rule file for your printer. You can do this by creating a file in the /etc/udev/rules.d/ directory. For example, create a file named 99-usb-printer.rules:

    sudo nano /etc/udev/rules.d/99-usb-printer.rules
  2. Add the udev rule: Add the following line to the file, replacing 1234 and 5678 with your printer's vendor ID (VID) and product ID (PID):

    SUBSYSTEM=="usb", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", MODE="0666", GROUP="plugdev"

    You can find the VID and PID of your printer using the lsusb command.

  3. Reload udev rules: After saving the file, reload the udev rules:

    sudo udevadm control --reload-rules
    sudo udevadm trigger
  4. Add your user to the plugdev group: Ensure that your user is part of the plugdev group:

    sudo usermod -aG plugdev $USER
  5. Reboot your Raspberry Pi: Finally, reboot your Raspberry Pi to apply the changes:

    sudo reboot

After following these steps, you should have the necessary permissions to access the USB printer, and the LIBUSB_ERROR_ACCESS error should be resolved [1].

To continue talking to Dosu, mention @dosu.