;-----------------------------------------------------------------------
;
;  SWIC SCANNER READING (AND READING-THE-SETTING) PROPERTY.
;
;  THE USER'S BUFFER OFFSET IS A CODE INDICATING WHAT TO READ.  THIS
;  CODE INDEXES TABLE 'RCMD43' TO OBTAIN A COMMAND BYTE.  THE COMMAND
;  BYTE IS TRANSMITTED TO THE SWIC SCANNER; WE CAN THEN READ BACK THE
;  DESIRED BUFFER.
;
;  IN ORDER FOR THIS TO WORK NICELY IN OUR ENVIRONMENT TWO REQUIREMENTS
;  MUST BE MET:
;
;	1) THE SWIC SCANNER MUST HAVE NON-DESTRUCTIVE READOUT.
;	2) THE RETURN BUFFER MUST BE AVAILABLE RATHER RAPIDLY, SO
;	   WE CAN READ IT RIGHT AWAY, SO THAT OTHER REQUESTS CAN'T
;	   GET INTERLEAVED.
;
;  THE FIRST IS ASSERTED BY THE SWIC SCANNER PEOPLE.  THE QUICK RESPONSE
;  CONDITION HAS BEEN MEASURED AT ABOUT 600 MICROSECONDS FOR THE FIRST
;  WORD, PLUS 25 US PER ADDITIONAL WORD.  WE CAN START READING
;  IMMEDIATELY, RELYING ON NO-Q RETRIES TO COVER THE FIRST 600 US.
;
;  COMMUNICATION WITH THE SWIC SCANNER IS HANDLED THROUGH AN INTER-
;  MEDIARY '032' CARD.  THIS CARD HAS FIFOS RUNNING IN BOTH DIRECTIONS.
;
;  WE CAN ENQUIRE ABOUT THE STATE OF THE FIFOS BEFORE WE SEND OUR ONE
;  BYTE COMMAND.  IDEALLY THESE SHOULD BE EMPTY, WITH NO UNPROCESSED
;  STUFF IN THE PIPE THAT MIGHT MUCK UP OUR REQUEST.  WE CAN FORCIBLY
;  EMPTY THE QUEUES, BUT WE WORRY ABOUT INTERFERRING WITH IN-PROGRESS
;  SETTING STRINGS.  IN THE ABSENCE OF MORE DATA ON THE SWIC SCANNER'S
;  BEHAVIOR WE ARE LIMITED TO CLEARING ONLY THE RECEIVE FIFO BEFORE
;  EVERY OPERATION.
;
;  WE KNOW THE NOMINAL LENGTH OF EACH TYPE OF BUFFER THE SCANNER IS
;  SUPPOSED TO PRODUCE.  IF THE USER IS REQUESTING THAT MANY WORDS
;  (OR MORE) WE RETURN THE NOMINAL NUMBER OF WORDS.  IF THE SCANNER
;  DOESN'T PRODUCE ENOUGH WORDS THEN WE RETURN NO-Q.
;
;  IF THE USER REQUESTS FEWER WORDS (E.G. JUST THE 7 IN THE HEADER),
;  THEN WE READ ONLY THOSE WORDS FROM THE FIFO.
;
;  READING-THE-SETTING IS IDENTICAL TO READING.  WE REQUIRE AN OFFSET
;  CODE = ZERO, THEREBY RETURNING THE CALCULATED DATA.
;
;  BEFORE SOME READINGS WE DELAY A FEW 15HZ TICKS.  IF THE READING
;  IS TRIGGERED OFF A CLOCK EVENT THE EXPECTATION IS THAT THE SCANNER
;  TRIGGER OFF THE SAME EVENT.  WE NEED TO GIVE THE SCANNERS TIME TO 
;  COMPUTE.  WE TAKE THIS AUTOMATIC DELAY ONLY FOR EVENT TRIGGERED
;  READINGS.
;
;  IN A SIMILAR SPIRIT, A NO-Q RESPONSE WILL CAUSE US TO DELAY AND
;  RETRY ALL READINGS.  THE PROBLEM OCCURS IF WE ATTEMPT TO READ WHILE
;  THE SCANNER IS BUSY.  WE RETRY ONLY A FEW TIMES.  IF WE STILL FAIL
;  WE RETURN A NO-Q ERROR.
;
;  THE IDEA OF USING THE 'OFFSET' AS A CODE IS DUE TO TOM GROVES.
;
;-----------------------------------------------------------------------
;
;  TABLE INDEXED BY 'BUFFER OFFSET', YIELDING:
;	1) COMMAND BYTE TO SEND TO SWIC SCANNER TO SATISFY OUR REQUEST.
;	2) LENGTH (WORDS) EXPECTED IN RETURN
;
;		 CMD  LEN	OFF CMD  MEANING
;		 ---  ---	--- ---  -------
RCMD43:	.BYTE	^O320,89.	;0   D0  CALCULATED DATA
	.BYTE	^O341,57.	;2   E1  RAW DATA FROM SCAN 1
	.BYTE	^O342,57.	;4   E2   "   "    "    "   2
	.BYTE	^O343,57.	;6   E3   "   "    "    "   3
	.BYTE	^O344,57.	;8   E4   "   "    "    "   4
	.BYTE	^O345,57.	;10  E5   "   "    "    "   5
	.BYTE	^O346,57.	;12  E6   "   "    "    "   6
	.BYTE	^O347,57.	;14  E7   "   "    "    "   7
	.BYTE	^O350,57.	;16  E8   "   "    "    "   8
	.BYTE	^O351,57.	;18  E9   "   "    "    "   9
	.BYTE	^O352,57.	;20  EA   "   "    "    "   10
	.BYTE	^O357,41.	;22  EF  TEST PATTERN DATA
	.BYTE	^O361,249.	;24  F1  RAW DATA FROM SCANS 1 TO 5
	.BYTE	^O362,249.	;26  F2  RAW DATA FROM SCANS 6 TO 10
MXOFF = <.-RCMD43>-2	;MAXIMUM OFFSET

;-----------------------------------------------------------------------
;
;  SWIC SCANNER SETTING PROPERTY.
;
;  THE USER'S BUFFER IS TRANSMITTED A BYTE AT A TIME THROUGH THE 032
;  CARD TO THE SCANNER.  SINCE ALL SWIC SCANNER COMMANDS ARE MERELY
;  BYTE STRINGS THIS APPROACH SHOULD BE PERFECTLY GENERAL.
;
;  WE DON'T BOTHER CLEARING ANY OF THE 032'S FIFOS BEFORE WE TRANSMIT.
;  WE DON'T WAIT FOR THE SETTING STRING TO PERCOLATE THROUGH BECAUSE
;  OUR READ PROTOCOL IS POLITE ENOUGH TO STACK UP ITS COMMANDS BEHIND.
;
;  A SETTING BYTE OF ZERO IS MEANINGLESS TO THE SWIC SCANNER, SO
;  WE HAVE RESERVED IT FOR A 'REBOOT' SEQUENCE.  WHEN WE SEE A ZERO
;  AS THE FIRST BYTE OF THE SETTING BUFFER WE SEND COMMANDS TO CLEAR
;  THE 032 CARD AS FOLLOWS:
;
;  	F(9)A(1)	CLEAR READ FIFO
;	F(12)A(0)	DISABLE INTERNAL JUMPER
;	F(9)A(0)	CLEAR WRITE FIFO
;	F(24)A(0)	DISABLE LAM
;	F(28)A(0)	DISABLE BLOCK TRANSFER
;
;  WE THEN SEND THE FOLLOWING INITIALIZATION SEQUENCE TO THE SCANNER:
;
;	02		END 'WRITE ASCII STRING' MODE (JUST IN CASE)
;	07		REBOOT
;	06		ENTER STORE MODE
;	3D		EXTERNAL TRIGGER
;	61		SINGLE SCAN
;	71		DISPLAY SCAN 1
;	40		1 MS INTEGRATION TIME
;
;  FINALLY, FOR NO APPARENT REASON, IT SEEMS BETTER IF WE SEND AN
;  EXTRA F(9)A(1).
;
;  IF THERE ARE FURTHER BYTES IN THE SETTING BUFFER BEYOND THE INITIAL
;  ZERO THEY WILL BE SENT FOLLOWING THIS SEQUENCE.
;
;  THE LENGTH OF SETTING BUFFERS IS LIMITED TO 24 BYTES.
;
;-----------------------------------------------------------------------