pbm2lwxl-0/000075500000000000000000000000001071406350200127565ustar00rootroot00000000000000pbm2lwxl-0/Makefile000064400000000000000000000013441071406350200144200ustar00rootroot00000000000000CC=gcc CFLAGS=-g INSTALL_DIR=/usr/local/bin/ default: all all: pbm2lwxl pbm2lwxl: pbm2lwxl.c $(CC) $(CFLAGS) -o pbm2lwxl pbm2lwxl.c tarball: download_html pbm2lwxl.tar.gz pbm2lwxl.tar.gz: Makefile pbm2lwxl.c license.html index.html README ps2lwxl txt2lwxl small2lwxl tar zcvf pbm2lwxl.tar.gz Makefile pbm2lwxl.c license.html index.html README ps2lwxl txt2lwxl small2lwxl upload: pbm2lwxl.tar.gz scp pbm2lwxl.tar.gz whitis@guestweb.dbd.com:public_html/software/pbm2lwxl/ download_html: lynx --source http://www.freelabs.com/~whitis/software/license.html >license.html lynx --source http://www.freelabs.com/~whitis/software/pbm2lwxl/index.html >license.html install: cp pbm2lwxl ps2lwxl txt2lwxl small2lwxl $(INSTALL_DIR) pbm2lwxl-0/README000064400000000000000000000001761071406350200136420ustar00rootroot00000000000000read index.html and license.html. Tux images curtosy of Larry Ewing and/or Neal Tucker http://www.isc.tamu.edu/~lewing/linux/ pbm2lwxl-0/index.html000064400000000000000000000206701071406350200147600ustar00rootroot00000000000000 pbm2lwxl - A driver for the CoStar Labelwriter XL
[HOME(Mark Whitis)] [Contact] [Resume] [Browser Friendly] [No Spam] [FEL] [DBD]

pbm2lwxl - A driver for the CoStar Labelwriter XL

Overview

pbm2lwxl is a device driver for the CoStar Labelwriter XL and compatible printers. It takes plain (not raw) pbm files. The PBM file format was popularized by the PBM (aka netbpm, pbmplus, etc) utilities by Jef Poskanzer. There are utilities to convert from almost any image format to PBM/PPM/PGM/PNM, and vice versa. Ghostscript supports pbm output. This driver was written in the C language for Linux but should compile on any un*x compatible system as well as many other operating systems; no operating system specific calls were used.

Writing a PBM filter is an appropriate way to write a printer driver for a simple raster based printer.

Many idiotic companies only write windows drivers for their printers and then their products only work with microsoft windows, and often not even will all versions of windows. Write a PBM or ghostscript driver and your product will work with MS-DOS, Windows 3.1, Windows 95, Windows 98, Windows NT, MacOS, OS/2, Linux, FreeBSD, NetBSD, OpenBSD, 4.3BSD, Solaris, Sunos, AIX, HPUX, Irix, Digital Unix, SCO Unix, Ultrix, VMS, NeXTstep, Amiga, Plan 9, SMS/QDOS.
CoStar LabelWriter II 9600 192 Should work  
CoStar LabelWriter XL+ 19200 448 Should work  
CoStar EL40 ? 192? 1-1/2" wide Should work  
CoStar EL60 ? 448? 2-1/4" wide Should work  
CoStar Turbo ? 448? 2-1/4" wide Should work  
Avery Personal Label Printer 19200 192 Tested - Ok  
Avery Personal Label Printer+??? 19200 448 Should work  
Sieko any n/a n/a Should NOT work. See below
Sony any n/a n/a Unknown See below

Download

Download pbm2lwxl.tar.gz

License

Copyright 1999 by Mark Whitis. All Rights Reserved. Availible under this license. Not GPL tainted. The labelwriter XL uses 19200. Older models use 9600 I think the avery units are relabeled costar units - they look identical inside and out

usage

The printer uses xon/xoff - configure spooler appropriately or use something like: "stty 19200 ixon usage: pbm2lwxl [ width [height] ] width and height are in pixels. width should be 192 (1") or 448 (wide models). You can redirect the output directly to the serial port the printer is attached assuming you don't already have a spooler running on that port and you have already set the baud rate and XON/XOFF flow controls.

scripts

You may need to edit the pathnames to utilities in these scripts. You will probably want to use one or more of the following utilities
    mpage -1 -o -m720t0lrb -L6      - ascii to postscript 
    ghostscript -sDEVICE=pbm -sOutputFile=- -q -dNOPAUSE -r192x192 -g700x192 -dSAFER - -c quit 
    pnmflip -cw   - to rotate 90 degrees 
    pnmnoraw      - convert from raw to plain (ascii) pnm format. 
Note that the ghostscript command shown above generates 700x192 which should be pnmflip'ed to get 192x700 for printing. Change "-L6" to "-L12" on the mpage command to fit more lines on a label.

This program does not use libpnm. No particular reason. It was just faster to write code which read a plain pbm file than to figure out how to use libpnm and if its licensing was acceptable. libpnm is more flexible but we really don't need that flexibility here.

lpr

I haven't integrated this with lpr yet. The biggest question is how to set XON/XOFF. The documentation on fs/fc printcap directives is a bit vague (to say the least). It is possible I might have to write a trivial output filter program to do xon/xoff. fs=IXON?????????:lp=/dev/cua1:br#19200:

Bar Codes

Check out pbmupc, part of the netpbm package, probably already installed on most Linux boxes.

Other companies

Avery

The avery products look like rebranded costar products. I have several of the 1" models around and will test them soon.

Seiko

This program will not drive seiko label printers. For a driver program for seiko printers, check out slap. Slap is a rather bloated program which tries to reinvent the wheel instead of cooperating with the existing rasterizer (ghostscript). It comes with a bunch of fonts. The result appears to be that you have a much more complicated program but much less flexibility in printing labels.

Sony

I know nothing about sony label printers

Dymo

It looks like dymobought costar which is now called Dymo-Costar. Don't confuse these printers, however, with the continuous laminated thermal transfer label tape printers made by Brother and Casio, some of which were rebranded by Dymo. And certainly don't confuse these with the even older mechanical embossing printers by Dymo or the old Kroy mechanical ribbon transfer label makers.

Industrial Bar code printers

I don't have any information at the moment on the industrial strength bar code printers.

This file is maintained by Mark Whitis (whitis@dbd.com).

pbm2lwxl-0/license.html000064400000000000000000000760171071406350200153010ustar00rootroot00000000000000 pbm2lwxl - A driver for the CoStar Labelwriter XL
Mark Whitis's Website Home Page Linux Book: Linux Programming Unleashed My Resume Genealogical Data Contact Info Security About

[HOME(Mark Whitis)] [Contact] [Resume] [Browser Friendly] [No Spam] [FEL] [DBD]
[IMAGE]

pbm2lwxl - A driver for the CoStar Labelwriter XL

Overview

pbm2lwxl is a device driver for the CoStar Labelwriter XL and compatible printers. It takes plain (not raw) pbm files. The PBM file format was popularized by the PBM (aka netbpm, pbmplus, etc) utilities by Jef Poskanzer. There are utilities to convert from almost any image format to PBM/PPM/PGM/PNM, and vice versa. Ghostscript supports pbm output. This driver was written in the C language for Linux but should compile on any un*x compatible system as well as many other operating systems; no operating system specific calls were used.

Writing a PBM filter is an appropriate way to write a printer driver for a simple raster based printer.

Many idiotic companies only write windows drivers for their printers and then their products only work with microsoft windows, and often not even will all versions of windows. Write a PBM or ghostscript driver and your product will work with MS-DOS, Windows 3.1, Windows 95, Windows 98, Windows NT, MacOS, OS/2, Linux, FreeBSD, NetBSD, OpenBSD, 4.3BSD, Solaris, Sunos, AIX, HPUX, Irix, Digital Unix, SCO Unix, Ultrix, VMS, NeXTstep, Amiga, Plan 9, SMS/QDOS.

Status

I am currently working on support for multipage postscript files. The latest version of the driver (probably newer than availible here) supports multiple PBM files on a single input stream as output by ghostscript. Unfortunately, pbmflip and pbmnoraw (which are used in the scripts) choke. I am now getting ghostscript to do the rotation, where desired. The current version works fine as long as there is only one label per print job. Nov 1999 Update: Dymo-Costar has sent me several of their printers for testing. I have tested the Turbo, EL60, and EL40. All work with the appropriate parameters (see table below).

Device Support

CoStar LabelWriter II 9600 192?/128? Should work  
CoStar LabelWriter XL 19200 192 Tested - works  
CoStar LabelWriter XL+ 19200 448 Should work  
CoStar EL40 19200 192 1-1/2" wide Tested. Works.  
CoStar EL60 19200 448 2-1/4" wide Tested. Works.  
CoStar Turbo 115200 448 2-1/4" wide Tested, works  
CoStar SE250 115,200 448 Should work  
CoStar SE250+ ? 448? Should work 115.2Kbps
CoStar ASCII ? 192? Should work 115.2Kbps
CoStar ASCII+ ? 448 Should work 115.2Kbps
Avery Personal Label Printer 9600 128 Tested - lower resolution approx 128x128 dpi
Avery Personal Label Printer+??? 19200 448 Should work  
Sieko any n/a n/a Should NOT work. See below
Sony any n/a n/a Unknown See below
CoStar LW300 115200 300? 1-1/2" wide Not tested. Will Propably work. Has Serial and USB
CoStar LW330 115200 700? 2-1/4" wide Not Tested. Will probably work. Has Serial and USB
CoStar LW330 Turbo 115200? 700? 2-1/4" wide Not tested. Will probably work. Has serial and USB.
Since the Avery unit has lower resolution, there are a few problems. Random garbage is printed on some lines. This is probably the result of sending more bytes of data per line than the printer expects. There is also an offset problem (the last 128 pixels get printed, not the first) unless you specify a label width of 128 when invoking pbm2lwxl. Effective label size (standard 1-1/8x3.5" labels) is 128x448 pixels.

These printers do not autobaud; use only the single baud rate supported by the printer. Use the correct label width or you probably won't like the results.

Download

Download pbm2lwxl.tar.gz

License

Copyright 1999 by Mark Whitis. All Rights Reserved. Availible under this license. Not GPL tainted.

Compiling

In the commands below, /dist is the directory on your system where you download distribution files prior to installation. Substitute a suitable directory on your system or make /dist a symbolic link to a directory created for the purpose on a disk partition with sufficient free space.

   cd /dist
   wget http://www.freelabs.com/~whitis/software/pbm2lwxl/pbm2lwxl.tar.gz
   cd /usr/local/src
   mkdir pbm2lwxl
   cd pbm2lwxl
   tar zxvf /dist/pbm21wxl.tar.gz
   make
   make install

"make install" does not make any attempt to integrate with the printing system on your system.

usage

The labelwriter XL uses 19200. Older models use 9600 The printer uses xon/xoff - configure spooler appropriately or use something like: "stty 19200 ixon -onlcr usage: pbm2lwxl [ width [height] ] For example: # Make sure you specify the correct baud rate for your printer model stty 19200 ixon -onlcr /dev/cua1 width and height are in pixels. width should be 192 (1") or 448 (wide models). You can redirect the output directly to the serial port the printer is attached assuming you don't already have a spooler running on that port and you have already set the baud rate and XON/XOFF flow controls.

Obviously, you need to redirect a PBM file into the standard input of the program.

scripts

You may need to edit the pathnames to the pbm2lwxl utility in these scripts. Since lpd does not establish a reasonable path, I hardcoded the pathnames to /usr/local/bin/. You will probably want to use one or more of the following utilities
    mpage -1 -o -m720t0lrb -L6      - ascii to postscript 
    ghostscript -sDEVICE=pbm -sOutputFile=- -q -dNOPAUSE -r192x192 -g700x192 -dSAFER - -c quit 
    pnmflip -cw   - to rotate 90 degrees 
    pnmnoraw      - convert from raw to plain (ascii) pnm format. 
Note that the ghostscript command shown above generates 700x192 which should be pnmflip'ed to get 192x700 for printing. Change "-L6" to "-L12" on the mpage command to fit more lines on a label.

This program does not use libpnm. No particular reason. It was just faster to write code which read a plain pbm file than to figure out how to use libpnm and if its licensing was acceptable. libpnm is more flexible but we really don't need that flexibility here.

lpr

Apparently, lpd recognizes XON/XOFF on serial ports. This is good since there does not appear to be a way to configure that (the fs printcap directive seems inadequate). So, here is a sample configuration for text.

label0:\
        :sd=/var/spool/lpd/label0:\
        :mx#0:\
        :sh:\
        :lp=/dev/cua19:\
        :if=/usr/local/bin/txt2lwxl:\
        :br#9600:

Bar Codes

Check out pbmupc, part of the netpbm package, probably already installed on most Linux boxes.

Other companies

Avery

The avery units are relabeled older costar units (I suspect the labelwriter II) - they look identical inside and out and the Avery units even say "COSTAR" inside.

The Avery Personal label printer prints at 1" per second, according to the meager specifications.

Seiko

This program will not drive seiko label printers. For a driver program for seiko printers, check out slap. Slap is a rather bloated program which tries to reinvent the wheel instead of cooperating with the existing rasterizer (ghostscript). It comes with a bunch of fonts. The result appears to be that you have a much more complicated program but much less flexibility in printing labels.

Sony

I know nothing about sony label printers

Dymo

It looks like dymobought costar which is now called Dymo-Costar. Don't confuse these printers, however, with the continuous laminated thermal transfer label tape printers made by Brother and Casio, some of which were rebranded by Dymo. And certainly don't confuse these with the even older mechanical embossing printers by Dymo or the old Kroy mechanical ribbon transfer label makers.

Industrial Bar code printers

I don't have any information at the moment on the industrial strength bar code printers.

Innards

The following was from an Avery Personal Label Printer
Chip: (Motorola logo) SC408056FN 600100-030 COSTAR REV D 2C83JQQKV9152
  (Probably a mask programmed 68HC11 processor)
Chip: 74HC04N
Chip: 75HC423N
Chip: 2x (ST logo) PBL3717A 89134C
Chip: Max232N
Chip: 2xUA7805C
Chip: P8P10 (T0-220)
Marking: ASSY PART NO: 60100-032
Marking: COSTAR CORP 400032 REV D

Postscript

For more information on the postscript language, get a copy of Postscript Language Tutorial and Cookbook and the Postscript Language Reference Manual.

One of the most common problems you will have with these label printers is that a postscript page is laid out so that the text prints at the top of a normal 8-1/2x11 page and the area which is rendered into the bitmap is a small rectangle in the lower left corner. Even if you only print 6 lines on the page, they will typically be at the top. The lower left hand corner is used as an origin (this makes better mathematical sense but printers and monitors work the other way) rather than the top left which causes unexpected things to happen when printing other paper sizes. This is why the funny margin options are used with mpage above.

It might be helpful to define new paper sizes in gs_stad.ps. mpage would probably need to be updated. mpage would benifit from a page definition database which specified where each little page went on the page. This would be useful for all sorts of laser and inkjet printer labels.

Compression

The LableWriter XL supports a form of RLE image compression. I don't know if the older printers support this. The driver uses the raw, uncompressed, image data format. On some models, the serial port might slow down the printing with uncompressed data.

Applications

Debugging

Set the variable debug to 1 in pbm2lwxl.c (or set it using gdb).

Continuous paper

Thermal adding machine paper can be used instead of labels. You will need to send a label length of -1 to the printer to disable the hole sensor; if the second argument to pbm2lwxl is a Cheap thermal paper can be handy for testing purposes or for applications such as a cheap point of sale receipt printer (using the wide model, preferably), cheap tape over shipping labels, etc. For line by line printing applications, you may want to use pbmtext instead of ghostscript and disable the formfeed command in the software.

pnmcrop is handy with pnmtext to trim the excessive border produced by pnmtext.

Look at the script "fontdemo" for a sample of receipt style printing.

Label stock

Labels are availible from avery and costar, among others. Labels are availible in a variety of sizes.

EIMINC can make custom labels specifically for barcoding; they claim these labels are more durable and are IR scanable. They also sell tamper evident labels but I don't think they work in thermal label printers.

Fonts

This driver does not need any fonts or do any font handling; use whatever fonts are availible for postscript or pbmtext. As a convenience to users of pbmtext, an X windows font grabbing utility (grabfont), a demonstration of how to use them in receipt printing mode (fontdemo) are included.

Tux

An image of TUX the penguin

Distribution Specific

Old redhat versions

Not worth the trouble fixing the printtool. Just create the queue entry in /etc/printcap and input filter manually and keep a backoup copy of printcap incase printtool clobbers it.

It would involve a bit of work to extend the redhat printtool/printfilters to handle label printers.

The redhat print tool needs to be extended to understand the concept of one or more postprocessors after ghostscript. Additional fields should be added to their printer database /usr/lib/rhs/rhs-printfilters/printerdb. Printfilters should be added to convert ps-to-pbm and then pbm-to-printer.

redhat does understand the idea of a final filter that actually sends the data directly to the printer (smbprint), etc. although that is all hard coded into the main filter script.

The redhat print filters also seem to have a problem in that if they are starting from ascii they will apparently invoke asc-to-printer; it is not a valid assumption these days that the printer can handle ascii. They seem to make the mistake in assuming that any of the *-to-printer.fpi filters can actually be used. It bypasses its own "DESIRED_TO" format.

Redhat 7.1

###
### dymo label printer
###
wget ftp://speakeasy.rpmfind.net/linux/redhat/7.1/en/os/i386/SRPMS//printconf-0.2.12-1.src.rpm
rpm -i printconf-0.2.12-1.src.rpm
rpm -ba /usr/src/redhat/SPECS/printconf.spec 
cd /usr/src/redhat/BUILD/printconf-0.2.12/src
echo pbm2lwxl >>redhat_gs_driver_list 
python util/build_striped_printer_db.py  foomatic/data japanese printer_db.pickle redhat_gs_driver_list
patch printconf-gui <<\...EOF...
--- printconf-gui.orig	Wed Mar 28 11:51:22 2001
+++ printconf-gui	Wed Jul 18 03:22:20 2001
@@ -278,6 +278,12 @@
 # This being a printing system, it's probably a good idea to go and see if there are any printers attached locally.
 # There are much more intelligent approaches to this problem, but the rest of the system isn't sophisticated enough
 # to care yet, so simply scaning likely devices to see if they can be opened for writing is sufficient.
+
+# Added serial ports which are needed to support Avery, Dymo, and Costar
+# label printers, among others.  And yes, we definitely need more than
+# for serial ports here.  My label printers are attached to
+# a byterunner 8 port board with ports from ttyS16-ttyS23
+#    - Mark Whitis <whitis@freelabs.com>
 local_printers = []
 for devlpx in [	'/dev/lp0',
 		'/dev/lp1',
@@ -286,7 +292,40 @@
 		'/dev/usb/lp0',
 		'/dev/usb/lp1',
 		'/dev/usb/lp2',
-		'/dev/usb/lp3']:
+		'/dev/usb/lp3',
+		'/dev/ttyS0',
+		'/dev/ttyS1',
+		'/dev/ttyS2',
+		'/dev/ttyS3',
+		'/dev/ttyS4',
+		'/dev/ttyS5',
+		'/dev/ttyS6',
+		'/dev/ttyS7',
+		'/dev/ttyS8',
+		'/dev/ttyS9',
+		'/dev/ttyS10',
+		'/dev/ttyS11',		
+		'/dev/ttyS12',
+		'/dev/ttyS13',				
+		'/dev/ttyS14',
+		'/dev/ttyS15',						
+		'/dev/ttyS16',
+		'/dev/ttyS17',
+		'/dev/ttyS18',
+		'/dev/ttyS19',
+		'/dev/ttyS20',
+		'/dev/ttyS21',		
+		'/dev/ttyS22',		
+		'/dev/ttyS23',		
+		'/dev/ttyS24',		
+		'/dev/ttyS25',		
+		'/dev/ttyS26',		
+		'/dev/ttyS27',		
+		'/dev/ttyS28',		
+		'/dev/ttyS29',		
+		'/dev/ttyS30',		
+		'/dev/ttyS31'
+		]:
 	try:
 		os.close (os.open (devlpx, os.O_WRONLY | os.O_NONBLOCK))
 		local_printers.append({'device':devlpx})
...EOF...

# chown lp /dev/ttyS16

# buggy cp, can't overide -i with -f
yes | cp printer_db.pickle /usr/share/printconf/printer_db.pickle
yes | cp  printconf-gui /usr/sbin/printconf-gui

printconf-gui &
   # Interactive, GUI
# after configuring printer in printconf-gui, add :br#19200: in /etc/printcap
# (which will unfortunately be erased next time printconf-gui runs)
emacs /var/spool/lpd/lbltst/pbm2lwxl-126082.foo 
  # change 
  #    "| pnmflip -cw | pnmnoraw | pbm2lwxl" 
  # to  
  #    "| pbm2lwxl 448 1500"
  # which defines a lable size of 2.125x8" (the length will be truncated
  # based on how many lines ghostscript outputs)
  # note this will give non-rotated output.  If you want rotated output
  # you will need to reverse the width and height in all label 
  # size definitions, put the pnmflip and pnmnoraw commands back, and
  # remember to add the options to pbm2lwxl.  Better yet, figure out
  # how to get portrait/landscape printing options to ghostscript
  # once it is working, you may want to move from /etc/printcap
  # to /etc/printcap.local so printconf won't hurt it.

Company Involvement

This driver was written using a document (Lwxlprog.txt) downloaded from costar's web site. Programming documents, SDKs, etc are at their Developers Libary including the LWXL programming Document . Costar sent me several models of printers for testing purposes. Tim Kissane at CoStar runs Linux at home and has gotten some other people inside the company working Linux.

Common Problems

If the last half of the line seems garbled on 7x14 and 7x13 fonts in fontdemo, you are probably being bitten by newline translation. Try "stty -onlcr <$device".

If XON/XOFF flow control is not working, garbage may be printed.

If you have any funny settings for xterm in your xdefaults, this will affect grabfont.

Bugs

No bugs have been reported.

Other Operating Systems

This should port easily to many operating systems.

Unix Compatible

This software should port easily to any unix compatible operating system, including FreeBDS, Solaris, SunOS, AIX, etc. The most likely change needed, if any, is to change which include files are used.

Microsoft Windows, any version, or DOS

DO NOT send me requests for assistance with any version of microsoft windows, with the possible exception of serious porting efforts. Dymo no longer supports the older printer models. If you are looking for a windows driver, look here or do an intelligent search on google. Remember to run a virus checker. If you have programming experience, you can try porting this driver or using dymo-costars windows SDK. But don't bother me me windows end user questions.

This program should port easily to DOS or the dos box on windows. The challange is how to get the output of this program to a serial port. On a pure dos box, you may need a library which supports interrupt driven I/O although simple redirection of standard output to COM1: may work (with appropriate MODE settings for buad rate, no translation, and XON/XOFF) since the data flow is output only except for XON/XOFF. On a dos window in windows, this may already be handled for you by windows if you open COMx:. Don't forget to enable XON/XOFF and disable any translation.

Have I made it perfectly clear that I do not provide tech support for windoze users?

This file is maintained by Mark Whitis (whitis@freelabs.com).

[NO SPAM! Zero Tolerance: We charge a hefty fee for each unsolicited bulk email message received] [Blue Ribbon Campaign]

All email messages received must pass the turing test or they will be considered SPAM. If it could have been written by a machine, it was.

Under no circumstances are you to email me with questions regarding windoze, any other microsoft operating system or application, or any software which runs under any form of windoze.

Search this site for:
Use the search form at the left to search this site, including Free Electron Lab's, Mark's personal pages, Mark's Linux Pages, and Mark's Genealogy pages.

This page should be viewable on any reasonable browser including handheld devices, browsers with special accessability features for people with disabilities, text mode browsers, and browsers which lack Java and Javascript or have these features disabled for security reasons. Adjust your browser window to any reasonable width you choose.


There are 11 equally sized squares in this image ranging from 0% to 100% brightness in even steps of 10%. If you cannot see each square, you need to adjust the brightness and contrast controls on your monitor. [Greybar]
Mark Whitis's Website Home Page Linux Book: Linux Programming Unleashed My Resume Genealogical Data Contact Info Security About




  [Linswap Banner Exchange Ad]


LinSwap: The Linux Banner Exchange Program.



pbm2lwxl-0/pbm2lwxl.c000064400000000000000000000147351071406350200147030ustar00rootroot00000000000000/* pbm2lwxl.c - Copyright 1999 by Mark Whitis. All Rights Reserved. */ /* A driver for the Costar Labelwriter XL and compatible printers */ /* The labelwriter XL uses 19200. Older models use 9600 */ /* I think the avery units are relabeled costar units - they look identical */ /* inside and out */ /* uses xon/xoff - configure spooler appropriately */ /* or use something like: "stty 19200 ixon -onlcr #include #include #include /* 1" model has 192 resistive elements */ /* 2" model has 448 resistive elements */ /* about 200 lines per inch */ int label_width=192; int label_height=600; int debug=1; reset() { int i; for(i=0;i<57;i++) { printf("%c",27); } printf("Q"); } /* n is number of pixels wide */ /* data must be n/8 bytes or larger */ print_line(int n, unsigned char data[]) { int i; int nbytes; nbytes=(n+7)>>3; #if 0 printf("%cD%c",27,nbytes); /* ESC D n - set bytes per line*/ #else printf("%c",27); /* ESC D n - set bytes per line*/ printf("D"); /* ESC D n - set bytes per line*/ printf("%c",nbytes); /* ESC D n - set bytes per line*/ #endif printf("%c",0x16); /* */ for(i=0;i>8), (n & 0xFF)); } int pixel_order[]= { 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01 }; test() { int i; int j; int pos; unsigned char data[512]; for(i=0; i=label_width) pos=0; /* clear data */ for(j=0;j>3] |= pixel_order[pos&0x07]; print_line(label_width, data); } } read_pbm_header(int *width_p, int *height_p) { char buf[4096]; int found_type; char *p; found_type=0; while(1) { p=fgets(buf,sizeof(buf),stdin); if(p==NULL) { exit(0); } if(debug) fprintf(stderr,"buf=%s\n",buf); if(debug) fprintf(stderr,"buf[0]=%d\n",buf[0]); if(strncmp(buf,"P1",2)==0) { found_type=1; } else if (buf[0]=='#') { ; /* skip comment */ } else if (isspace(buf[0])) { ; /* skip blank lines */ } else if (sscanf(buf,"%d %d",width_p,height_p)==2) { assert(*width_p>0); assert(*height_p>0); assert(*width_p<4096); assert(*height_p<4096); break; } else { fprintf(stderr, "Error: Input is not in plain PBM (noraw) format\n"); fprintf(stderr, "Try running through pnmnoraw\n"); abort(); } } } /* length in pixels, not bytes */ void set_pixel(int length, unsigned char *data, int pos) { if(pos>=length) return; if(pos<0) return; data[pos>>3] |= pixel_order[pos&0x07]; } void reset_pixel(int length, unsigned char *data, int pos) { if(pos>=length) return; if(pos<0) return; data[pos>>3] &= ~pixel_order[pos&0x07]; } int read_pbm_line(int length, unsigned char *data, int pbm_width, int pbm_height) { int c; int pos; int count; pos=0; count=pbm_width; while(count) { c=fgetc(stdin); if(c==EOF) return(EOF); if(c=='1') { set_pixel(length, data, pos); pos++; count--; } if(c=='0') { reset_pixel(length, data, pos); pos++; count--; } } return(0); } main(int argc, char **argv) { unsigned char data[512]; int i; int j; int pos; char buf[4096]; int rc; int pbm_width; int pbm_height; while(1) { read_pbm_header(&pbm_width, &pbm_height); if(debug) fprintf(stderr,"pbm_width=%d\n",pbm_width); if(debug) fprintf(stderr,"pbm_height=%d\n",pbm_height); /* note that the printer itself cannot handle this high a width */ /* but we allow some excess in case the introduce a wider model */ /* the 2040 limit is set by the protocol (255 bytes) */ if(argc>=2) label_width=atoi(argv[1]); assert(label_width > 0); assert(label_width <= 2040); if(argc>=3) label_height=atoi(argv[2]); assert(label_height >= -1); assert(label_height <= 65535); for(i=0;i&2 echo "WIDTH=$WIDTH" >&2 echo "HEIGHT=HEIGHT" >&2 #ghostscript -sDEVICE=pbm -sOutputFile=- -q -dNOPAUSE -r192x192 -g700x192 -dSAFER - -c quit | pnmflip -cw | pnmnoraw | /usr/local/bin/pbm2lwxl $1 $2 ghostscript -sDEVICE=pbm -sOutputFile=- -q -dNOPAUSE -r${DPI}x${DPI} -g${HEIGHT}x${WIDTH} -dSAFER - -c quit | pnmflip -cw | pnmnoraw | /usr/local/bin/pbm2lwxl $WIDTH $HEIGHT pbm2lwxl-0/small2lwxl000075500000000000000000000001451071406350200150050ustar00rootroot00000000000000#!/bin/bash # good for 6 lines of 29 characters mpage -1 -o -m720t0lrb -L12 | /usr/local/bin/ps2lwxl pbm2lwxl-0/txt2lwxl000075500000000000000000000001441071406350200145130ustar00rootroot00000000000000#!/bin/bash # good for 6 lines of 29 characters mpage -1 -o -m720t0lrb -L6 | /usr/local/bin/ps2lwxl