[comp.periphs.printers] How do you send NUL to a printer?

bill@twg.bc.ca (Bill Irwin) (05/31/91)

I'm having a problem sending codes to an Okidata 393 printer to
change the form length.  For this Oki there are two ways you can
do it: either set the form length in inches or lines.

Inches: ESC C NUL 11    [set to 11 inch form]

Lines:  ESC C 66        [set 66 lines per page]

The only difference is the NUL in the inches setting.  The way I
have been trying to send this is with:

echo -n "^[C\000011"

When this is directed to a file and viewed with vi, I get:

^[C11

Is the NUL supposed to show in vi?  When this is sent to the
printer it behaves as though it was sent the Lines setting
command, without the NUL.  Is it possible that the NUL is getting
trapped by the system?
-- 
Bill Irwin    -       The Westrheim Group     -    Vancouver, BC, Canada
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uunet!van-bc!twg!bill     (604) 431-9600 (voice) |     Your Computer  
bill@twg.bc.ca            (604) 430-4329 (fax)   |    Systems Partner

mjm@eleazar.dartmouth.edu (Andy Behrens) (06/01/91)

bill@twg.bc.ca (Bill Irwin) writes:
>  [I have been trying to send a NUL to a printer using]
>  echo -n "^[C\000011"
>  
>  When this is directed to a file and viewed with vi, I get:
>  
>  ^[C11
> 
>  Is the NUL supposed to show in vi?  When this is sent to the
>  printer it behaves as though it was sent the Lines setting
>  command, without the NUL.  

Vi won't show you the NUL characters even though they're in the file, but 'od -c' will.  

However, that isn't where your problem lies.  Many terminal drivers
will discard NUL characters on output.  You can fool them by sending
\200 instead: it won't be discarded, but the high-order bit will be
deleted before the printer sees it.

Try 
	echo -n "^[C\020011"

instead.


--
If you've got a hammer,			       If the only tool you have
find a nail.				    is a hammer, you tend to see
(George Bush, January 29, 1991)			every problem as a nail.
							(Abraham Maslow)
+-------------------+
|  Andy Behrens     |                   or: andyb%coat.com@dartmouth.edu
|  andyb@coat.com   |                    bitnet: andyb%coat.com@dartcms1
+-------------------+       uucp: {uunet,rutgers}!dartvax!coat.com!andyb
    

clewis@ferret.ocunix.on.ca (Chris Lewis) (06/01/91)

In article <2291@twg.bc.ca> bill@twg.bc.ca (Bill Irwin) writes:
>Inches: ESC C NUL 11    [set to 11 inch form]

>The only difference is the NUL in the inches setting.  The way I
>have been trying to send this is with:

>echo -n "^[C\000011"

The above is a little odd - the "-n" implies a Berkeley style
echo, but \ escapes aren't in Berkeley echo - they are in the
System V echo.

>When this is directed to a file and viewed with vi, I get:

>^[C11

>Is the NUL supposed to show in vi?  When this is sent to the
>printer it behaves as though it was sent the Lines setting
>command, without the NUL.  Is it possible that the NUL is getting
>trapped by the system?

When I try this with a System V echo, the NUL works, but the -n doesn't.
vi *doesn't* show the NUL (even with the "l" command), but it is there.
Run "od -c" on the output and you'll see the null sitting there.  On the
other hand, ^[ *isn't* escape in System V echo.  On my machine (System V,
Xenix machines should be similar), this works:

	echo "\033\000011\c"

Don't rely on vi to show you any sort of reliable representation of
non-printable-ASCII characters.  Use "od" for that.
-- 
Chris Lewis, Phone: (613) 832-0541, Domain: clewis@ferret.ocunix.on.ca
UUCP: ...!cunews!latour!ecicrl!clewis; Ferret Mailing List:
ferret-request@eci386; Psroff (not Adobe Transcript) enquiries:
psroff-request@eci386 or Canada 416-832-0541.  Psroff 3.0 in c.s.u soon!