Subject: [netatalk-admins] Re: Problems sending binary data to parrallel port postscript printer
From: Michael Hojnowski (mqh@mqh.cit.cornell.edu)
Date: Mon Feb 16 1998 - 19:45:47 EST
>> >Anyway the situation is
>> >Macs running Laserwriter 8.5.1 printing images from photoshop via
netatalk to
>> >a Linux (Red Hat 4.2) or FreeBSD (2.2.5) box with a Tektronix Phaser
IIIPXi
>> >printer connected via a parrallel port. Spooling works fine (the whole
idea
>> >of doing it was to get the printer off localtalk). Printing files with
only
>> >ascii in them works fine, printing images (which are binary encoded)
causes
>> >the printer to choke..
I had a similar problem using CAP/LWSRV to collect postscript, then
spooling it to HP or Lexmark printers via IP. The problem was this - the
Mac generates "Binary Postscript", however the HP and Lexmark (and probably
Tektronix) printers don't expect Binary Postscript unless it comes in via
Appletalk. If you send in Binary Postscript via IP or the serial lines,
the postscript ripper isn't prepared for it, and it chokes.
The workaround for me was to insert a filter which translated the
postscript into "Tagged Binary Postscript" before sending it to the
printer. A guru at Lexmark sent me the following program. I filter the
data through this filter, which escapes the 8 or so binary sequences that
are choking the printer. This will probably fix it, if you can figure out
how to wrench this filter into the Netatalk setup. I don't run netatalk, I
just read this mail list out of curiosity. Sick, huh?
The filter is below.
Mike
--- /* bin2tbcp.c - Convert file to Tagged Binary Communications Protocol. */#include <stdio.h> #include <stdlib.h> #include <string.h>
void main(argc,argv) int argc; char *argv[]; { FILE *infp,*outfp; long CH; char inputfile[80],outputfile[80];
if (argc == 3) { strcpy(inputfile, argv[1]); strcpy(outputfile, argv[2]); if ( (infp = fopen(inputfile,"r")) == NULL ) { printf("\nERROR : Unable to open input file: %s\n",inputfile); exit(1); } if ( (outfp = fopen(outputfile,"w")) == NULL ) { printf("\nERROR : Unable to open output file: %s\n",outputfile); exit(1); } } else if (argc == 2) { strcpy(inputfile, argv[1]); outfp = stdout; if ( (infp = fopen(inputfile,"r")) == NULL ) { printf("\nERROR : Unable to open input file: %s\n",inputfile); exit(1); } } else { infp=stdin; outfp=stdout; }
fprintf(outfp,"%cM",(unsigned char)(0x01)); while ((CH = fgetc(infp)) != EOF) { switch (CH) { case (unsigned char) 0x01: /* ^A */ case (unsigned char) 0x03: /* ^C */ case (unsigned char) 0x04: /* ^D */ case (unsigned char) 0x05: /* ^E */ case (unsigned char) 0x11: /* ^Q */ case (unsigned char) 0x13: /* ^S */ case (unsigned char) 0x14: /* ^T */ case (unsigned char) 0x1c: /* ^\ */ case (unsigned char) 0x1b: /* ^[ */ fputc((unsigned char) 0x01,outfp); fputc((unsigned char)(CH ^ 0x40),outfp); break; default: fputc(CH,outfp); }
}
fprintf(outfp,"%c%%-12345X",(unsigned char)(0x1b)); fclose(outfp); fclose(infp); }
--- Michael Hojnowski - Sr Prog/Analyst - Cornell University (607) 255-7407 Home Page: http://mqh.cit.cornell.edu/~mqh/ Fax: (607) 255-8169 PGP Public Key: Can be found on my home page
This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:30:57 EST