1753928 Members
9013 Online
108810 Solutions
New Discussion юеВ

PJL in script or C

 
SOLVED
Go to solution
Tim Howell
Frequent Advisor

PJL in script or C

I need to check the status of a network printer, preferable within the (ANSI C) application, before the application sends a job to the printer. It sounds like PJL is the key, but I can't find difinitve docs or examples. I even have the printed book from HP, but there are too many unknowns left to perform the task. It says there is a way to receive messages from the printer, but it doesn't explain how. I am using HP-UX 11i, korn shell, and have laserjet4v and 5000N printers.
Thanks in advance!
if only we knew...
4 REPLIES 4
Rodney Hills
Honored Contributor

Re: PJL in script or C

If I'm not mistaken, most status checks of network devices (including printers) is done via "snmp".

-- Rod Hills
There be dragons...
Johan_52
Advisor

Re: PJL in script or C

You open a TCP connection with the printer and send a PJL command to retrieve the status of the device with commands like @PJL INFO VARIABLES or @PJL INQUIRE . This will return amongst lots of other information messages like toner low, paper out etc. Personally I prefer unsolicitied status messages (@PJL USTATUSON) The printer sends device/job/page message when a particular event occurs (the device goes offline, a job is printed or a page is complete). This requires that when you're sending data to the printer you periodically read from the port to see if there are any messages pending.
Tim Howell
Frequent Advisor

Re: PJL in script or C

Thanks Rod, I will investigate that as well.

Johan, I have tried that but got no response. Perhaps I did not do it right. I treated the printer as the server and had the tcp client connect on port 9100. (I stumbled on that port in the hpnpf man page)I achieved a connection and sent commands, but the printer did not return anything...(?)

Thanks again.
if only we knew...
Johan_52
Advisor
Solution

Re: PJL in script or C

Hi Tim

The attached [ modified ] excerpt from my pjl driver retrieves the configuration information from a PJL printer. I know the recv loop could be implemented smarter, but as is it shows best what needs to be done.
Compile with the -D_SOCKET_SOURCE and -D_HPUX_SOURCE options and execute specifying the printer name and port on the command line. If this example does not work I think you should check printer and / or network settings, but I'm afraid I can't help you there much further.

HTH

Johan