(FILECREATED "20-Feb-87 17:06:40" {DSK}<LISPFILES>STC>PATCH>DV-RS232CPATCH.;1 18252  

      changes to:  (VARS DV-RS232CPATCHCOMS)
		   (FNS \DVRS232C.SET.PARAMETERS \DVRS232C.ISSUE.SHORT.COMMAND))


(PRETTYCOMPRINT DV-RS232CPATCHCOMS)

(RPAQQ DV-RS232CPATCHCOMS ((FNS \DVRS232C.SET.PARAMETERS \DVRS232C.ISSUE.SHORT.COMMAND)))
(DEFINEQ

(\DVRS232C.SET.PARAMETERS
  [LAMBDA (PARAMETERLIST)                                    (* AS "20-Feb-87 16:47")

          (* * PARAMETERLIST is in property list format. This function sets the parameters of the IOP accordingly)


    (COND
      (PARAMETERLIST
	(bind (rsWorkListImage ← (\DoveIO.ByteSwap (fetch (Dove.RS232DCB rsWorkList)
							of \DoveRS232C.DCBPointer)))
		(rsCommandWorkListImage ← (\DoveIO.ByteSwap (fetch (Dove.RS232DCB rsCommandWorkList)
							       of \DoveRS232C.DCBPointer)))
		MAJORFLG COMMANDWORK PROP VAL for PROP.VAL in PARAMETERLIST
	   do ((SETQ PROP (CAR PROP.VAL))
		 (SETQ VAL (CDR PROP.VAL))
		 (SELECTQ PROP
			    [FRAME.TIMEOUT (COND
					     ((NEQ VAL (\DoveIO.ByteSwap (fetch (Dove.RS232DCB
										      
									      rsFrameTimeoutValue)
									      of 
									   \DoveRS232C.DCBPointer)))
					       (replace (Dove.RS232DCB rsFrameTimeoutValue)
						  of \DoveRS232C.DCBPointer
						  with (\DoveIO.ByteSwap (FIX (TIMES 10 VAL]
			    [CORRESPONDENT (replace (Dove.RS232DCB rsTTYHost) of 
									   \DoveRS232C.DCBPointer
					      with (COND
						       ((EQ VAL RS232C.CP.TTYHOST)
							 \DoveIO.ByteTRUE)
						       (T \DoveIO.ByteFALSE]
			    (SYNCH.CHAR                      (* Not supported on Dove)
					NIL)
			    [(STOP.BITS NoOfStopBits)
			      (replace (RS232C.INIT NoOfStopBits) of RS232C.DEFAULT.INIT.INFO
				 with VAL)
			      (COND
				((NEQ (fetch (Dove.i8274.WR4 stopBits)
					   of (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274)
							 of \DoveRS232C.DCBPointer)))
					(SELECTC VAL
						   (1 oneStopBit)
						   (2 twoStopBits)
						   (\ILLEGAL.ARG 0)))
				  (SETQ MAJORFLG T)
				  (SETQ rsWorkListImage (BITSET rsWorkListImage rsWorkWR4))
				  (replace (Dove.i8274.WR4 stopBits)
				     of (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274) of 
									   \DoveRS232C.DCBPointer))
				     with (SELECTC VAL
						       (1 oneStopBit)
						       (2 twoStopBits)
						       (\ILLEGAL.ARG 0]
			    [(PARITY Parity)
			      (replace (RS232C.INIT Parity) of RS232C.DEFAULT.INIT.INFO
				 with VAL)
			      (COND
				([NEQ VAL (COND
					  ([NOT (fetch (Dove.i8274.WR4 enableParity)
						     of (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274)
								   of \DoveRS232C.DCBPointer]
					    (QUOTE NONE))
					  ((EQ (fetch (Dove.i8274.WR4 enableParity)
						    of (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274)
								  of \DoveRS232C.DCBPointer)))
						 parityOdd)
					    (QUOTE ODD))
					  ((EQ (fetch (Dove.i8274.WR4 enableParity)
						    of (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274)
								  of \DoveRS232C.DCBPointer)))
						 parityEven)
					    (QUOTE EVEN]
				  (SETQ MAJORFLG T)
				  (SETQ rsWorkListImage (BITSET rsWorkListImage rsWorkWR4))
				  (COND
				    ((EQ VAL (QUOTE NONE))
				      (replace (Dove.i8274.WR4 enableParity)
					 of (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274)
						       of \DoveRS232C.DCBPointer))
					 with NIL))
				    (T (replace (Dove.i8274.WR4 enableParity)
					  of (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274)
							of \DoveRS232C.DCBPointer))
					  with T)
				       (replace (Dove.i8274.WR4 parityOddOrEven)
					  of (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274)
							of \DoveRS232C.DCBPointer))
					  with (SELECTQ VAL
							    (EVEN parityEven)
							    (ODD parityOdd)
							    (\ILLEGAL.ARG VAL]
			    [(CHAR.LENGTH BitsPerSerialChar)
			      (replace (RS232C.INIT BitsPerSerialChar) of 
									 RS232C.DEFAULT.INIT.INFO
				 with VAL)
			      (SETQ VAL (SELECTQ VAL
						     (8 3)
						     (7 1)
						     (6 2)
						     (5 0)
						     (\ILLEGAL.ARG VAL)))
			      (COND
				([NEQ VAL (fetch (Dove.i8274.WR5 txCharLength)
					       of (LOCF (fetch (Dove.RS232DCB rsWR5ofi8274)
							     of \DoveRS232C.DCBPointer]
				  (SETQ MAJORFLG T)
				  (SETQ rsWorkListImage (BITSET rsWorkListImage (LOGOR rsWorkWR3 
											rsWorkWR5)))
				  (replace (Dove.i8274.WR5 txCharLength)
				     of (LOCF (fetch (Dove.RS232DCB rsWR5ofi8274) of 
									   \DoveRS232C.DCBPointer))
				     with VAL)
				  (replace (Dove.i8274.WR3 rxCharLength)
				     of (LOCF (fetch (Dove.RS232DCB rsWR3ofi8274) of 
									   \DoveRS232C.DCBPointer))
				     with VAL]
			    (SYNCH.COUNT                     (* Not implemented on Daybreak)
					 NIL)
			    [(LINE.SPEED BaudRate)
			      (replace (RS232C.INIT BaudRate) of RS232C.DEFAULT.INIT.INFO
				 with VAL)
			      (SETQ \DLRS232C.OUTPUT.TIMEOUT (\RS232C.PACKET.TIMEOUT VAL))
			      (COND
				([AND (SETQ VAL (CDR (SASSOC VAL \DVRS232C.BAUD.RATES)))
					(NEQ VAL (\DoveIO.ByteSwap (fetch (Dove.RS232DCB 
										    rsBaudRateChA)
									of \DoveRS232C.DCBPointer]
				  (SETQ MAJORFLG T)
				  (SETQ rsWorkListImage (BITSET rsWorkListImage rsNewBaudRate))
				  (replace (Dove.RS232DCB rsBaudRateChA) of 
									   \DoveRS232C.DCBPointer
				     with (\DoveIO.ByteSwap VAL]
			    [(FLOW.CONTROL FlowControl)
			      (SETQ MAJORFLG T)
			      (replace (RS232C.INIT FlowControl) of RS232C.DEFAULT.INIT.INFO
				 with VAL)
			      [COND
				((EQ VAL (QUOTE XOnXOff))
				  (SETQ VAL (CONSTANT (create RS232C.XONXOFF
								    FLAG ← 1
								    XON.CHAR ← (CHARCODE ↑Q)
								    XOFF.CHAR ← (CHARCODE ↑S]
			      (COND
				[(LISTP VAL)
				  (replace (Dove.RS232FlowControl type) of (fetch (Dove.RS232DCB
											  
										 rs232FlowControl)
										  of 
									   \DoveRS232C.DCBPointer)
				     with (COND
					      ((ZEROP (fetch (RS232C.XONXOFF FLAG) of VAL))
						noFlowControl)
					      (T XOnXOffFlowControl)))
				  (replace (Dove.RS232FlowControl XOn) of (fetch (Dove.RS232DCB
											 
										 rs232FlowControl)
										 of 
									   \DoveRS232C.DCBPointer)
				     with (\DoveIO.ByteSwap (OR (fetch (RS232C.XONXOFF XON.CHAR)
								       of VAL)
								    0)))
				  (replace (Dove.RS232FlowControl XOff) of (fetch (Dove.RS232DCB
											  
										 rs232FlowControl)
										  of 
									   \DoveRS232C.DCBPointer)
				     with (\DoveIO.ByteSwap (OR (fetch (RS232C.XONXOFF 
											XOFF.CHAR)
								       of VAL)
								    0]
				(T (replace (Dove.RS232FlowControl type)
				      of (fetch (Dove.RS232DCB rs232FlowControl) of 
									   \DoveRS232C.DCBPointer)
				      with noFlowControl]
			    [LINE.TYPE (LET [(WR1Base (LOCF (fetch (Dove.RS232DCB rsWR1ofi8274)
							       of \DoveRS232C.DCBPointer)))
					     (WR3Base (LOCF (fetch (Dove.RS232DCB rsWR3ofi8274)
							       of \DoveRS232C.DCBPointer)))
					     (WR4Base (LOCF (fetch (Dove.RS232DCB rsWR4ofi8274)
							       of \DoveRS232C.DCBPointer)))
					     (WR5Base (LOCF (fetch (Dove.RS232DCB rsWR5ofi8274)
							       of \DoveRS232C.DCBPointer)))
					     (WR7Base (LOCF (fetch (Dove.RS232DCB rsWR7ofi8274)
							       of \DoveRS232C.DCBPointer]
					    (SELECTC VAL
						       (RS232C.LT.ASYNCH (replace (Dove.RS232DCB
										      rs232Mode)
									    of 
									   \DoveRS232C.DCBPointer
									    with asynchMode)
									 (replace (Dove.i8274.WR1
										      
									       extInterruptEnable)
									    of WR3Base
									    with NIL)
									 (replace (Dove.i8274.WR3
										      enterHuntMode)
									    of WR3Base
									    with NIL)
									 (replace (Dove.i8274.WR3
										      rxCRCenable)
									    of WR3Base
									    with NIL)
									 (replace (Dove.i8274.WR3
										      addrSearchMode)
									    of WR3Base
									    with NIL)
									 (replace (Dove.i8274.WR4
										      clockRate)
									    of WR4Base
									    with x16clk)
									 (replace (Dove.i8274.WR5
										      txCRCenable)
									    of WR5Base
									    with NIL)
									 (SETQ rsWorkListImage
									   (BITSET rsWorkListImage
										   (LOGOR rsWorkWR1 
											rsWorkWR3 
											rsWorkWR4 
											rsWorkWR5)))
									 (SETQ MAJORFLG T))
						       (RS232C.LT.BIT.SYNCH (HELP 
						      "Bit synchronous RS232 not implemented yet"))
						       (ERROR "Illegal line type" VAL]
			    (RESET.RING.HEARD (replace (Dove.RSLatchedStatus ringHeard)
						 of (LOCF (fetch (Dove.RS232DCB rsLatchedStatus)
							       of \DoveRS232C.DCBPointer))
						 with NIL))
			    (RESET.BREAK.DETECTED (replace (Dove.RSLatchedStatus breakDetected)
						     of (LOCF (fetch (Dove.RS232DCB 
										  rsLatchedStatus)
								   of \DoveRS232C.DCBPointer))
						     with NIL))
			    (RESET.DATA.LOST (replace (Dove.RSLatchedStatus dataLost)
						of (LOCF (fetch (Dove.RS232DCB rsLatchedStatus)
							      of \DoveRS232C.DCBPointer))
						with NIL))
			    [(REQUEST.TO.SEND RTS)
			      (SETQ COMMANDWORK T)
			      (SETQ rsWorkListImage (BITSET rsWorkListImage rsWorkWR5))
			      (COND
				((replace (Dove.i8274.WR5 rts) of (LOCF (fetch (Dove.RS232DCB
										       rsWR5ofi8274)
									       of 
									   \DoveRS232C.DCBPointer))
				    with VAL)
				  (SETQ rsCommandWorkListImage (BITSET rsCommandWorkListImage 
									 rtsCommand)))
				(T (SETQ rsCommandWorkListImage (BITCLEAR rsCommandWorkListImage 
									    rtsCommand]
			    [(DATA.TERMINAL.READY DTR)
			      (SETQ COMMANDWORK T)
			      (SETQ rsWorkListImage (BITSET rsWorkListImage rsWorkWR5))
			      (COND
				((replace (Dove.i8274.WR5 dtr) of (LOCF (fetch (Dove.RS232DCB
										       rsWR5ofi8274)
									       of 
									   \DoveRS232C.DCBPointer))
				    with VAL)
				  (SETQ rsCommandWorkListImage (BITSET rsCommandWorkListImage 
									 dtrCommand)))
				(T (SETQ rsCommandWorkListImage (BITCLEAR rsCommandWorkListImage 
									    dtrCommand]
			    (ModemControl (for SIGNAL in VAL
					     do (SELECTQ
						    SIGNAL
						    [RTS (SETQ COMMANDWORK T)
							 (SETQ rsWorkListImage (BITSET 
										  rsWorkListImage 
											rsWorkWR5))
							 (COND
							   ((replace (Dove.i8274.WR5 rts)
							       of (LOCF (fetch (Dove.RS232DCB
										     rsWR5ofi8274)
									     of 
									   \DoveRS232C.DCBPointer))
							       with VAL)
							     (SETQ rsCommandWorkListImage
							       (BITSET rsCommandWorkListImage 
								       rtsCommand)))
							   (T (SETQ rsCommandWorkListImage
								(BITCLEAR rsCommandWorkListImage 
									  rtsCommand]
						    [DTR (SETQ COMMANDWORK T)
							 (SETQ rsWorkListImage (BITSET 
										  rsWorkListImage 
											rsWorkWR5))
							 (COND
							   ((replace (Dove.i8274.WR5 dtr)
							       of (LOCF (fetch (Dove.RS232DCB
										     rsWR5ofi8274)
									     of 
									   \DoveRS232C.DCBPointer))
							       with VAL)
							     (SETQ rsCommandWorkListImage
							       (BITSET rsCommandWorkListImage 
								       dtrCommand)))
							   (T (SETQ rsCommandWorkListImage
								(BITCLEAR rsCommandWorkListImage 
									  dtrCommand]
						    NIL)))
			    NIL))
	   finally (COND
		       (COMMANDWORK (replace (Dove.RS232DCB rsCommandWorkList) of 
									   \DoveRS232C.DCBPointer
				       with (\DoveIO.ByteSwap rsCommandWorkListImage))
				    (SETQ MAJORFLG T)))
		     (COND
		       ((NOT MAJORFLG)
			 (RETURN T))
		       (T (SETQ rsWorkListImage (BITSET rsWorkListImage workFori8274))
			  (replace (Dove.RS232DCB rsWorkList) of \DoveRS232C.DCBPointer
			     with (\DoveIO.ByteSwap rsWorkListImage))
			  (\DoveIO.NotifyIOP (fetch (Dove.RS232FCB rs232WorkMask) of 
									   \DoveRS232C.FCBPointer))
			  (repeatwhile (BITTEST (\DoveIO.ByteSwap (fetch (Dove.RS232DCB 
										       rsWorkList)
								       of \DoveRS232C.DCBPointer))
						  workFori8274)
			     do (BLOCK))
			  (RETURN T])

(\DVRS232C.ISSUE.SHORT.COMMAND
  [LAMBDA (COMMAND)                                        (* AS "20-Feb-87 17:03")

          (* * Issue a simple command to Opie. Tis a pity issuing such commands isn't as simple as it was on the DLion)


    (DECLARE (GLOBALVARS \DLRS232C.COMMAND.LOCK))
    (LET (rsCommandWorkListImage rsWorkListImage)
         (WITH.FAST.MONITOR \DLRS232C.COMMAND.LOCK (while (BITTEST (\DoveIO.ByteSwap
								       (fetch (Dove.RS232DCB 
										rsCommandWorkList)
									  of \DoveRS232C.DCBPointer)
								       )
								     rsCommandInProgress)
						      do (BLOCK))
			    (SETQ rsCommandWorkListImage (\DoveIO.ByteSwap (fetch (Dove.RS232DCB
											
										rsCommandWorkList)
										of 
									   \DoveRS232C.DCBPointer)))
			    (SETQ rsWorkListImage (\DoveIO.ByteSwap (fetch (Dove.RS232DCB 
										       rsWorkList)
									 of \DoveRS232C.DCBPointer))
			      )
			    (SELECTC COMMAND
				       (ABORT.INPUT (SETQ rsCommandWorkListImage (BITSET 
									   rsCommandWorkListImage 
											  abortRx)))
				       (ABORT.OUTPUT (SETQ rsCommandWorkListImage (BITSET 
									   rsCommandWorkListImage 
											  abortTx)))
				       [BREAK.ON (replace (Dove.i8274.WR5 sendBreak)
						    of (LOCF (fetch (Dove.RS232DCB rsWR5ofi8274)
								  of \DoveRS232C.DCBPointer))
						    with T)
						 (SETQ rsWorkListImage (BITSET rsWorkListImage
										 (LOGOR rsWorkWR5 
										     workFori8274]
				       [BREAK.OFF (replace (Dove.i8274.WR5 sendBreak)
						     of (LOCF (fetch (Dove.RS232DCB rsWR5ofi8274)
								   of \DoveRS232C.DCBPointer))
						     with NIL)
						  (SETQ rsWorkListImage (BITSET rsWorkListImage
										  (LOGOR rsWorkWR5 
										     workFori8274]
				       (GET.STATUS (SETQ rsCommandWorkListImage (BITSET 
									   rsCommandWorkListImage 
										  getDeviceStatus)))
				       (OFF (replace (Dove.i8274.WR3 rxEnable)
					       of (LOCF (fetch (Dove.RS232DCB rsWR3ofi8274)
							     of \DoveRS232C.DCBPointer))
					       with NIL)
					    (replace (Dove.i8274.WR3 autoEnable)
					       of (LOCF (fetch (Dove.RS232DCB rsWR3ofi8274)
							     of \DoveRS232C.DCBPointer))
					       with NIL)
					    (replace (Dove.i8274.WR5 txEnable)
					       of (LOCF (fetch (Dove.RS232DCB rsWR5ofi8274)
							     of \DoveRS232C.DCBPointer))
					       with NIL)
					    (replace (Dove.i8274.WR1 txIntDMAenable)
					       of (LOCF (fetch (Dove.RS232DCB rsWR1ofi8274)
							     of \DoveRS232C.DCBPointer))
					       with NIL)
					    (replace (Dove.i8274.WR1 extInterruptEnable)
					       of (LOCF (fetch (Dove.RS232DCB rsWR1ofi8274)
							     of \DoveRS232C.DCBPointer))
					       with NIL)
					    (SETQ rsWorkListImage
					      (BITSET rsWorkListImage (LOGOR rsWorkWR1 rsWorkWR3 
									       rsWorkWR5 workFori8274)
						      ))
					    (replace (Dove.RS232DCB rsClientType) of 
									   \DoveRS232C.DCBPointer
					       with rsNoClient))
				       [ON (replace (Dove.i8274.WR3 rxEnable)
					      of (LOCF (fetch (Dove.RS232DCB rsWR3ofi8274)
							    of \DoveRS232C.DCBPointer))
					      with T)
					   (replace (Dove.i8274.WR5 txEnable)
					      of (LOCF (fetch (Dove.RS232DCB rsWR5ofi8274)
							    of \DoveRS232C.DCBPointer))
					      with T)
					   (replace (Dove.i8274.WR1 txIntDMAenable)
					      of (LOCF (fetch (Dove.RS232DCB rsWR1ofi8274)
							    of \DoveRS232C.DCBPointer))
					      with T)
					   (replace (Dove.i8274.WR1 interruptCondition)
					      of (LOCF (fetch (Dove.RS232DCB rsWR1ofi8274)
							    of \DoveRS232C.DCBPointer))
					      with intOnAllRxParityAffectsVector)
					   (replace (Dove.RS232DCB rsClientType) of 
									   \DoveRS232C.DCBPointer
					      with rsNormal)
					   (SETQ rsWorkListImage (BITSET rsWorkListImage
									   (LOGOR rsWorkWR1 
										    rsWorkWR3 
										    rsWorkWR5 
										    workFori8274]
				       NIL)
			    [COND
			      ((BITTEST rsWorkListImage workFori8274)
				(replace (Dove.RS232DCB rsWorkList) of \DoveRS232C.DCBPointer
				   with (\DoveIO.ByteSwap rsWorkListImage]
			    (replace (Dove.RS232DCB rsCommandWorkList) of \DoveRS232C.DCBPointer
			       with (\DoveIO.ByteSwap (BITSET rsCommandWorkListImage 
								rsCommandInProgress)))
			    (\DoveIO.NotifyIOP (fetch (Dove.RS232FCB rs232WorkMask) of 
									   \DoveRS232C.FCBPointer))
			    (repeatwhile (BITTEST (\DoveIO.ByteSwap (fetch (Dove.RS232DCB 
										rsCommandWorkList)
									 of \DoveRS232C.DCBPointer))
						    rsCommandInProgress)
			       do (BLOCK))
			    (\DVRS232C.GATHER.STATUS])
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (338 18230 (\DVRS232C.SET.PARAMETERS 348 . 13176) (\DVRS232C.ISSUE.SHORT.COMMAND 13178
 . 18228)))))
STOP