9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: okamoto@granite.cias.osakafu-u.ac.jp
To: 9fans@cse.psu.edu
Subject: Re: [9fans] porting from vs. porting to Plan 9
Date: Mon, 20 Oct 2003 10:38:46 +0900	[thread overview]
Message-ID: <d0865472e80d74ad6f64b136f59510da@granite.cias.osakafu-u.ac.jp> (raw)
In-Reply-To: <Pine.LNX.4.44.0310171611480.12875-100000@maxroach.lanl.gov>

> - "How do I handle PCMCIA and USB"
>
> I still think the last is the biggest deal. Hot-plug is really needed.

When I connected my usb HP printer, I do followings:

1) run usbd
2) wakeup the usb port
3) print anything to that printer.

In practice, I use following scripts for my work:

(1) and (2)  /rc/bin/psc2110lp
===========================================
#!/bin/rc

if(! ~ `{ps |grep usbd} *usbd)
	usb/usbd
for(i in `{seq 20}){
	if (grep -s '3 0x020107' '#U'/usb0/$i/status >[2]/dev/null){
		echo -n 'ep 3 bulk w 64 32' >'#U'/usb0/$i/ctl
		bind '#U'/usb0/$i/ep3data /n/lp
		exit ''
	}
}
exit 'no printer'
================================

(2) /sys/lib/lp/devices
have a line of
==================================
# Hewlett-Packard All-in-One usb printer psc 2110
psc2110	Kenji-Home	-	/n/lp	-	gsijs!PSC+2100	generic	nospool	-	-	-	-
==================================

(3) change the /sys/lib/lp/process/generic to
============================================
#!/bin/rc
# Tries to determine what type of file you are printing and do the correct
# thing with it.
# It currently knows about images, troff intermediate, and ascii files.
TMPFILE=/tmp/lp$pid
fn sigexit { rm -f $TMPFILE; }
if (! ~ $DEBUG '') flag x +
if (~ $LPCLASS *nohead*) NOHEAD=1
if (~ $LPCLASS *duplex*) DUPLEX=1
cat >$TMPFILE
FILETYPE=`{file $TMPFILE}
switch ($FILETYPE(2)) {
case troff;
	switch ($LPCLASS) {
	case *Latin1* *post* *opost*;	switch ($FILETYPE(5)) {
					# Latin1 is for compatibility with old research UNIX systems, doesn't work on Plan 9
					case Latin1 post; tcs -s -f utf -t latin1 < $TMPFILE |$LPLIB/process/dpost

					case UTF; $LPLIB/process/tr2post < $TMPFILE
					}

	case *gs!* *gsijs!*;	switch ($FILETYPE(5)) {
					# Latin1 is for compatibility with old research UNIX systems, doesn't work on Plan 9
					case Latin1 post; tcs -s -f utf -t latin1 < $TMPFILE |$LPLIB/process/dpost |$LPLIB/process/gspipe

					case UTF; $LPLIB/process/tr2post < $TMPFILE |$LPLIB/process/gspipe
					}

	case *;		echo $FILETYPE(2) -T$FILETYPE(5) output is improper for $LPDEST >[1=2]
	}
case special;
	switch ($FILETYPE(4)) {
	case '#b';		switch ($LPCLASS) {
				case *post*;	$LPLIB/process/p9bitpost < $TMPFILE
				case *gs!*;	$LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipe
				case *gsijs!*;	$LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipeijs
				}

	case *;		echo $FILETYPE file is improper for $LPDEST >[1=2]
	}
case Compressed plan old;	# type is really 'Compressed image' or 'plan 9 image'
				# or 'old plan 9 image'
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/p9bitpost < $TMPFILE
	case *gs!*;	$LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/p9bitpost < $TMPFILE |$LPLIB/process/gspipeijs
	}
case jpeg;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/jpgpost < $TMPFILE
	case *gs!*;	$LPLIB/process/jpgpost < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/jpgpost < $TMPFILE |$LPLIB/process/gspipeijs
	}

case GIF;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/gifpost < $TMPFILE
	case *gs!*;	$LPLIB/process/gifpost < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/gifpost < $TMPFILE |$LPLIB/process/gspipeijs
	}

case ccitt-g31;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/g3post < $TMPFILE
	case *gs!*;	$LPLIB/process/g3post < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/g3post < $TMPFILE |$LPLIB/process/gspipeijs
	}

# bitmap for research UNIX compatibility, does not work on Plan 9.
case bitmap;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/bpost < $TMPFILE
	case *mhcc*;	$LPLIB/process/bpost < $TMPFILE | $LPLIB/process/mhcc
	case *;		echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case tex;
	mv $TMPFILE $TMPFILE.dvi
	TMPFILE=$TMPFILE.dvi
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/dvipost $TMPFILE
	case *gs!*;	$LPLIB/process/dvipost $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/dvipost $TMPFILE |$LPLIB/process/gspipeijs
	case *;		echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case postscript;
	switch ($LPCLASS) {
	case *post*;		$LPLIB/process/post < $TMPFILE
	case *gs!*;		$LPLIB/process/post < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;		$LPLIB/process/post < $TMPFILE |$LPLIB/process/gspipeijs
	case *;			echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case HPJCL;
	switch ($LPCLASS) {
	case *HPJCL*;		$LPLIB/process/noproc < $TMPFILE
	case *;			echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case daisy;
	switch ($LPDEST) {
	case *;		echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
	}
case English short extended alef limbo [Aa]scii assembler c latin rc sh as mail email message/rfc822;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/ppost < $TMPFILE
	case *gs!*;	$LPLIB/process/ppost < $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/ppost < $TMPFILE |$LPLIB/process/gspipeijs
	case *canon*;	$LPLIB/process/can $* < $TMPFILE
	case *;		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}

case tiff;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/tiffpost $TMPFILE
	case *gs!*;	$LPLIB/process/tiffpost $TMPFILE |$LPLIB/process/gspipe
	case *gsijs!*;	$LPLIB/process/tiffpost $TMPFILE |$LPLIB/process/gspipeijs
	case *;		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}
case PDF;
	switch ($LPCLASS) {
	case *post*;	$LPLIB/process/pdfpost $TMPFILE
	case *gs!*;	$LPLIB/process/pdfgs $TMPFILE
	case *gsijs!*;	$LPLIB/process/pdfgsijs $TMPFILE
	case *;		echo Unrecognized class of line printer for $LPDEST >[1=2]
	}
case empty;
	echo file is empty >[1=2]
case cannot;
	echo cannot open file >[1=2]
case *;
	echo $FILETYPE(2) file is improper for $LPDEST >[1=2]
}
wait
rv=$status
rm -f $TMPFILE
#exit $status
exit
======================================

(4) add a file as /sys/lib/lp/process/gspipeijs as#!/bin/rc
======================================
# extended to IJS driver by K.Okamoto
if (! ~ $DEBUG '') flag x +

# usage: gspipeijs [dev]
# assumes postscript on stdin

switch($#*) {
case 0
	MANUF=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)(\+.*)?/\2/'}
	PRODCT=`{echo $LPCLASS | sed 's/(.*\+)?gsijs!([^+]*)\+(.*)?/\3/'}
case 1
	IJS=$1
case *
	echo 'usage: gspipeijs [dev]' >[1=2]
	exit gspipeijs
}

GSTMPFILE=/tmp/gsp$pid

GSOPT=(-q '-sDEVICE=ijs' '-sIjsServer='hpijs '-sDeviceModel='"$MANUF^' '^$PRODCT" '-sOutputFile='^$GSTMPFILE  '-sPAPERSIZE='a4 -dIjsUseOutputFD -dSAFER -dNOPAUSE )

gs $GSOPT  -

cat $GSTMPFILE
rm $GSTMPFILE

exit
======================================

(5) then, lp -dpsc2110 foo.ps

Lastly, I hate lp system of Plan 9!!!

Kenji



  reply	other threads:[~2003-10-20  1:38 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-17 15:20 mirtchov
2003-10-17 16:34 ` Skip Tavakkolian
2003-10-17 17:08   ` Joel Salomon
2003-10-17 18:55     ` Brantley Coile
2003-10-17 19:05       ` matt
2003-10-17 20:17       ` ron minnich
2003-10-17 20:20         ` Christopher Nielsen
2003-10-17 20:26         ` Brantley Coile
2003-10-17 20:41           ` Charles Forsyth
2003-10-17 20:54             ` Brantley Coile
2003-10-20 10:33             ` Douglas A. Gwyn
2003-10-20 16:03               ` Skip Tavakkolian
2003-10-21  6:07                 ` Adrian Tritschler
2003-10-17 22:18           ` ron minnich
2003-10-20  1:38             ` okamoto [this message]
2003-10-17 21:36         ` Roman Shaposhnick
2003-10-20 10:33           ` Douglas A. Gwyn
2003-10-21  0:10             ` [9fans] Re: your mail Roman Shaposhnick
2003-10-17 23:38       ` [9fans] porting from vs. porting to Plan 9 Geoff Collyer
2003-10-18  1:21         ` bs
2003-10-21 10:14           ` Martin C.Atkins
2003-10-18  8:27         ` Charles Forsyth
2003-10-18  8:48           ` Richard Miller
2003-10-18 11:09           ` Geoff Collyer
2003-10-18 13:09             ` Tristan Seligmann
2003-10-19  8:25               ` C H Forsyth
2003-10-20  3:28                 ` mirtchov
2003-10-20  7:04                   ` Tristan Seligmann
2003-10-20 17:17                     ` mirtchov
2003-10-20 10:35                   ` Patrick R. Wade
2003-10-21  1:14                     ` david parsons
2003-10-19 16:27             ` Charles Forsyth
2003-10-20 10:35             ` bs
2003-10-18 19:19           ` Richard Miller
2003-10-19 15:10             ` I RATTAN
2003-10-19 15:54               ` Richard Miller
2003-10-20 14:03             ` ron minnich
2003-10-20 17:03               ` jmk
2003-10-20 21:40         ` splite
2003-10-17 16:43 ` Ronald G. Minnich
2003-10-17 17:01   ` Fco.J.Ballesteros
2003-10-17 20:17     ` Christopher Nielsen
2003-10-20 10:33       ` Douglas A. Gwyn
2003-10-17 15:36 steve-simon
2003-10-17 16:05 Richard C Bilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d0865472e80d74ad6f64b136f59510da@granite.cias.osakafu-u.ac.jp \
    --to=okamoto@granite.cias.osakafu-u.ac.jp \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).