(FILECREATED "12-Nov-85 18:56:23" {ERIS}<LISPCORE>LIBRARY>DLTTY.;12 40301  

      changes to:  (VARS DLTTYCOMS DLTTYCOMMANDS DLTTYOUTCOMMANDS DLTTYSETPARAMETERCOMMANDS DVTTYBITS)
		   (RECORDS DLTTY.IN.CSB DLTTY.OUT.COMMAND DLTTY.OUT.CSB DLTTY.SETPARAMETER.COMMAND 
			    Dove.TTYFCB)

      previous date: "29-Oct-85 13:59:17" {ERIS}<LISPCORE>LIBRARY>DLTTY.;11)


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

(PRETTYCOMPRINT DLTTYCOMS)

(RPAQQ DLTTYCOMS ((COMS (* DLion TTY/Printer port head)
			  (DECLARE: DONTCOPY (EXPORT (CONSTANTS * DLTTYCOMMANDS)
						     (CONSTANTS * DLTTYOUTCOMMANDS)
						     (CONSTANTS * DLTTYSETPARAMETERCOMMANDS)
						     (RECORDS DLTTY.IN.CSB DLTTY.OUT.COMMAND 
							      DLTTY.OUT.CSB 
							      DLTTY.SETPARAMETER.COMMAND)))
			  (INITVARS (\DLTTY.BAUD.RATES (QUOTE ((50 . 0)
							       (75 . 1)
							       (110 . 2)
							       (134.5 . 3)
							       (150 . 4)
							       (300 . 5)
							       (600 . 6)
							       (1200 . 7)
							       (1800 . 8)
							       (2000 . 9)
							       (2400 . 10)
							       (3600 . 11)
							       (4800 . 12)
							       (7200 . 13)
							       (9600 . 14)
							       (19200 . 15))))
				    (\DLTTY.INVERSE.BAUD.RATES (QUOTE ((0 . 50)
								       (1 . 75)
								       (2 . 110)
								       (3 . 134.5)
								       (4 . 150)
								       (5 . 300)
								       (6 . 600)
								       (7 . 1200)
								       (8 . 1800)
								       (9 . 2000)
								       (10 . 2400)
								       (11 . 3600)
								       (12 . 4800)
								       (13 . 7200)
								       (14 . 9600)
								       (15 . 19200)))))
			  (RECORDS RS232C.INIT RS232C.XONXOFF)
			  (INITVARS (\DLTTY.STATE 0)
				    (\DLTTY.FLOWCONTROL (create RS232C.XONXOFF FLAG ← 1 XON.CHAR ←
								(CHARCODE ↑Q)
								XOFF.CHAR ← (CHARCODE ↑S))))
			  (ADDVARS (GLOBALVARS \DLTTY.BAUD.RATES \DLTTY.INVERSE.BAUD.RATES 
					       \DLTTY.STATE \DLTTY.FLOWCONTROL))
			  (FNS \DLTTY.BIN \DLTTY.BOUT \DLTTY.GET.PARAMETERS \DLTTY.INIT \DLTTY.READP 
			       \DLTTY.SET.PARAMETERS \DLTTY.SHUTDOWN))
		    (COMS (* Daybreak head)
			  (DECLARE: DONTCOPY (FILES (SOURCE)
						    DOVERS232C)
				    (EXPORT (RECORDS Dove.TTYFCB)
					    (CONSTANTS * DVTTYBITS)))
			  (INITVARS (\DoveTTY.FCBPointer)
				    (\DVTTY.BAUD.RATES (QUOTE ((50 . 5000)
							       (75 . 3334)
							       (110 . 2272)
							       (150 . 1667)
							       (300 . 833)
							       (600 . 417)
							       (1200 . 208)
							       (1800 . 138)
							       (2000 . 126)
							       (2400 . 104)
							       (3600 . 69)
							       (4800 . 52)
							       (7200 . 35)
							       (9600 . 26)
							       (19200 . 13))))
				    (\DVTTY.INVERSE.BAUD.RATES (QUOTE ((5000 . 50)
								       (3334 . 75)
								       (2272 . 110)
								       (1667 . 150)
								       (833 . 300)
								       (417 . 600)
								       (208 . 1200)
								       (138 . 1800)
								       (126 . 2000)
								       (104 . 2400)
								       (69 . 3600)
								       (52 . 4800)
								       (35 . 7200)
								       (26 . 9600)
								       (13 . 19200)))))
			  (GLOBALVARS \DoveTTY.FCBPointer \DVTTY.INVERSE.BAUD.RATES \DVTTY.BAUD.RATES)
			  (FNS \DVTTY.BIN \DVTTY.BOUT \DVTTY.INIT \DVTTY.SET.PARAMETERS \DVTTY.READP 
			       \DVTTY.GET.PARAMETERS \DVTTY.SHUTDOWN))
		    (COMS (* Machine independant face; for DLion and DayBreak)
			  (DECLARE: DONTCOPY (FILES (LOADCOMP)
						    DLRS232C))
			  (INITVARS (\TTY.FDEV)
				    (\TTYFLG)
				    (\TTY.READY))
			  (ADDVARS (GLOBALVARS \TTY.FDEV \TTYFLG \TTY.READY))
			  (DECLARE: DONTCOPY (EXPORT (RECORDS TTYSTREAM)))
			  (FNS \TTY.CREATE.FDEV \TTY.EVENTFN \TTY.BIN \TTY.BOUT \TTY.READP 
			       \TTY.CLOSEFILE \TTY.OPENFILE))
		    (COMS (* Machine independant user face)
			  (INITVARS (TTY.DEFAULT.INIT.INFO (create RS232C.INIT BaudRate ← 1200 
								   BitsPerSerialChar ← 8 Parity ←
								   (QUOTE NONE)
								   NoOfStopBits ← 1 FlowControl ← 
								   \DLTTY.FLOWCONTROL))
				    (TTY.ERROR.STREAM PROMPTWINDOW))
			  (GLOBALVARS TTY.DEFAULT.INIT.INFO TTY.ERROR.STREAM)
			  (FNS TTY.INIT TTY.GET.PARAMETERS TTY.SET.PARAMETERS TTY.RESET.STREAMS 
			       TTY.SHUTDOWN))))



(* DLion TTY/Printer port head)

(DECLARE: DONTCOPY 
(* FOLLOWING DEFINITIONS EXPORTED)



(RPAQQ DLTTYCOMMANDS ((TTY.GET.STATUS 33280)
			(TTY.ON 33536)
			(TTY.OFF 33792)
			(TTY.BREAK.ON 34304)
			(TTY.BREAK.OFF 34560)))
(DECLARE: EVAL@COMPILE 

(RPAQQ TTY.GET.STATUS 33280)

(RPAQQ TTY.ON 33536)

(RPAQQ TTY.OFF 33792)

(RPAQQ TTY.BREAK.ON 34304)

(RPAQQ TTY.BREAK.OFF 34560)

(CONSTANTS (TTY.GET.STATUS 33280)
	   (TTY.ON 33536)
	   (TTY.OFF 33792)
	   (TTY.BREAK.ON 34304)
	   (TTY.BREAK.OFF 34560))
)

(RPAQQ DLTTYOUTCOMMANDS ((PUT.CHAR 128)
			   (ABORT.PUT 133)))
(DECLARE: EVAL@COMPILE 

(RPAQQ PUT.CHAR 128)

(RPAQQ ABORT.PUT 133)

(CONSTANTS (PUT.CHAR 128)
	   (ABORT.PUT 133))
)

(RPAQQ DLTTYSETPARAMETERCOMMANDS ((SET.DSR 33025)
				    (SET.CTS 33026)
				    (SET.CHAR.LENGTH 33028)
				    (SET.PARITY 33032)
				    (SET.STOP.BITS 33040)
				    (SET.BAUD.RATE 33056)
				    (SET.ALL.PARAMETERS 33087)))
(DECLARE: EVAL@COMPILE 

(RPAQQ SET.DSR 33025)

(RPAQQ SET.CTS 33026)

(RPAQQ SET.CHAR.LENGTH 33028)

(RPAQQ SET.PARITY 33032)

(RPAQQ SET.STOP.BITS 33040)

(RPAQQ SET.BAUD.RATE 33056)

(RPAQQ SET.ALL.PARAMETERS 33087)

(CONSTANTS (SET.DSR 33025)
	   (SET.CTS 33026)
	   (SET.CHAR.LENGTH 33028)
	   (SET.PARITY 33032)
	   (SET.STOP.BITS 33040)
	   (SET.BAUD.RATE 33056)
	   (SET.ALL.PARAMETERS 33087))
)
[DECLARE: EVAL@COMPILE 

(ACCESSFNS DLTTY.IN.CSB ((TTYINBASE (LOCF (fetch (IOPAGE DLTTYIN) of DATUM))))
			  (BLOCKRECORD TTYINBASE ((IN.CONTROL WORD)
					  (IN.DATA BYTE)
					  (DATA.TERMINAL.READY FLAG)
					  (NIL BITS 4)
					  (REQUEST.TO.SEND FLAG)
					  (RX.READY FLAG)
					  (TX.READY FLAG)))
			  (BLOCKRECORD TTYINBASE ((STATE FLAG)
					  (NIL BITS 7)
					  (SUCCESS FLAG)
					  (BREAK.DETECTED FLAG)
					  (FRAMING.ERROR FLAG)
					  (DATA.LOST FLAG)
					  (PARITY.ERROR FLAG)
					  (NIL BITS 2)
					  (NOT.READY FLAG))))

(ACCESSFNS DLTTY.OUT.COMMAND ((COMMANDBASE (LOCF (fetch (IOPAGE DLTTYPORTCMD) of DATUM))))
			       (BLOCKRECORD COMMANDBASE ((COMMAND BYTE)
					       (OUTDATA BYTE))))

(ACCESSFNS DLTTY.OUT.CSB ((TTYOUTBASE (LOCF (fetch (IOPAGE DLTTYOUT) of DATUM))))
			   (BLOCKRECORD TTYOUTBASE ((PARAMETER WORD)
					   (NOTIFY.MASK WORD)))
			   (BLOCKRECORD TTYOUTBASE ((ON.OFF BITS 4)
					   (LINE.SPEED BITS 4)
					   (STOP.BITS BITS 2)
					   (PARITY BITS 2)
					   (CHAR.LENGTH BITS 2)
					   (CLEAR.TO.SEND FLAG)
					   (DATA.SET.READY FLAG))))

(ACCESSFNS DLTTY.SETPARAMETER.COMMAND ((COMMANDBASE (LOCF (fetch (IOPAGE DLTTYPORTCMD)
							       of DATUM))))
					(BLOCKRECORD COMMANDBASE ((COMMAND WORD))))
]


(* END EXPORTED DEFINITIONS)

)

(RPAQ? \DLTTY.BAUD.RATES (QUOTE ((50 . 0)
				   (75 . 1)
				   (110 . 2)
				   (134.5 . 3)
				   (150 . 4)
				   (300 . 5)
				   (600 . 6)
				   (1200 . 7)
				   (1800 . 8)
				   (2000 . 9)
				   (2400 . 10)
				   (3600 . 11)
				   (4800 . 12)
				   (7200 . 13)
				   (9600 . 14)
				   (19200 . 15))))

(RPAQ? \DLTTY.INVERSE.BAUD.RATES (QUOTE ((0 . 50)
					   (1 . 75)
					   (2 . 110)
					   (3 . 134.5)
					   (4 . 150)
					   (5 . 300)
					   (6 . 600)
					   (7 . 1200)
					   (8 . 1800)
					   (9 . 2000)
					   (10 . 2400)
					   (11 . 3600)
					   (12 . 4800)
					   (13 . 7200)
					   (14 . 9600)
					   (15 . 19200))))
[DECLARE: EVAL@COMPILE 

(RECORD RS232C.INIT (BaudRate BitsPerSerialChar Parity NoOfStopBits FlowControl))

(RECORD RS232C.XONXOFF (FLAG XON.CHAR XOFF.CHAR))
]

(RPAQ? \DLTTY.STATE 0)

(RPAQ? \DLTTY.FLOWCONTROL (create RS232C.XONXOFF FLAG ← 1 XON.CHAR ← (CHARCODE ↑Q)
				    XOFF.CHAR ← (CHARCODE ↑S)))

(ADDTOVAR GLOBALVARS \DLTTY.BAUD.RATES \DLTTY.INVERSE.BAUD.RATES \DLTTY.STATE \DLTTY.FLOWCONTROL)
(DEFINEQ

(\DLTTY.BIN
  (LAMBDA (STREAM)                                           (* ejs: " 8-Sep-85 17:58")
    (bind CHAR GOTCHAR NOTOPEN until GOTCHAR
       do (until (OR (fetch (DLTTY.IN.CSB STATE) of \IOPAGE)
		     (SETQ NOTOPEN (NOT (READABLE STREAM))))
	     do (BLOCK))
	  (COND
	    (NOTOPEN (RETURN (\EOF.ACTION STREAM))))
	  (SETQ CHAR (fetch (DLTTY.IN.CSB IN.DATA) of \IOPAGE))
	  (replace (DLTTY.IN.CSB STATE) of \IOPAGE with NIL)
	  (COND
	    (\DLTTY.FLOWCONTROL (COND
				  ((EQ CHAR (fetch (RS232C.XONXOFF XOFF.CHAR) of \DLTTY.FLOWCONTROL))
				    (replace (TTYSTREAM OUTPUTHELD) of STREAM with T))
				  ((EQ CHAR (fetch (RS232C.XONXOFF XON.CHAR) of \DLTTY.FLOWCONTROL))
				    (replace (TTYSTREAM OUTPUTHELD) of STREAM with NIL))
				  (T (SETQ GOTCHAR T))))
	    (T (SETQ GOTCHAR T)))
       finally (RETURN CHAR))))

(\DLTTY.BOUT
  (LAMBDA (STREAM BYTE)                                      (* ejs: "28-Aug-85 12:15")
    (while (IGEQ (fetch (DLTTY.OUT.COMMAND COMMAND) of \IOPAGE)
		 PUT.CHAR)
       do (BLOCK))
    (COND
      ((fetch (TTYSTREAM OUTPUTHELD) of STREAM)
	(do (COND
	      ((READP STREAM)
		(COND
		  ((EQ (fetch (DLTTY.IN.CSB IN.DATA) of \IOPAGE)
		       (fetch (RS232C.XONXOFF XON.CHAR) of \DLTTY.FLOWCONTROL))
		    (replace (TTYSTREAM OUTPUTHELD) of STREAM with NIL)
		    (RETURN)))
		(replace (DLTTY.IN.CSB STATE) of \IOPAGE with NIL)))
	    (BLOCK))))
    (replace (DLTTY.OUT.COMMAND OUTDATA) of \IOPAGE with (LOGAND BYTE (MASK.1'S 0 8)))
    (replace (DLTTY.OUT.COMMAND COMMAND) of \IOPAGE with PUT.CHAR)
    T))

(\DLTTY.GET.PARAMETERS
  (LAMBDA (PARAMETERLIST)                                    (* ejs: " 8-Sep-85 17:00")

          (* * Return requested parameters in ALIST format)


    (for PARAMETER in PARAMETERLIST
       collect (SELECTQ PARAMETER
			((STOP.BITS NoOfStopBits)
			  (CONS PARAMETER (CDR (FASSOC (fetch (DLTTY.OUT.CSB STOP.BITS) of \IOPAGE)
						       (QUOTE ((0 . 0)
								(1 . 1)
								(2 . 1.5)
								(3 . 2)))))))
			((PARITY Parity)
			  (CONS PARAMETER (CDR (FASSOC (fetch (DLTTY.OUT.CSB PARITY) of \IOPAGE)
						       (QUOTE ((0 . NONE)
								(1 . ODD)
								(3 . EVEN)))))))
			((CHAR.LENGTH BitsPerSerialChar)
			  (CONS PARAMETER (IPLUS 5 (fetch (DLTTY.OUT.CSB CHAR.LENGTH) of \IOPAGE))))
			((LINE.SPEED BaudRate)
			  (CONS PARAMETER (CDR (FASSOC (fetch (DLTTY.OUT.CSB LINE.SPEED)
							  of \IOPAGE)
						       \DLTTY.INVERSE.BAUD.RATES))))
			((DATA.SET.READY DSR)
			  (CONS PARAMETER (fetch (DLTTY.OUT.CSB DATA.SET.READY) of \IOPAGE)))
			((CLEAR.TO.SEND CTS)
			  (CONS PARAMETER (fetch (DLTTY.OUT.CSB CLEAR.TO.SEND) of \IOPAGE)))
			((FLOW.CONTROL FlowControl)
			  (CONS PARAMETER (COND
				  ((EQUAL \DLTTY.FLOWCONTROL
					  (CONSTANT (create RS232C.XONXOFF
							    FLAG ← 1
							    XON.CHAR ←(CHARCODE ↑Q)
							    XOFF.CHAR ←(CHARCODE ↑S))))
				    (QUOTE XOnXOff))
				  (T \DLTTY.FLOWCONTROL))))
			NIL))))

(\DLTTY.INIT
  (LAMBDA (BAUDRATE BITSPERCHAR PARITY STOPBITS FLOWCONTROL)
                                                             (* ejs: " 8-Sep-85 16:32")
    (SETQ \TTY.READY NIL)
    (\TTY.CREATE.FDEV (create RS232C.INIT
			      BaudRate ← BAUDRATE
			      BitsPerSerialChar ← BITSPERCHAR
			      Parity ← PARITY
			      NoOfStopBits ← STOPBITS
			      FlowControl ← FLOWCONTROL))
    (replace (DLTTY.OUT.COMMAND COMMAND) of \IOPAGE with ABORT.PUT)
    (replace (DLTTY.OUT.CSB NOTIFY.MASK) of \IOPAGE with 0)
    (replace (DLTTY.IN.CSB DATA.TERMINAL.READY) of \IOPAGE with NIL)
    (replace (DLTTY.IN.CSB REQUEST.TO.SEND) of \IOPAGE with NIL)
    (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE with TTY.ON)
    (while (IGEQ (fetch (DLTTY.OUT.COMMAND COMMAND) of \IOPAGE)
		 PUT.CHAR)
       do (BLOCK))
    (SETQ \DLTTY.STATE (replace (DLTTY.OUT.CSB PARAMETER) of \IOPAGE with 0))
    (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE with SET.ALL.PARAMETERS)
    (\DLTTY.SET.PARAMETERS (BQUOTE ((LINE.SPEED ,@ BAUDRATE)
				    (CHAR.LENGTH ,@ BITSPERCHAR)
				    (PARITY ,@ PARITY)
				    (STOP.BITS ,@ STOPBITS)
				    (FLOW.CONTROL ,@ FLOWCONTROL))))
    (SETQ \TTYFLG T)
    (SETQ \TTY.READY T)))

(\DLTTY.READP
  (LAMBDA (STREAM)                                           (* ejs: "27-Aug-85 16:21")
    (fetch (DLTTY.IN.CSB STATE) of \IOPAGE)))

(\DLTTY.SET.PARAMETERS
  (LAMBDA (PARAMETERLIST)                                    (* ejs: " 8-Sep-85 17:04")
    (bind PARAMETER VALUE for PARAMPAIR in PARAMETERLIST
       do (while (IGEQ (fetch (DLTTY.OUT.COMMAND COMMAND) of \IOPAGE)
		       PUT.CHAR)
	     do (BLOCK))
	  (SETQ PARAMETER (CAR PARAMPAIR))
	  (SETQ VALUE (CDR PARAMPAIR))
	  (SELECTQ PARAMETER
		   ((STOP.BITS NoOfStopBits)
		     (LET ((SBVALUE (CDR (SASSOC VALUE (QUOTE ((0 . 0)
								(1 . 1)
								(1.5 . 2)
								(2 . 3)))))))
		          (COND
			    (SBVALUE (replace (RS232C.INIT NoOfStopBits) of TTY.DEFAULT.INIT.INFO
					with VALUE)
				     (replace (DLTTY.OUT.CSB STOP.BITS) of \IOPAGE with SBVALUE)
				     (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE
					with SET.STOP.BITS)))))
		   ((PARITY Parity)
		     (LET ((PARVALUE (CDR (FASSOC VALUE (QUOTE ((NONE . 0)
								 (ODD . 1)
								 (EVEN . 3)))))))
		          (COND
			    (PARVALUE (replace (RS232C.INIT Parity) of TTY.DEFAULT.INIT.INFO
					 with VALUE)
				      (replace (DLTTY.OUT.CSB PARITY) of \IOPAGE with PARVALUE)
				      (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE
					 with SET.PARITY)))))
		   ((CHAR.LENGTH BitsPerSerialChar)
		     (LET ((LVALUE (IDIFFERENCE VALUE 5)))
		          (COND
			    ((AND (IGEQ LVALUE 0)
				  (ILEQ LVALUE 3))
			      (replace (RS232C.INIT BitsPerSerialChar) of TTY.DEFAULT.INIT.INFO
				 with VALUE)
			      (replace (DLTTY.OUT.CSB CHAR.LENGTH) of \IOPAGE with LVALUE)
			      (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE with 
										  SET.CHAR.LENGTH)))))
		   ((LINE.SPEED BaudRate)
		     (LET ((BDVALUE (CDR (SASSOC VALUE \DLTTY.BAUD.RATES))))
		          (COND
			    (BDVALUE (replace (RS232C.INIT BaudRate) of TTY.DEFAULT.INIT.INFO
					with VALUE)
				     (replace (DLTTY.OUT.CSB LINE.SPEED) of \IOPAGE with BDVALUE)
				     (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE
					with SET.BAUD.RATE)))))
		   ((DATA.SET.READY DSR)
		     (replace (DLTTY.OUT.CSB DATA.SET.READY) of \IOPAGE with (NOT (NULL VALUE)))
		     (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE with SET.DSR))
		   ((CLEAR.TO.SEND CTS)
		     (replace (DLTTY.OUT.CSB CLEAR.TO.SEND) of \IOPAGE with (NOT (NULL VALUE)))
		     (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE with SET.CTS))
		   ((FLOW.CONTROL FlowControl)
		     (replace (RS232C.INIT FlowControl) of TTY.DEFAULT.INIT.INFO with VALUE)
		     (SETQ \DLTTY.FLOWCONTROL (COND
			 ((EQ VALUE (QUOTE XOnXOff))
			   (CONSTANT (create RS232C.XONXOFF
					     FLAG ← 1
					     XON.CHAR ←(CHARCODE ↑Q)
					     XOFF.CHAR ←(CHARCODE ↑S))))
			 (T VALUE))))
		   NIL))
    (SETQ \DLTTY.STATE (fetch (DLTTY.OUT.CSB PARAMETER) of \IOPAGE))))

(\DLTTY.SHUTDOWN
  (LAMBDA NIL                                                (* ejs: "27-Aug-85 18:59")
    (while (IGEQ (fetch (DLTTY.OUT.COMMAND COMMAND) of \IOPAGE)
		 PUT.CHAR)
       do (BLOCK))
    (replace (DLTTY.SETPARAMETER.COMMAND COMMAND) of \IOPAGE with TTY.OFF)
    (SETQ \DLTTY.STATE (fetch (DLTTY.OUT.CSB PARAMETER) of \IOPAGE))
    (SETQ \TTYFLG (SETQ \TTY.READY NIL))))
)



(* Daybreak head)

(DECLARE: DONTCOPY 
(FILESLOAD (SOURCE)
	   DOVERS232C)

(* FOLLOWING DEFINITIONS EXPORTED)


[DECLARE: EVAL@COMPILE 

(MESARECORD Dove.TTYFCB ((txTcb DoveIO.TaskContextBlock)
			   (specRxTcb DoveIO.TaskContextBlock)
			   (rxTaskChBTcb DoveIO.TaskContextBlock)
			   (ttyLockMask WORD)
			   (ttyWorkMask WORD)
			   (ttyClientCondition DoveIO.ClientCondition)
			   (ttyWorkCondition WORD)
			   (txBuffer BYTE)
			   (rxBuffer BYTE)
			   (ttyWorkList WORD)
			   (ttyBaudRate WORD)
			   (wr1.waitEnable FLAG)
			   (NIL BITS 1)
			   (wr1.waitOnRxOrTx BITS 1)
			   (wr1.interruptCondition BITS 2)
			   (wr1.statusAffectsVector FLAG)
			   (wr1.txIntDMAenable FLAG)
			   (wr1.extInterruptEnable FLAG)
			   (wr3.rxCharLength BITS 2)
			   (wr3.autoEnable FLAG)
			   (NIL BITS 4)
			   (wr3.rxEnable FLAG)
			   (wr4.clockRate BITS 2)
			   (NIL BITS 2)
			   (wr4.stopBits BITS 2)
			   (wr4.parity BITS 2)
			   (wr5.dataSetReady FLAG)
			   (wr5.txCharLength BITS 2)
			   (wr5.sendBreak FLAG)
			   (wr5.txEnable FLAG)
			   (NIL BITS 1)
			   (wr5.clearToSend FLAG)
			   (NIL BITS 1)
			   (NIL BITS 7)
			   (iopSystemInputPort.nDataTerminalReady FLAG)
			   (rr0.breakDetected FLAG)
			   (rr0.txUnderrun FLAG)
			   (rr0.requestToSend FLAG)
			   (rr0.syncDetected FLAG)
			   (rr0.carrierDetect FLAG)
			   (rr0.txBufferEmpty FLAG)
			   (rr0.interruptPending FLAG)
			   (rr0.rxCharAvailable FLAG)
			   (NIL BITS 1)
			   (rr1.asyncFramingError FLAG)
			   (rr1.rxOverrun FLAG)
			   (rr1.parityError FLAG)
			   (NIL BITS 3)
			   (rr1.txAllSent FLAG)
			   (rr2 BYTE)
			   (ttyStatusWord WORD)
			   (eePromImage 4 WORD)))
]

(RPAQQ DVTTYBITS ((writeBaudRate 32768)
		    (writeReg3 16384)
		    (writeReg4 8192)
		    (writeReg5 4096)
		    (workToBeDone 2048)
		    (writeReg1 1024)
		    (ttyChnlBOn 16384)
		    (ttyTxBufEmpty 8192)
		    (ttyRxBufFull 4096)
		    (ttyInterruptFail 512)
		    (ttyDataLost 256)))
(DECLARE: EVAL@COMPILE 

(RPAQQ writeBaudRate 32768)

(RPAQQ writeReg3 16384)

(RPAQQ writeReg4 8192)

(RPAQQ writeReg5 4096)

(RPAQQ workToBeDone 2048)

(RPAQQ writeReg1 1024)

(RPAQQ ttyChnlBOn 16384)

(RPAQQ ttyTxBufEmpty 8192)

(RPAQQ ttyRxBufFull 4096)

(RPAQQ ttyInterruptFail 512)

(RPAQQ ttyDataLost 256)

(CONSTANTS (writeBaudRate 32768)
	   (writeReg3 16384)
	   (writeReg4 8192)
	   (writeReg5 4096)
	   (workToBeDone 2048)
	   (writeReg1 1024)
	   (ttyChnlBOn 16384)
	   (ttyTxBufEmpty 8192)
	   (ttyRxBufFull 4096)
	   (ttyInterruptFail 512)
	   (ttyDataLost 256))
)


(* END EXPORTED DEFINITIONS)

)

(RPAQ? \DoveTTY.FCBPointer )

(RPAQ? \DVTTY.BAUD.RATES (QUOTE ((50 . 5000)
				   (75 . 3334)
				   (110 . 2272)
				   (150 . 1667)
				   (300 . 833)
				   (600 . 417)
				   (1200 . 208)
				   (1800 . 138)
				   (2000 . 126)
				   (2400 . 104)
				   (3600 . 69)
				   (4800 . 52)
				   (7200 . 35)
				   (9600 . 26)
				   (19200 . 13))))

(RPAQ? \DVTTY.INVERSE.BAUD.RATES (QUOTE ((5000 . 50)
					   (3334 . 75)
					   (2272 . 110)
					   (1667 . 150)
					   (833 . 300)
					   (417 . 600)
					   (208 . 1200)
					   (138 . 1800)
					   (126 . 2000)
					   (104 . 2400)
					   (69 . 3600)
					   (52 . 4800)
					   (35 . 7200)
					   (26 . 9600)
					   (13 . 19200))))
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS \DoveTTY.FCBPointer \DVTTY.INVERSE.BAUD.RATES \DVTTY.BAUD.RATES)
)
(DEFINEQ

(\DVTTY.BIN
  (LAMBDA (STREAM)                                           (* ejs: "29-Oct-85 13:58")
    (bind CHAR GOTCHAR NOTOPEN until GOTCHAR
       do (until (OR (BITTEST (\DoveIO.ByteSwap (fetch (Dove.TTYFCB ttyStatusWord)
							   of \DoveTTY.FCBPointer))
				    ttyRxBufFull)
			   (SETQ NOTOPEN (NOT (READABLE STREAM))))
	       do (BLOCK))
	    (COND
	      (NOTOPEN (RETURN (\EOF.ACTION STREAM))))
	    (SETQ CHAR (fetch (Dove.TTYFCB rxBuffer) of \DoveTTY.FCBPointer))
	    (replace (Dove.TTYFCB ttyStatusWord) of \DoveTTY.FCBPointer
	       with (\DoveIO.ByteSwap (BITCLEAR (\DoveIO.ByteSwap (fetch (Dove.TTYFCB 
										    ttyStatusWord)
									   of \DoveTTY.FCBPointer))
						    (LOGOR ttyDataLost ttyRxBufFull))))
	    (COND
	      (\DLTTY.FLOWCONTROL (COND
				    ((EQ CHAR (fetch (RS232C.XONXOFF XOFF.CHAR) of 
									       \DLTTY.FLOWCONTROL))
				      (replace (TTYSTREAM OUTPUTHELD) of STREAM with T))
				    ((EQ CHAR (fetch (RS232C.XONXOFF XON.CHAR) of 
									       \DLTTY.FLOWCONTROL))
				      (replace (TTYSTREAM OUTPUTHELD) of STREAM with NIL))
				    (T (SETQ GOTCHAR T))))
	      (T (SETQ GOTCHAR T)))
       finally (RETURN CHAR))))

(\DVTTY.BOUT
  (LAMBDA (STREAM BYTE)                                      (* ejs: "23-Oct-85 19:11")
    (while (NOT (BITTEST (\DoveIO.ByteSwap (fetch (Dove.TTYFCB ttyStatusWord) of 
									      \DoveTTY.FCBPointer))
			     ttyTxBufEmpty))
       do (BLOCK))
    (COND
      ((fetch (TTYSTREAM OUTPUTHELD) of STREAM)
	(do (COND
		((READP STREAM)
		  (COND
		    ((EQ (fetch (Dove.TTYFCB rxBuffer) of \DoveTTY.FCBPointer)
			   (fetch (RS232C.XONXOFF XON.CHAR) of \DLTTY.FLOWCONTROL))
		      (replace (TTYSTREAM OUTPUTHELD) of STREAM with NIL)
		      (RETURN)))
		  (replace (DLTTY.IN.CSB STATE) of \IOPAGE with NIL)))
	      (BLOCK))))
    (replace (Dove.TTYFCB txBuffer) of \DoveTTY.FCBPointer with (LOGAND BYTE
										(MASK.1'S 0 8)))
    (replace (Dove.TTYFCB ttyStatusWord) of \DoveTTY.FCBPointer
       with (\DoveIO.ByteSwap (BITCLEAR (fetch (Dove.TTYFCB ttyStatusWord) of 
									      \DoveTTY.FCBPointer)
					  ttyTxBufEmpty)))
    (\DoveIO.NotifyIOP (fetch (Dove.TTYFCB ttyWorkMask) of \DoveTTY.FCBPointer))
    T))

(\DVTTY.INIT
  (LAMBDA (BAUDRATE BITSPERCHAR PARITY STOPBITS FLOWCONTROL)
                                                             (* ejs: "23-Oct-85 19:46")
    (SETQ \TTY.READY NIL)
    (SETQ \DoveTTY.FCBPointer (\DoveIO.GetHandlerIORegionPtr DoveIO.ttyHandler))
    (\TTY.CREATE.FDEV (create RS232C.INIT
				  BaudRate ← BAUDRATE
				  BitsPerSerialChar ← BITSPERCHAR
				  Parity ← PARITY
				  NoOfStopBits ← STOPBITS
				  FlowControl ← FLOWCONTROL))
    (replace (Dove.TTYFCB wr1.interruptCondition) of \DoveTTY.FCBPointer with 
								  intOnAllRxParityNotAffectVector)
    (replace (Dove.TTYFCB wr1.txIntDMAenable) of \DoveTTY.FCBPointer with T)
    (replace (Dove.TTYFCB wr3.rxEnable) of \DoveTTY.FCBPointer with T)
    (replace (Dove.TTYFCB wr5.txEnable) of \DoveTTY.FCBPointer with T)
    (replace (Dove.TTYFCB ttyWorkList) of \DoveTTY.FCBPointer
       with (\DoveIO.ByteSwap (BITSET (\DoveIO.ByteSwap (fetch (Dove.TTYFCB ttyWorkList)
							     of \DoveTTY.FCBPointer))
					(LOGOR writeReg1 writeReg3 writeReg5 workToBeDone))))
    (replace (Dove.TTYFCB ttyStatusWord) of \DoveTTY.FCBPointer
       with (\DoveIO.ByteSwap (BITCLEAR (BITSET (\DoveIO.ByteSwap (fetch (Dove.TTYFCB 
										    ttyStatusWord)
								       of \DoveTTY.FCBPointer))
						  (LOGOR ttyChnlBOn ttyTxBufEmpty))
					  (LOGOR ttyRxBufFull ttyInterruptFail ttyDataLost))))
    (\DoveIO.NotifyIOP (fetch (Dove.TTYFCB ttyWorkMask) of \DoveTTY.FCBPointer))
    (\DVTTY.SET.PARAMETERS (BQUOTE ((LINE.SPEED ,@ BAUDRATE)
					(CHAR.LENGTH ,@ BITSPERCHAR)
					(PARITY ,@ PARITY)
					(STOP.BITS ,@ STOPBITS)
					(FLOW.CONTROL ,@ FLOWCONTROL))))
    (SETQ \TTYFLG T)
    (SETQ \TTY.READY T)))

(\DVTTY.SET.PARAMETERS
  (LAMBDA (PARAMETERLIST)                                    (* ejs: "25-Oct-85 21:50")
    (bind PARAMETER VALUE (workListImage ←(\DoveIO.ByteSwap (fetch (Dove.TTYFCB ttyWorkList)
								   of \DoveTTY.FCBPointer)))
       for PARAMPAIR in PARAMETERLIST
       do (SETQ PARAMETER (CAR PARAMPAIR))
	    (SETQ VALUE (CDR PARAMPAIR))
	    (SELECTQ PARAMETER
		       ((STOP.BITS NoOfStopBits)
			 (LET ((SBVALUE (CDR (SASSOC VALUE (QUOTE ((0 . 0)
									  (1 . 1)
									  (1.5 . 2)
									  (2 . 3)))))))
			      (COND
				(SBVALUE (replace (RS232C.INIT NoOfStopBits) of 
									    TTY.DEFAULT.INIT.INFO
					    with VALUE)
					 (replace (Dove.TTYFCB wr4.stopBits) of 
									      \DoveTTY.FCBPointer
					    with SBVALUE)
					 (SETQ workListImage (BITSET workListImage writeReg4))))))
		       ((PARITY Parity)
			 (LET ((PARVALUE (CDR (FASSOC VALUE (QUOTE ((NONE . 0)
									   (ODD . 1)
									   (EVEN . 3)))))))
			      (COND
				(PARVALUE (replace (RS232C.INIT Parity) of 
									    TTY.DEFAULT.INIT.INFO
					     with VALUE)
					  (replace (Dove.TTYFCB wr4.parity) of 
									      \DoveTTY.FCBPointer
					     with PARVALUE)
					  (SETQ workListImage (BITSET workListImage writeReg4))))))
		       ((CHAR.LENGTH BitsPerSerialChar)
			 (LET ((LVALUE (IDIFFERENCE VALUE 5)))
			      (COND
				((AND (IGEQ LVALUE 0)
					(ILEQ LVALUE 3))
				  (replace (Dove.TTYFCB wr3.rxCharLength) of \DoveTTY.FCBPointer
				     with (replace (Dove.TTYFCB wr5.txCharLength) of 
									      \DoveTTY.FCBPointer
					       with LVALUE))
				  (SETQ workListImage (BITSET workListImage (LOGOR writeReg3 
										       writeReg5))))))
			 )
		       ((LINE.SPEED BaudRate)
			 (LET ((BDVALUE (CDR (SASSOC VALUE \DVTTY.BAUD.RATES))))
			      (COND
				(BDVALUE (replace (RS232C.INIT BaudRate) of 
									    TTY.DEFAULT.INIT.INFO
					    with VALUE)
					 (replace (Dove.TTYFCB ttyBaudRate) of 
									      \DoveTTY.FCBPointer
					    with (\DoveIO.ByteSwap BDVALUE))
					 (SETQ workListImage (BITSET workListImage writeBaudRate))))
			   ))
		       ((DATA.SET.READY DSR)
			 (replace (Dove.TTYFCB wr5.dataSetReady) of \DoveTTY.FCBPointer
			    with T)
			 (SETQ workListImage (BITSET workListImage writeReg5)))
		       ((CLEAR.TO.SEND CTS)
			 (replace (Dove.TTYFCB wr5.clearToSend) of \DoveTTY.FCBPointer
			    with T)
			 (SETQ workListImage (BITSET workListImage writeReg5)))
		       ((FLOW.CONTROL FlowControl)
			 (replace (RS232C.INIT FlowControl) of TTY.DEFAULT.INIT.INFO
			    with VALUE)
			 (SETQ \DLTTY.FLOWCONTROL (COND
			     ((EQ VALUE (QUOTE XOnXOff))
			       (CONSTANT (create RS232C.XONXOFF
						     FLAG ← 1
						     XON.CHAR ←(CHARCODE ↑Q)
						     XOFF.CHAR ←(CHARCODE ↑S))))
			     (T VALUE))))
		       NIL)
       finally (replace (Dove.TTYFCB ttyWorkList) of \DoveTTY.FCBPointer
		    with (\DoveIO.ByteSwap (BITSET workListImage workToBeDone)))
		 (\DoveIO.NotifyIOP (fetch (Dove.TTYFCB ttyWorkMask) of \DoveTTY.FCBPointer)))))

(\DVTTY.READP
  (LAMBDA (STREAM)                                           (* ejs: "23-Oct-85 19:19")
    (BITTEST (\DoveIO.ByteSwap (fetch (Dove.TTYFCB ttyStatusWord) of \DoveTTY.FCBPointer))
	     ttyRxBufFull)))

(\DVTTY.GET.PARAMETERS
  (LAMBDA (PARAMETERLIST)                                    (* ejs: "25-Oct-85 21:49")

          (* * Return requested parameters in ALIST format)


    (for PARAMETER in PARAMETERLIST
       collect (SELECTQ PARAMETER
			    ((STOP.BITS NoOfStopBits)
			      (CONS PARAMETER (CDR (FASSOC (fetch (Dove.TTYFCB wr4.stopBits)
								    of \DoveTTY.FCBPointer)
								 (CONSTANT (BQUOTE
									       ((, oneStopBit . 1)
										(, oneAndHalfStopBit
 . 1.5)
										(, twoStopBits . 2))))
								 ))))
			    ((PARITY Parity)
			      (CONS PARAMETER (CDR (FASSOC (fetch (Dove.TTYFCB wr4.parity)
								    of \DoveTTY.FCBPointer)
								 (QUOTE ((0 . NONE)
									    (1 . ODD)
									    (3 . EVEN)))))))
			    ((CHAR.LENGTH BitsPerSerialChar)
			      (CONS PARAMETER (IPLUS 5 (fetch (Dove.TTYFCB wr5.txCharLength)
							      of \DoveTTY.FCBPointer))))
			    ((LINE.SPEED BaudRate)
			      (CONS PARAMETER (CDR (FASSOC (\DoveIO.ByteSwap
								   (fetch (Dove.TTYFCB ttyBaudRate)
								      of \DoveTTY.FCBPointer))
								 \DVTTY.INVERSE.BAUD.RATES))))
			    ((DATA.SET.READY DSR)
			      (CONS PARAMETER (fetch (Dove.TTYFCB wr5.dataSetReady) of 
									      \DoveTTY.FCBPointer)))
			    ((CLEAR.TO.SEND CTS)
			      (CONS PARAMETER (fetch (Dove.TTYFCB wr5.clearToSend) of 
									      \DoveTTY.FCBPointer)))
			    ((FLOW.CONTROL FlowControl)
			      (CONS PARAMETER
				      (COND
					((EQUAL \DLTTY.FLOWCONTROL
						  (CONSTANT (create RS232C.XONXOFF
									FLAG ← 1
									XON.CHAR ←(CHARCODE ↑Q)
									XOFF.CHAR ←(CHARCODE ↑S))))
					  (QUOTE XOnXOff))
					(T \DLTTY.FLOWCONTROL))))
			    NIL))))

(\DVTTY.SHUTDOWN
  (LAMBDA (BAUDRATE BITSPERCHAR PARITY STOPBITS FLOWCONTROL)
                                                             (* ejs: "25-Oct-85 21:35")
    (replace (Dove.TTYFCB wr1.txIntDMAenable) of \DoveTTY.FCBPointer with T)
    (replace (Dove.TTYFCB wr3.rxEnable) of \DoveTTY.FCBPointer with T)
    (replace (Dove.TTYFCB wr5.txEnable) of \DoveTTY.FCBPointer with T)
    (replace (Dove.TTYFCB ttyWorkList) of \DoveTTY.FCBPointer
       with (\DoveIO.ByteSwap (BITSET (\DoveIO.ByteSwap (fetch (Dove.TTYFCB ttyWorkList)
								 of \DoveTTY.FCBPointer))
					  (LOGOR writeReg1 writeReg3 writeReg5 workToBeDone))))
    (replace (Dove.TTYFCB ttyStatusWord) of \DoveTTY.FCBPointer
       with (\DoveIO.ByteSwap (BITCLEAR (BITSET (\DoveIO.ByteSwap (fetch (Dove.TTYFCB 
										    ttyStatusWord)
									   of \DoveTTY.FCBPointer))
						    (LOGOR ttyChnlBOn ttyTxBufEmpty))
					    (LOGOR ttyRxBufFull ttyInterruptFail ttyDataLost))))
    (\DoveIO.NotifyIOP (fetch (Dove.TTYFCB ttyWorkMask) of \DoveTTY.FCBPointer))
    (SETQ \TTYFLG NIL)
    (SETQ \TTY.READY NIL)))
)



(* Machine independant face; for DLion and DayBreak)

(DECLARE: DONTCOPY 
(FILESLOAD (LOADCOMP)
	   DLRS232C)
)

(RPAQ? \TTY.FDEV )

(RPAQ? \TTYFLG )

(RPAQ? \TTY.READY )

(ADDTOVAR GLOBALVARS \TTY.FDEV \TTYFLG \TTY.READY)
(DECLARE: DONTCOPY 
(* FOLLOWING DEFINITIONS EXPORTED)


[DECLARE: EVAL@COMPILE 

(ACCESSFNS TTYSTREAM ((OUTPUTHELD (fetch (STREAM F1) of DATUM)
				    (replace (STREAM F1) of DATUM with NEWVALUE))))
]


(* END EXPORTED DEFINITIONS)

)
(DEFINEQ

(\TTY.CREATE.FDEV
  (LAMBDA (INITINFO)                                         (* ejs: "27-Aug-85 16:24")
    (OR (type? FDEV \TTY.FDEV)
	(\DEFINEDEVICE (QUOTE TTY)
		       (SETQ \TTY.FDEV (create FDEV
					       DEVICENAME ←(QUOTE TTY)
					       RANDOMACCESSP ← NIL
					       PAGEMAPPED ← NIL
					       NODIRECTORIES ← T
					       FDBINABLE ← NIL
					       FDBOUTABLE ← NIL
					       FDEXTENDABLE ← NIL
					       CLOSEFILE ←(FUNCTION \TTY.CLOSEFILE)
					       DELETEFILE ←(FUNCTION NILL)
					       EVENTFN ←(FUNCTION \TTY.EVENTFN)
					       GENERATEFILES ←(FUNCTION \GENERATENOFILES)
					       GETFILEINFO ←(FUNCTION \TTY.GETFILEINFO)
					       SETFILEINFO ←(FUNCTION \TTY.SETFILEINFO)
					       GETFILENAME ←(FUNCTION NILL)
					       OPENFILE ←(FUNCTION \TTY.OPENFILE)
					       REOPENFILE ←(FUNCTION NILL)
					       TRUNCATEFILE ←(FUNCTION NILL)
					       BIN ←(FUNCTION \TTY.BIN)
					       BOUT ←(FUNCTION \TTY.BOUT)
					       PEEKBIN ←(FUNCTION \TTY.PEEKBIN)
					       READP ←(FUNCTION \TTY.READP)
					       DEVICEINFO ←(create RS232C.DEVICEINFO)))))
    (replace (RS232C.DEVICEINFO INIT) of (fetch (FDEV DEVICEINFO) of \TTY.FDEV) with INITINFO)))

(\TTY.EVENTFN
  (LAMBDA (EVENT)                                            (* ejs: "27-Aug-85 19:01")
    (SELECTQ EVENT
	     ((BEFORELOGOUT BEFORESAVEVM BEFOREMAKESYS BEFORESYSOUT)
	       (SELECTC \MACHINETYPE
			(\DANDELION (SETQ \DLTTY.STATE (fetch (DLTTY.OUT.CSB PARAMETER) of \IOPAGE)))
			NIL)
	       (SETQ \TTY.READY NIL))
	     ((AFTERLOGOUT AFTERMAKESYS AFTERSYSOUT AFTERSAVEVM)
	       (COND
		 (\TTYFLG (SELECTC \MACHINETYPE
				   (\DANDELION (replace (DLTTY.OUT.CSB PARAMETER) of \IOPAGE
						  with \DLTTY.STATE)
					       (replace (DLTTY.SETPARAMETER.COMMAND COMMAND)
						  of \IOPAGE with SET.ALL.PARAMETERS))
				   NIL)
			  (SETQ \TTY.READY T))))
	     NIL)))

(\TTY.BIN
  (LAMBDA (STREAM)                                           (* ejs: "27-Aug-85 16:20")
    (SELECTC \MACHINETYPE
	     (\DANDELION (\DLTTY.BIN STREAM))
	     (\DAYBREAK (\DVTTY.BIN STREAM))
	     (\NOMACHINETYPE))))

(\TTY.BOUT
  (LAMBDA (STREAM BYTE)                                      (* ejs: "27-Aug-85 16:21")
    (SELECTC \MACHINETYPE
	     (\DANDELION (\DLTTY.BOUT STREAM BYTE))
	     (\DAYBREAK (\DVTTY.BOUT STREAM BYTE))
	     (\NOMACHINETYPE))))

(\TTY.READP
  (LAMBDA (STREAM)                                           (* ejs: "27-Aug-85 16:22")
    (SELECTC \MACHINETYPE
	     (\DANDELION (\DLTTY.READP STREAM))
	     (\DAYBREAK (\DVTTY.READP STREAM))
	     (\NOMACHINETYPE))))

(\TTY.CLOSEFILE
  (LAMBDA (STREAM)                                           (* ejs: " 8-Sep-85 17:14")
    (LET ((TTYDEVICEINFO (fetch (FDEV DEVICEINFO) of \TTY.FDEV)))
         (SELECTQ (fetch (STREAM ACCESS) of STREAM)
		  (INPUT (replace (RS232C.DEVICEINFO INSTREAM) of TTYDEVICEINFO with NIL))
		  (OUTPUT (replace (RS232C.DEVICEINFO OUTSTREAM) of TTYDEVICEINFO with NIL))
		  (BOTH (replace (RS232C.DEVICEINFO INSTREAM) of TTYDEVICEINFO with NIL)
			(replace (RS232C.DEVICEINFO OUTSTREAM) of TTYDEVICEINFO with NIL))
		  NIL)
         (replace (STREAM ACCESS) of STREAM with NIL))))

(\TTY.OPENFILE
  [LAMBDA (NAME ACCESS RECOG PARAMETERS)                     (* edited: "20-Sep-85 10:18")
    (OR \TTY.FDEV (\TTY.CREATE.FDEV TTY.DEFAULT.INIT.INFO))

          (* * Set any parameters specified by the user)


    [COND
      (PARAMETERS (TTY.SET.PARAMETERS (for PAIR in PARAMETERS collect (CONS (CAR PAIR)
									    (CADR PAIR]

          (* * Check for conflicting access)


    (SELECTQ ACCESS
	     [INPUT (COND
		      ((fetch (RS232C.DEVICEINFO INSTREAM) of (fetch (FDEV DEVICEINFO) of \TTY.FDEV))
			(printout TTY.ERROR.STREAM T "TTY port is busy on input" T)
			(ERRORX (QUOTE (9 {TTY}]
	     [OUTPUT (COND
		       ((fetch (RS232C.DEVICEINFO OUTSTREAM) of (fetch (FDEV DEVICEINFO)
								   of \TTY.FDEV))
			 (printout TTY.ERROR.STREAM T "TTY port is busy on output" T)
			 (ERRORX (QUOTE (9 {TTY}]
	     [BOTH (COND
		     ((OR (fetch (RS232C.DEVICEINFO INSTREAM) of (fetch (FDEV DEVICEINFO)
								    of \TTY.FDEV))
			  (fetch (RS232C.DEVICEINFO OUTSTREAM) of (fetch (FDEV DEVICEINFO)
								     of \TTY.FDEV)))
		       (printout TTY.ERROR.STREAM T "TTY port is busy on input or output" T)
		       (ERRORX (QUOTE (9 {TTY}]
	     (\ILLEGAL.ARG ACCESS))

          (* * If an output stream is being opened, make sure no XOFF chars are hanging in the input latch)


    (COND
      ((OR (EQ ACCESS (QUOTE OUTPUT))
	   (EQ ACCESS (QUOTE BOTH)))
	(replace (DLTTY.IN.CSB IN.DATA) of \IOPAGE with 0)))

          (* * Return the stream to the user)


    (LET [(EOLCONVENTION (CADR (FASSOC (QUOTE EOLCONVENTION)
				       PARAMETERS]
         (create STREAM
		 ACCESS ← ACCESS
		 EOLCONVENTION ←(SELECTQ EOLCONVENTION
					 (CR CR.EOLC)
					 (LF LF.EOLC)
					 (CRLF CRLF.EOLC)
					 (COND
					   ([AND (SMALLP EOLCONVENTION)
						 (IGEQ EOLCONVENTION 0)
						 (ILEQ EOLCONVENTION (CONSTANT (IMAX CR.EOLC LF.EOLC 
										     CRLF.EOLC]
					     EOLCONVENTION)
					   (T CRLF.EOLC)))
		 DEVICE ← \TTY.FDEV])
)



(* Machine independant user face)


(RPAQ? TTY.DEFAULT.INIT.INFO (create RS232C.INIT BaudRate ← 1200 BitsPerSerialChar ← 8 Parity ←
				       (QUOTE NONE)
				       NoOfStopBits ← 1 FlowControl ← \DLTTY.FLOWCONTROL))

(RPAQ? TTY.ERROR.STREAM PROMPTWINDOW)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS TTY.DEFAULT.INIT.INFO TTY.ERROR.STREAM)
)
(DEFINEQ

(TTY.INIT
  (LAMBDA (BaudRate BitsPerSerialChar Parity NoOfStopBits FlowControl)
                                                             (* ejs: "23-Oct-85 18:21")

          (* * User interface to low level initialization)


    (SELECTC \MACHINETYPE
	       (\DANDELION (COND
			     ((NULL BaudRate)
			       (APPLY (FUNCTION \DLTTY.INIT)
					TTY.DEFAULT.INIT.INFO))
			     ((LISTP BaudRate)
			       (APPLY (FUNCTION \DLTTY.INIT)
					BaudRate))
			     (T (\DLTTY.INIT BaudRate BitsPerSerialChar Parity NoOfStopBits 
					       FlowControl))))
	       (\DAYBREAK (COND
			    ((NULL BaudRate)
			      (APPLY (FUNCTION \DVTTY.INIT)
				       TTY.DEFAULT.INIT.INFO))
			    ((LISTP BaudRate)
			      (APPLY (FUNCTION \DVTTY.INIT)
				       BaudRate))
			    (T (\DVTTY.INIT BaudRate BitsPerSerialChar Parity NoOfStopBits 
					      FlowControl))))
	       (ERROR "The TTY/PrinterPort is currently not supported on " (MACHINETYPE)))))

(TTY.GET.PARAMETERS
  (LAMBDA (PARAMETERLIST)                                    (* ejs: "25-Oct-85 21:59")
    (SELECTC \MACHINETYPE
	       (\DANDELION (\DLTTY.GET.PARAMETERS PARAMETERLIST))
	       (\DAYBREAK (\DVTTY.GET.PARAMETERS PARAMETERLIST))
	       (ERROR "RS232C is currently not supported on " (MACHINETYPE)))))

(TTY.SET.PARAMETERS
  (LAMBDA (PARAMETERLIST)                                    (* ejs: "27-Aug-85 18:45")
    (SELECTC \MACHINETYPE
	     (\DANDELION (\DLTTY.SET.PARAMETERS PARAMETERLIST))
	     (\DAYBREAK (\DVTTY.SET.PARAMETERS PARAMETERLIST))
	     (\NOMACHINETYPE))))

(TTY.RESET.STREAMS
  (LAMBDA NIL                                                (* ejs: " 8-Sep-85 16:49")
    (replace (RS232C.DEVICEINFO INSTREAM) of (fetch (FDEV DEVICEINFO) of \TTY.FDEV)
       with (replace (RS232C.DEVICEINFO OUTSTREAM) of (fetch (FDEV DEVICEINFO) of \TTY.FDEV)
	       with NIL))))

(TTY.SHUTDOWN
  (LAMBDA NIL                                                (* ejs: "27-Aug-85 18:53")
    (SELECTC \MACHINETYPE
	     (\DANDELION (\DLTTY.SHUTDOWN))
	     (\DAYBREAK (\DVTTY.SHUTDOWN))
	     (\NOMACHINETYPE))))
)
(PUTPROPS DLTTY COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (8162 16740 (\DLTTY.BIN 8172 . 9163) (\DLTTY.BOUT 9165 . 10026) (\DLTTY.GET.PARAMETERS 
10028 . 11564) (\DLTTY.INIT 11566 . 12949) (\DLTTY.READP 12951 . 13114) (\DLTTY.SET.PARAMETERS 13116
 . 16285) (\DLTTY.SHUTDOWN 16287 . 16738)) (20196 31306 (\DVTTY.BIN 20206 . 21572) (\DVTTY.BOUT 21574
 . 22767) (\DVTTY.INIT 22769 . 24605) (\DVTTY.SET.PARAMETERS 24607 . 27998) (\DVTTY.READP 28000 . 
28230) (\DVTTY.GET.PARAMETERS 28232 . 30085) (\DVTTY.SHUTDOWN 30087 . 31304)) (31814 37562 (
\TTY.CREATE.FDEV 31824 . 33136) (\TTY.EVENTFN 33138 . 33892) (\TTY.BIN 33894 . 34140) (\TTY.BOUT 34142
 . 34401) (\TTY.READP 34403 . 34655) (\TTY.CLOSEFILE 34657 . 35341) (\TTY.OPENFILE 35343 . 37560)) (
37925 40225 (TTY.INIT 37935 . 38974) (TTY.GET.PARAMETERS 38976 . 39327) (TTY.SET.PARAMETERS 39329 . 
39621) (TTY.RESET.STREAMS 39623 . 39975) (TTY.SHUTDOWN 39977 . 40223)))))
STOP