Emulated_USB_Printer icon indicating copy to clipboard operation
Emulated_USB_Printer copied to clipboard

Raspberry Pi 4 - Problems with accessing /dev/g_printer0

Open RWAP opened this issue 4 years ago • 16 comments

On a Raspberry Pi 4B, I have used this code and have the USB-OTG port correctly configured to emulate an Epson TM-T88V printer. The host machine recognises the Raspberry Pi as the Epson printer.

Unfortunately, I have hit a problem.

I have the code running in /home/pi/software, and the compiled program has chown root:root on it.

If I use:

fd[0].fd = open(PRINTER_FILE, O_RDWR);

I get an error - cannot open /dev/g_printer0 (it shows in the /dev directory though)

If I change this to: fd[0].fd = open(PRINTER_FILE, O_RDONLY);

or do a CHMOD 777 on /dev/g_printer0, the code opens the device successfully.

However, I get errors when polling the device - errno = 2 (No such file or directory)

Any ideas - could it be a cabling issue?

RWAP avatar Jul 19 '21 12:07 RWAP

Hi, nice seeing you are playing around with this as well :) Mentioned you and your product a few times in my thesis! Sadly I never had the chance to play around with the RPI 4B. My first guess was that there is a second device descriptor which has a similar name like g_printer0. The original documentation mentions "/dev/g_printer" as the device descriptor.

I tested it with the RPI Zero WH having Linux raspberrypi 5.4.83+ armv6l installed. Dunno if the RPI 4B can run this version. I wouldn't think it's cabeling as the host seems to detect the pi correctly as a printer.

Maybe I will find some time this weekend to try myself. Also, it would be pretty cool if would share the parameters for the emulation of the Epson TM-T88V printer, but of course you don't have to ;)

Really interested in the implementation using the Raspberry Pi 4B!!

Raspberryy avatar Jul 19 '21 13:07 Raspberryy

So far as I can tell, the Raspberry Pi only supports /dev/g_printer0

I would be interested to read your thesis some time :)

RWAP avatar Jul 19 '21 17:07 RWAP

Hi :) Did you get any further? Thesis is in german :( Sorry about that.

Raspberryy avatar Aug 19 '21 17:08 Raspberryy

Has anyone got any further with getting this to successfully run on the Raspberry Pi 4 so that a host computer still believes the original USB printer is connected?

RWAP avatar Mar 02 '22 21:03 RWAP

So last year I got the Pi to emulate an Epson printer and managed to connect it to a Windows till system which recognised it as the Epson printer. I was then able to print out till receipts directly to the Pi and read them from /dev/g_printer0. Unfortunately, I don't remember how I got this to work and after putting the project down for a couple weeks and coming back to it I wasn't able to replicate my previous success. I appreciate that this isn't the most helpful comment but there is some light at the end of this tunnel 😂

bcheidemann avatar Mar 03 '22 08:03 bcheidemann

Hi Rasperryy, Can you please help to configure and make it work Raspberry pi 4 ?

yuvarajan-prs avatar Nov 22 '22 06:11 yuvarajan-prs

HI @yuvarajan-prs , unfortunately I don't have a Pi4 ready for testing. Have you tried it yet? Where do you get stuck?

Raspberryy avatar Nov 22 '22 20:11 Raspberryy

Awesome repo , thanks for all the work you put into it

@RWAP any chance you still have the epson vid,pid and ipnp string still

Would save me having to buy a unit just to replace it with this code on a cm4

letis009 avatar Jan 30 '23 19:01 letis009

All I have is :

modprobe g_printer idVendor=0x04b8 idProduct=0x0e02 bcdDevice="256" iManufacturer="EPSON" iProduct="TM-T88V" iSerialNum="405139460344080000" iPNPstring="MFG:EPSON;CMD:ESC/POS;MDL:TM-T88V;CLS:PRINTER;DES:EPSON TM-T88V;CID:EpsonTM00000001;"

I never got this to work reliably on a Pi 4 though

RWAP avatar Jan 31 '23 08:01 RWAP

You are the man

letis009 avatar Jan 31 '23 09:01 letis009

Cool! Thanks for sharing :) I will add it to the repo too. If you have any additional connection details, please share them with us '-'

Raspberryy avatar Jan 31 '23 11:01 Raspberryy

Did anyone manage to get this working on a Pi 4? I've tried everything I can think of. It worked on a zero but I really need a wired ethernet connection....

davidgarratt avatar Apr 25 '23 08:04 davidgarratt

Interestingly, it has worked randomly twice. I am currently wondering about power consumption.... Will try a powered hub (plugged into the computer not the pi)

davidgarratt avatar Apr 25 '23 13:04 davidgarratt

Hi there! Unfortunately I didn't have time to try and use the RaspberryPi4 yet. You will definitely not be able to power the RPI 4 per USB2 Bus though, that's for sure. Please keep me updated with your findings once you use an external Power Supply. Also, please share your printer parameters (vendorID, iPNPstring, ...) with us here, that is always helpful!

Raspberryy avatar Apr 25 '23 15:04 Raspberryy

Did anyone manage to get this working on a Pi 4? I've tried everything I can think of. It worked on a zero but I really need a wired ethernet connection....

If everything else fails, maybe there is an adapter for the RaspberryPi Zero for Ethernet?

Raspberryy avatar Apr 25 '23 15:04 Raspberryy

I have an ENC28J60 on the way to try and do that over SPI.....

Weirdly, I've ended up with one SD card that seems to work (with the pi4). I have no idea why. I'm currently taking a backup of it in case I break it! I've even managed to convert the .bin data to html using this project: https://github.com/receipt-print-hq/escpos-tools/blob/master/doc/esc2html.md I'm using the parameters for an Epson TM-T88V above.

Using a powered hub (well my docking station) didn't help :(

Will keep the group posted on progress

davidgarratt avatar Apr 25 '23 16:04 davidgarratt