Cloudbase
Posts: 2
Joined: Wed Aug 07, 2019 9:44 am

g_printer module

Wed Aug 07, 2019 9:53 am

Hi

I'm working on a project with the Pi Zero to sit between a device and its printer to process print data and decide what to do with it based on GPIO input to the pi, i.e. Device -> Pi Zero -> Printer/Cloud/Whatever

The point of the project is to be as universal as possible and require little to no setup on the host device. I've come across the g_printer module which I thought was the answer to all my problems, allowing the Pi to masquerade as a printer. However, it seems that actually interfacing with the Pi as a printer is a little more complicated than just "Add Printer", "Ctrl + P" etc.
So here are my questions:
1. Am I using the g_printer module wrong? Should it show up as a printer to the host system and not just a peculiar "software device"/is there more config with the module?
2. Can anyone suggest to me how I can make the Pi Zero show up to any host device as if it were an ordinary USB printer, i.e. exactly what I'm looking to do

Thanks in advance

P.S. Yes I know there are easier ways to print to a Pi, but the very nature of the project requires the Pi to:
1. Work over a USB interface
2. Require no setup on the Host System any more complicated than "Add Printer".

Aydan
Posts: 688
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: g_printer module

Wed Aug 07, 2019 11:47 am


hippy
Posts: 5770
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: g_printer module

Wed Aug 07, 2019 11:48 am

I have not used it but my understanding was a g_printer device plugged into a host would be automatically recognised as a printer, though it may need host drivers installing to be usable.

The problem here appears to be that the host is reporting it as being something other than a printer. That could either be because g_printer is not identifying itself properly or the host does not recognise that identification.

It would be worth saying what host device you have, reporting what information there is which the host has determined from the device. It might also be worth trying with other hosts, other host operating systems, in case it is just a peculiarity of that host or its OS.

OS's should prompt for drivers when needed but if not provided may default to "unknown device" or similar and stick with that even when drivers are made available. Something like that may have happened during experimentation and getting things to work. How to make an OS 'forget what it thinks it knows' will be OS specific.

incognitum
Posts: 306
Joined: Tue Oct 30, 2018 3:34 pm

Re: g_printer module

Wed Aug 07, 2019 12:00 pm

Keep in mind that there is no such thing as an "ordinary USB printer"
The way to send printer data over USB is standardized, but what exact format the data is in (e.g. Postscript, PCL) and what the other capabilities of the printer are (paper size, printable area, etc.) is not, and typically requires drivers.

If it's for your own personal use (and not for use in some commercial product), you can let g_printer pretend to be an existing printer the host operating system already supports by setting the right vendor/device ID.

hippy
Posts: 5770
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: g_printer module

Wed Aug 07, 2019 4:43 pm

incognitum wrote:
Wed Aug 07, 2019 12:00 pm
Keep in mind that there is no such thing as an "ordinary USB printer"
And even if there were it does not guarantee that every host would recognise it as such.

Take the networking and serial gadgets which have well defined functionality and protocols; some hosts may understand what they are, add them as available devices as one would expect, others, particularly older hosts, may not, will need additional drivers to turn what was detected into available and usable devices.

What one can or would expect depends on the host.

Cloudbase
Posts: 2
Joined: Wed Aug 07, 2019 9:44 am

Re: g_printer module

Wed Aug 14, 2019 9:16 am

Thank you all so much for your replies.
I had read the documentation but had skipped over the vendor/device id section :roll:
That sounds like it could be just the solution i’m looking for if I can fool the host into thinking it’s some other commercially available postscript printer. We’ll see how it goes anyways.
I’ll give it a go and post back here for reference.
Thanks again

BeauSlim
Posts: 46
Joined: Mon Jul 31, 2017 10:02 am

Re: g_printer module

Fri Aug 16, 2019 3:29 am

Hmm, this could enable some interesting things like "printing" over usb to a display or network connected eReader.

Return to “Advanced users”