The Battle of the Phaser continues here...with some good and bad news to 
report:

- The pagecounter on this printer will not update until the TCP connection to 
the printer is closed, whether accessed via PJL PAGECOUNT or PostScript 
queries of the hardware pagecounter.  This is very irritating.
- The printer status accessed via SNMP will never move from "processing" to 
"completed" until the TCP connection to the printer is closed.  Also 
irritating.
- If PJL INFO is enabled, you get TWO lines of information back starting with 
ID= (one for jobid assigned by the printer, the other for the product ID 
string "Xerox Phaser 5400".  Disabling PJL INFO will eliminate the product ID 
string, to keep ifhp's status-monitoring working.
- PJL USTATUS's "RESULT=OK" string comes back way before the job is complete 
(or the pagecounter is updated at the end of the job).
- Any job printed duplex is billed for 2 sheets.  Even if nothing is printed 
on the second side.

I may still have the attention of some people at Xerox regarding what I 
consider PJL implementation "issues" described above...we'll see if they take 
any to heart and implement such changes.

Some good news to report: I have managed to get this to work with ifhp-3.5.8a2 
with reasonably accurate account limitations.  To do this, the following patch 
and check_xerox_status need to be applied, then invoke ifhp using model 
"phaser5400".  This enables "braindead_pagecounter" (closes TCP connection to 
printer, then reopens before final pagecount is gathered) and defines an 
external "waitend_prog" program that will wait for the printer to finish 
printing before querying the final pagecount.

For those who care about status queries on this printer, the SNMP tree to grab 
is .1.3.6.1.4.1.253.8.59.6.1.1.9.  Any jobs returning "17" are complete; if 
any show a "7", they are in progress.  The script below just queries the 
printer repeatedly until all go to status "7".  You can also query 
.1.3.6.1.2.1.43.16.5.1.2.1 (.1 and .2 subentries here) to get status 
information off the front panel of the printer, should you care what is saying 
to the user in front of the unit.

Patrick: please consider adding the following code to the ifhp distribution.  
I haven't had a chance to document the features in the HOWTO's, though (nor am 
I certain which is the "master" copy to add to).

As for the printer itself, it seems to be built very solid, much like the 
Phaser 850 we have here.  It prints to within 1/8" of the edge of the page, 
too, which is also impressive.  Time will tell how well it handles flaky PDF 
files and other strange PostScript jobs being thrown at it.

-- 
============================================================================
   John Perkins                   |   University of Wisconsin-Madison
   Associate Researcher           |   Department of Computer Science
   [EMAIL PROTECTED]               |   1210 W. Dayton St.
   608-262-0438/608-262-9997 FAX  |   Madison, WI  53706-1685
============================================================================


#! /usr/local/bin/perl -w
#
# usage: 
#    check_xerox_printer lprng_device
#
#
# Do SNMP query of Xerox printer; return necessary codes based on what we find
#


#BEGIN {
#       if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
#               $runtimedir = $1;
#               $PROGNAME = $2;
#       }
#}

use strict;
use Getopt::Long;
#use vars qw($opt_H $verbose $PROGNAME);
#use lib $main::runtimedir;
#use utils qw($TIMEOUT %ERRORS &print_revision &support &usage &is_error);
use Net::SNMP;

sub print_help ();
sub print_usage ();
sub help ();
sub version ();

my $community="CSL";
my $timeout=5;
my $retries=3;
my $status_oid=".1.3.6.1.4.1.253.8.59.6.1.1.9";
my $error;
my $response;
my $session;
my $status;
my $complete=0;
my $verbose=0;
my $host;
my $key;

$host = $ARGV[0];
$host =~ s/\%.*//;
print "Host: $host\n" if $verbose;

#create the SNMP session
print "Opening session to $host with PW $community, timeout $timeout and retries 
$retries\n" if $verbose;

print "Entering while loop" if $verbose;
while(!($complete)) {
  print "Running get_table $status_oid\n" if $verbose;
  ($session, $error) = Net::SNMP->session(-hostname=>$host,
                                          -community=>$community,
                                          -timeout=>$timeout,
                                          -retries=>$retries);
  $response = $session->get_table(($status_oid));
  $session->close;
  print "Error: $error\n" if $verbose;
  if ($response) {
    $complete=1;
    foreach $key (sort keys (%$response)) {
      print "response for $key: $response->{$key}\n" if $verbose;
      if ($response->{$key} != 17) {
        $complete=0;
      }
    }
    if (!$complete) {
      print "Sleeping\n" if $verbose;
      sleep 1;
    }
  } else {
    sleep 5;
  }
}

# exit with JSUCC
$status = 0;
print "Exit status: 0\n" if $verbose;
exit $status;


Index: ifhp.conf.in
===================================================================
RCS file: /afs/cs.wisc.edu/s/lprng-3.8/src/CVSROOT/ifhp-3.5.8a2/ifhp.conf.in,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 ifhp.conf.in
*** ifhp.conf.in        2002/04/16 15:27:01     1.1.1.1
--- ifhp.conf.in        2002/04/19 22:43:53
***************
*** 1608,1613 ****
--- 1608,1668 ----
    *gzip_compressed*  filter  \%s{gzip_decompress}
   ]
  
+ [ phaser5400 ] 
+ 
+ braindead_pagecounter
+ waitend_prog=PATH_TO/check_xerox_status
+ 
+ pjl_except=[ INFO ]
+ 
+ ps_simplex= <</Duplex false /Tumble false>> setpagedevice
+ ps_duplex= <</Duplex true /Tumble false>> setpagedevice
+ ps_lduplex=[ duplex ]
+ ps_sduplex= <</Duplex true /Tumble true>> setpagedevice
+ 
+ ps_collate=
+   currentpagedevice /Collate known
+     {currentpagedevice /Collate get
+       {(True)}{(False)} ifelse}
+     {(Unknown)}
+   ifelse = flush
+  restore "
+ 
+ ps_draft=  << /HWResolution [600 600] /Policies <</HWResolution 2 >>
+      /PostRenderingEnhance true 
+      /PostRenderingEnhanceDetails
+       << /REValue 0 /TonerSaver 1 /Type 18 >>
+   >> setpagedevice 
+ 
+ 
+ ps_normal=   << /HWResolution [1200 1200] /Policies <</HWResolution 2 >> 
+      /PostRenderingEnhance true 
+      /PostRenderingEnhanceDetails
+       << /REValue 0 /TonerSaver 0 /Type 18 >>
+   >> setpagedevice 
+ 
+ ps_high=[ normal]
+ ps_fast=[ draft ] 
+ 
+ #
+ # Position 1 is the MBF (manual bypass feeder)
+ #   Must specify Manual Feed or it will go to next tray (tray2) if empty
+ # Position 0 is tray 1 (top tray)
+ # Position 2 is tray 2
+ # Position 3 is tray 3 (assumed to be large-capacity feeder--would anyone 
+ #   get a large-capacity feeder without the second tray option up at the top?
+ #
+ ps_manual= <</ManualFeed true /MediaPosition 1 >> setpagedevice
+ ps_inupper= <</MediaPosition 0 >> setpagedevice
+ ps_intray1=[ ps_inupper ]
+ ps_inlower= <</MediaPosition 2 >> setpagedevice
+ ps_intray2=[ ps_inlower ]
+ ps_inlargecapacity= <</MediaPosition 3 >> setpagedevice
+ ps_inlarge=[ inlargecapacity ]
+ ps_intray3=[ inlargecapacity ]
+ 
+ tc=hp4000_pcl
+ 
  ## HP Printers
  
  ## These all support PJL to a limited extent and PCL
Index: src/ifhp.c
===================================================================
RCS file: /afs/cs.wisc.edu/s/lprng-3.8/src/CVSROOT/ifhp-3.5.8a2/src/ifhp.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 ifhp.c
*** ifhp.c      2002/04/16 15:27:03     1.1.1.1
--- ifhp.c      2002/04/19 21:23:15
***************
*** 1185,1191 ****
--- 1185,1195 ----
        OBJ *l = 0;
        int endpagecounter = 0;
        struct stat statb;
+         pid_t pid;
+         int status = 0;
+         struct stat prog_stat;
  
+ 
        /* make sure we clear the status */
  
        l = NEW_OBJ(l,MEMINFO);
***************
*** 1256,1261 ****
--- 1260,1294 ----
                Do_waitend(Job_timeout, Waitend_interval, Waitend_ctrl_t_interval, 
banner_page );
        }
  
+         if( Braindead_pagecounter ){
+                 DEBUG4("End_of_job: closing and reopening printer connection");
+                 close(1);
+ 
+                 if( Waitend_prog ){
+                   LOGMSG(LOG_INFO)_("End_of_job: using '%s' to wait for real end of 
+job"), Waitend_prog );
+                     pid = fork();
+                     if( pid != 0 ){
+                         /* parent process - wait for status monitor to end */
+                         DEBUG4("End_of_job: waiting for pid %d", pid);
+                         waitpid(pid, &status, 0);
+                     } else {
+                         /* child process - exec Waitend_prog */
+                         status = stat(Waitend_prog, &prog_stat);
+                         if( status == ENOENT ) {
+                             /* filter doesn't exist...abort! */
+                             Errorcode = JABORT;
+                             FATAL(LOGINFO)"End_of_job: waitend_prog %s does not 
+exist...aborting...", Waitend_prog);
+                         }
+                         DEBUG4("End_of_job: running %s %s", Waitend_prog, Device);
+                         execle( Waitend_prog, Waitend_prog, Device, 0, Envp );
+                         /* "ooops... error */
+                         Errorcode = JABORT; 
+                         FATAL(LOGINFO)"End_of_job: execle( %s, %s, %s, 0, Env ) 
+failed - %s", Waitend_prog, Waitend_prog, Device, Errormsg(errno));
+                     }
+                     Open_device( Device );
+                 }
+         }
+ 
        /* now get the pagecounter value */
        SET_HASH_STR_OBJ(Devstatus,"pagecount",0,MEMINFO);
        if( Status && do_pagecount && Pagecount_end && startpagecounter ){
Index: src/ifhp.h
===================================================================
RCS file: /afs/cs.wisc.edu/s/lprng-3.8/src/CVSROOT/ifhp-3.5.8a2/src/ifhp.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 ifhp.h
*** ifhp.h      2002/04/16 15:27:03     1.1.1.1
--- ifhp.h      2002/04/19 20:41:44
***************
*** 170,175 ****
--- 170,176 ----
        Appsocket,      /* accounting fd */
        Qms,    /* QMS printer */
        Autodetect,     /* let printer autodetect type */
+       Braindead_pagecounter,  /* Braindead_pagecounter */
        Close_connection, /* close the appsocket connection */
        Crlf,           /* only do CRLF */
        Dev_retries,    /* number of retries on open */
***************
*** 241,247 ****
        *Statusfile,    /* status file */
        *Stty_args,             /* if device is tty, stty values */
        *Sync,                  /* synchronize printer */
!       *Waitend;               /* wait for end using sync */
  
  /*
   * set by routines
--- 242,249 ----
        *Statusfile,    /* status file */
        *Stty_args,             /* if device is tty, stty values */
        *Sync,                  /* synchronize printer */
!       *Waitend,               /* wait for end using sync */
!       *Waitend_prog;          /* program to wait for EOJ */
  
  /*
   * set by routines
Index: src/vars.c
===================================================================
RCS file: /afs/cs.wisc.edu/s/lprng-3.8/src/CVSROOT/ifhp-3.5.8a2/src/vars.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 vars.c
*** vars.c      2002/04/16 15:27:03     1.1.1.1
--- vars.c      2002/04/19 20:40:49
***************
*** 18,23 ****
--- 18,24 ----
      {  "Accounting_script", "accounting", &Accounting_script, STRV ,0 },
      {  "Appsocket", "appsocket", (char **)&Appsocket, FLGV ,0 },
      {  "Autodetect", "autodetect", (char **)&Autodetect, FLGV,0 },
+     {  "Braindead_pagecounter", "braindead_pagecounter", (char 
+**)&Braindead_pagecounter, FLGV ,0 },
      {  "Close_connection", "close_connection", (char **)&Close_connection, FLGV,0 },
      {  "Crlf", "crlf", (char **)&Crlf, FLGV,0 },
      {  "Dev_retries", "dev_retries", (char **)&Dev_retries, INTV,0 },
***************
*** 71,76 ****
--- 72,78 ----
      {  "Trace_on_stderr", "trace", (char **)&Trace_on_stderr, FLGV,0 },
      {  "Wait_for_banner_page", "wait_for_banner", (char **)&Wait_for_banner, FLGV,0 
},
      {  "Waitend", "waitend", &Waitend, STRV,0 },
+     {  "Waitend_prog", "waitend_prog", &Waitend_prog, STRV,0 },
      {  "Waitend_ctrl_t_interval", "waitend_ctrl_t_interval", (char 
**)&Waitend_ctrl_t_interval, INTV,0 },
      {  "Waitend_interval", "waitend_interval", (char **)&Waitend_interval, INTV,0 },
  

Reply via email to