Raspberryy / Emulated_USB_Printer

Using a Raspberry Pi Zero to emulate a USB-Printer
GNU General Public License v3.0
77 stars 14 forks source link

Unable to start emulated printing #9

Open ozgith opened 9 months ago

ozgith commented 9 months ago

Hello,

I followed the instructions on a pi zero 2 w and then on a pi zero w, but I get the error message:

[!] Error -1 opening /dev/g_printer [*] Printer status Printer is Selected Paper is Out Printer OK

Similar to: sudo ./emulatedprinter -read_data [!] Error -1 opening /dev/g_printer [] Printer status Printer is Selected Paper is Out Printer OK [] Start reading printjobs [!] Error -1 opening /dev/g_printer

I see g_printer0 under my /dev

my printer.c has

define PRINTER_FILE "/dev/g_printer0"

define BUF_SIZE 512

define PRINTJOB_FILE_EXTENSION "pcl"

define GPDL_BIN_FILE "/home/default/Downloads/ghostpdl-10.2.1/bin/gpdl"

define GPDL_SDEVICE_METHOD "pdfwrite"

define GPDL_FILE_EXTENSION "pdf"

My os is: Linux HPLaserJet 6.1.0-rpi7-rpi-v6 #1 Raspbian 1:6.1.63-1+rpt1 (2023-11-24) armv6l GNU/Linux

Can you help me figuring out what am I missing?

Raspberryy commented 9 months ago

Hey, that's interesting. Can you please share the idVendor, idProduct and the pnp_string you are using for printer emulation? Trying to split potential error sources here:

  1. Have you made sure the "dtoverlay=dwc2,dr_mode=peripheral" is added to the config.txt?
  2. Does your printer emulation works? E.g. try typing "make stop" followed by "make startRicohAficio1224C" or any other of the preconfigured printers in case you have none. Does the host recognize the printer correctly?
  3. If both of the above works, have you tried using the printer_minimal.c? Do you see any other device descriptor with a similar name to "g_printer0" in your dev directory? Try using these as well to see if they work.

Let me know if any of these solved it or if none did :)

Raspberryy commented 9 months ago

@ozgith Also, see this thread too, the last user reported that updating the system and running as root helped. Also try adding permission as described within the same thread https://github.com/Raspberryy/Emulated_USB_Printer/issues/6

ozgith commented 9 months ago

Unfortunately I was unable to resolve the “[!] Error -1 opening /dev/g_printer” issue with my Rasberry Pi 2 Zero even after following your above instructions. So config.ext had the dtoverlay, g_printer0 line, but seems like emulatedprinter is unable to access that.

So I borrowed an older device, a Rasberry Pi Zero which is what you used. I went with the same OS version you used, 5.4.83 + armv6l and compiled emulatedprinter per your instructions.

I added my vendor string “sudo modprobe g_printer idVendor=0x4F9h idProduct=0x3C9h bcdDevice="256" iManufacturer="Brother" iProduct="MFC-J985DW" iSerialNum="U24350E7H606151" iPNPstring="MFG:Brother;CMD:HBP,BRPJL,URF;MDL:MFCJ985DW;CLS:PRINTER;CID:Brother Generic Jpeg Type2;URF:SRGB24,W8,CP1,IS1,MT1-8-11,OB9,PQ4-5,RS200-300,OFU0,V1.4,DM3;"

and I was able to have emulatedprinter capture the PCL files I sent to my Brother printer. Many thanks for writing this tool!

I then decided to upgrade the OS to the latest one to see if the problem is with the new OS. Upgrade went well, but I am again stuck at the same problem that I mentioned above on this tread. Somehow, on Rasberry OS V6 does not play well with access g_printer. I checked the permissions on g_printer on both OS, it is crw——— on both. I suspect there is an issue with the g_printer module that comes with the newer Pi Os, but I don’t know what else to look for. Do you have any other advice to make this work on the latest OS?