How to allow CUPs to wake up printer once when in standby? - printing

I an bringing up my home print server using RaspberryPi+CUPs
MY printer is HP Laserjet MTF m1212nf.
Apprently, I I was able to setup everything good enough to be able sending jobs over the network and get them printed.
However, one problem i am running into is that once I leave the printer Idle for some time, it seems to go into kinda standby mode (kinda power-saving mode) and then jobs i send show as completed in the CUPs interface, but they never get to be printed on paper.
From this point, the way to resume printing is to shut off and then on the printer and then things work again until next go into power saving mode.

What you look for is Tea4Cups, which is a bridge beetween commands and cups.
For installation on RPi see here: (step 1-3) https://github.com/Felixel42/Printer-Pi-DCP-115C#tea4cups
Prefix your printer line i.e. smb://yourprinter so that it looks like that
tea4cups:/smb://yourprinter
The configuration file is at /etc/cups/tea4cups.conf
A minimal example is
[global]
directory : /var/spool/cups/ #you might need to adjust this
prehook_0 : wakeonlan yourmac #or whatever command you want to execute

Related

Networked program has problem "waking up" HP printer to print

I am writing some software that tries to print via IPP to typical HP laser printers like the M605, for example, and it is having a hard time "waking up" the printer sometimes. What happens is that the software tries to connect to the printer's IP address on the local network (10.1.10.185 or whatever) and gets a "No route to host" error. If the user tries several times in a row, eventually the printer "wakes up" and begins responding.
I notice that regular Linux or Window programs that print to the printer do not seem to have this problem. So, either they are not using IP/networked printing or they have some way to deal with the "sleeping" problem that I am not aware of. I suppose I could put a tap on the ethernet cord, and print from a Windows program and see what it is doing, but that would be a very time consuming and laborious procedure.
Does anybody know what I am doing wrong here? Is there some way to wake up a printer via its internet connectivity access protocol?
One thing I noticed in one person's code is that they had a 30-second timeout specified on the connect, so that may be the issue, is that my connection timeout is just not what it should be. In that case, is there an established timeout period for waking up HP printers?

Is it possible to access a Chromebook via ssh through USB?

My employer has asked me to prepare for testing several thousand Chromebooks (mix of models/manufacturers) to refurb/flip. This may be a recurring thing.
Most or all of these will be old enough that CCD will not be available. I'd like to connect a widget such as a Raspberry Pi to the USB and have it automate testing as much as possible.
I know I can use keyboard emulation to inject commands, but I'd like to get a crosh session running over USB so that I can read info from the DUT besides just controlling it.
Google shows bazillions of returns about using a Chromebook as an ssh terminal but what I'm looking for is the opposite. I'm prepared for the answer to be a simple "no" but I'm concerned because I can't find that anyone else has asked this question. I don't think I'm that creative, so I suspect my Goog-fu is weak.
The answer appears to be "no". However I solved it another way; using "gadget mode" I have a Raspberry Pi ZW enumerate as a keyboard and a serial port. I put the Chromebook into Developer mode, open a developer shell with ctrl/alt/F2, or on a PC/linux or Mac system open a terminal window and type "sudo su" (these have to be done manually). Then I have the RPi issue this bash command to identify the serial port "in the blind":
SERPORT=/dev/serial/by-id/$(ls /dev/serial/by-id) # Chromebook or PC/linux
(or)
SERPORT=$(ls /dev/cu.usbmodem*) # Mac
Now I can have the RPi inject commands via the keyboard, put ">$SERPORT" on the end of each command, and the output comes in the RPi gadget serial port. The RPi then packages the data and forwards it over WiFi to our CRM. It's working nicely for Chromebooks, PCs booted into linux, Mac desktops and Macbooks.
Edit:
The company I work for has actually turned this into a product and so I'm not sure how much detail I should share, but...
I learned my way around gadget mode on the RPi from this link. There are examples for setting up a keyboard and a serial port. Using the templates in that link, I made a device called /dev/hidg0 which emits keyboard scancodes from the RPi to the Chromebook. I also made a device called /dev/ttyGS0 which the Chromebook sees as a serial port.
So I send keystrokes with some python like:
with open("/dev/hidg0","bw") as hid:
hid.write(blah)
and then have the Chromebook send text to the serial port, which I then read by looking at /dev/ttyGS0
Hopefully this will be enough to get you started. I found the isticktoit link very helpful.

Simulate Printer Errors / Printed Pages Signals

I'm testing software that sends jobs to the printer queue and then rises a flag when they are successfully printed. It also needs to detect how many pages printed correctly in a failed job.
Although there are many "Virtual Printers" out there, they all process their jobs perfectly... And that's the problem.
Is there a printer simulator that can provide with control over the signals it sends back to the windows spooler, such as printed pages, out of paper errors, paper jams, etc?
I'm not interested in the raw output the printer driver handles to the printer, but rather the signals the driver passes back to the windows' spooler.

How to build a virtual printer?

I'm trying to build a virtual printer.
There are already some answers like this and this.
However my demand is more specific. I just want to create a virtual printer that can be added into the system and can be accessed from any application. On clicking print command, a dialog looks like a real printer pops out and generates a PDF on printing. Then some more actions, like pushing the PDF to my server, are performed.
Do I need to dig into Windows Driver Kit? Or is there any free SDK for this?
Thanks.
Not sure if this question is still relevant to you, but you'd probably want to think about something like this:
Use the WDK (Windows Driver Kit) to create a Unidrv UI plugin. This will allow you to specify UI during the print (for your printer dialogue). The reason why you'd want to show UI here is because it's one of the only printer driver components that runs in the user session (the same process as the printing application). The XPS pipeline and port monitor are both session 0.
If you want to stick to MS convention, you'll do the spool file to PDF conversion in the render filter of the XPS Filter pipeline (this is if you're using an XPSDrv driver). The filter pipeline is where you have the opportunity to modify the XPS spool data coming in and in the final filter, convert it to your output document type (PDF in your case).
To do post print processing, you might want to consider creating a port monitor (again with the WDK) and kicking off a new process to do the post print processing after the port monitor writes out the print output to disk.
Only problem with this approach is that you can't use port monitors in Version 4 drivers (this is the new type of driver in Windows 8). Version 3 drivers still work in Win 8, but I guess they'll be phased out eventually.
Sorry it's probably not very obvious, but as I say, it's a high level overview (and unfortunately driver development is still very complex beyond a simple print to file). Version 4 printer drivers are becoming a lot easier to develop, but unfortunately with the removal of port monitor support and other improvements, it makes it a lot harder to develop anything requiring post processing.
[DISCLAIMER: I'm associated with the Mako SDK R&D team]
I know you asked for a free SDK, unfortunately I don't know of anything that would be suitable, but I know our company offer a Virtual Printer Platform (SDK) which would be good for you (prints to PDF and supports post print processing). You can find more information at the Mako SDK website
Hope this helps a bit anyway. I know printer driver development can be very confusing at times!
After reading up and doing a lot of research, with the aim to setup up something like redmon and use the printer SDK, I have completed the project using this SDK: http://www.novapdf.com/pdf-sdk.html
This solution however will work with windows only.
[I am not affiliated with novaPDF]
I have investigated an OSX version, however this will be a different build, you can probably set something up using this method: http://www.jms1.net/osx-pdf-services.shtml [I have not yet tried this]

Intercept Print Jobs

We have some computers on which we charge for printing documents. When a user prints, I would like to intercept the print job, prompt them for their username / password so I can charge their account, then allow the print job to continue through to the printer.
How can this be accomplished? Is it possible to write such a utility in .NET?
You really need to look at creating a Port Monitor for this. Far from simple. You could look at RedMon. BTW: Many printer vendors offer solutions to this which use codes that are embedded into the print stream (PCL/PS) and the data is collected and retained on the printer.
For example, Xerox has something called Standard Accounting. When enabled in the driver it embeds PJL codes like this:
#PJL COMMENT OID_ATT_ACCOUNTING_INFORMATION_AVP "XRX_USERID,xxxx";
Once the job has been printed the device makes reference to the user, number of pages etc. which can then be reported on.
The problem you will run into when doing this on the workstation / server is that detecting the number of pages printed can be difficult. If you are trying, for example, to charge by the page you might be able to parse the number of pages from the file, or run through a PCL or PS RIP and determine but if they have a flag for 2up or 4up on the page and that work is done by the printer and not the driver, you will charge the client for 4 pages when they really only printed 1. That is one of the many pitfalls.

Resources