(FILECREATED " 4-Sep-85 18:40:13" {ERIS}<LISPCORE>DIG>CENTRONICS.;8 5213   

      changes to:  (FNS CENTRONICS.RESET \CENTRONICS.OPENFILE \CreateCentronicsDevice 
			\CENTRONICS.CLOSEFILE \CENTRONICS.EVENTFN \CENTRONICS.BUSYWAIT 
			\CENTRONICS.BOUT)
		   (VARS CENTRONICSCOMS)

      previous date: "14-Aug-85 16:14:15" {ERIS}<LISPCORE>DIG>CENTRONICS.;5)


(* Copyright (c) 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT CENTRONICSCOMS)

(RPAQQ CENTRONICSCOMS [(FNS CENTRONICS.RESET CENTRONICS.BUSYWAIT)
		       (FNS \CreateCentronicsDevice \CENTRONICS.OPENFILE \CENTRONICS.CLOSEFILE 
			    \CENTRONICS.BOUT \CENTRONICS.BUSYWAIT \CENTRONICS.EVENTFN)
		       (DECLARE: DONTEVAL@LOAD DOCOPY (P (\CreateCentronicsDevice])
(DEFINEQ

(CENTRONICS.RESET
  [LAMBDA (C150STREAM)                                       (* hdj " 4-Sep-85 18:28")

          (* * only do it if we're talking about the real centronics device, and not a disk file or something)


    (if (OR (NULL C150STREAM)
	    (EQ (fetch (FDEV DEVICENAME) of (fetch (STREAM DEVICE) of C150STREAM))
		(QUOTE CENTRONICS)))
	then (WRITEPRINTERPORT 40960)
	     (WRITEPRINTERPORT 32768)
	     (DISMISS 1)                                     (* 32768 means init printer)
	     (WRITEPRINTERPORT 40960)                        (* turn off initialization and control lines)
	     NIL])

(CENTRONICS.BUSYWAIT
  [LAMBDA NIL                                                (* edited: "16-Jul-85 14:54")
    (PROG (C150STATUSLINE)
      RETRY
          (SETQ C150STATUSLINE (LOGAND (READPRINTERPORT)
				       31744))               (* If printer is busy, return T)
                                                             (* If other than busy, then there is an error)
          (RETURN (if (EQ C150STATUSLINE 8192)
		      then T
		    else (if (NEQ (LOGAND (READPRINTERPORT)
					  31744)
				  24576)
			     then (PRINTOUT PROMPTWINDOW "Printer error" T)
				  (HELP "Printer error - type (RETURN) to continue")
				  (GO RETRY])
)
(DEFINEQ

(\CreateCentronicsDevice
  [LAMBDA NIL                                                (* hdj " 4-Sep-85 17:35")
    (LET [(DEVICE (create FDEV
			  DEVICENAME ←(QUOTE CENTRONICS)
			  EVENTFN ←(FUNCTION \CENTRONICS.EVENTFN)
			  BOUT ←(FUNCTION \CENTRONICS.BOUT)
			  OPENFILE ←(FUNCTION \CENTRONICS.OPENFILE)
			  CLOSEFILE ←(FUNCTION \CENTRONICS.CLOSEFILE]
         (\DEFINEDEVICE (QUOTE CENTRONICS)
			DEVICE)
     DEVICE])

(\CENTRONICS.OPENFILE
  [LAMBDA (NAME ACCESS RECOG PARAMETERS DEVICE)              (* hdj " 4-Sep-85 17:52")
    (if (OR (EQ ACCESS (QUOTE OUTPUT))
	    (EQ ACCESS (QUOTE APPEND)))
	then [LET ((OLDSTREAM (fetch (FDEV DEVICEINFO) of DEVICE)))
	          (if OLDSTREAM
		      then (ERROR "Only one open stream allowed on this device" NAME)
		    else (replace (FDEV DEVICEINFO) of DEVICE
			    with (create STREAM
					 DEVICE ← DEVICE
					 FULLFILENAME ←(QUOTE {CENTRONICS}]
      else NIL])

(\CENTRONICS.CLOSEFILE
  [LAMBDA (STREAM)                                           (* hdj " 4-Sep-85 17:30")
    (replace (FDEV DEVICEINFO) of (fetch (STREAM DEVICE) of STREAM) with NIL])

(\CENTRONICS.BOUT
  [LAMBDA (STREAM BYTE)                                      (* hdj " 4-Sep-85 16:31")
    (if (NEQ (LOGAND (READPRINTERPORT)
		     31744)
	     24576)
	then (while (\CENTRONICS.BUSYWAIT)))                 (* Check if printer is busy)
    (LET ((C150DATANOSTB (LOGOR BYTE 40960)))                (* Send data, turn off strobe signal)
         (WRITEPRINTERPORT C150DATANOSTB)
         (WRITEPRINTERPORT (LOGAND 32767 C150DATANOSTB))     (* Send data, turn on strobe signal)
         (WRITEPRINTERPORT C150DATANOSTB))                   (* Turn off strobe signal)
    NIL])

(\CENTRONICS.BUSYWAIT
  [LAMBDA NIL                                                (* edited: "16-Jul-85 14:54")
    (PROG (C150STATUSLINE)
      RETRY
          (SETQ C150STATUSLINE (LOGAND (READPRINTERPORT)
				       31744))               (* If printer is busy, return T)
                                                             (* If other than busy, then there is an error)
          (RETURN (if (EQ C150STATUSLINE 8192)
		      then T
		    else (if (NEQ (LOGAND (READPRINTERPORT)
					  31744)
				  24576)
			     then (PRINTOUT PROMPTWINDOW "Printer error" T)
				  (HELP "Printer error - type (RETURN) to continue")
				  (GO RETRY])

(\CENTRONICS.EVENTFN
  [LAMBDA (DEVICE EVENT)                                     (* hdj " 4-Sep-85 16:34")
    (SELECTQ EVENT
	     ((AFTERLOGOUT AFTERSYSOUT AFTERMAKESYS)
	       (CENTRONICS.RESET))
	     NIL])
)
(DECLARE: DONTEVAL@LOAD DOCOPY 
(\CreateCentronicsDevice)
)
(PUTPROPS CENTRONICS COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (753 2173 (CENTRONICS.RESET 763 . 1443) (CENTRONICS.BUSYWAIT 1445 . 2171)) (2174 5072 (
\CreateCentronicsDevice 2184 . 2650) (\CENTRONICS.OPENFILE 2652 . 3229) (\CENTRONICS.CLOSEFILE 3231 . 
3447) (\CENTRONICS.BOUT 3449 . 4111) (\CENTRONICS.BUSYWAIT 4113 . 4840) (\CENTRONICS.EVENTFN 4842 . 
5070)))))
STOP