[fa.info-cpm] Interrupting CONOUT with CONOUT => lost data?

info-cpm (12/18/82)

>From bridger@Rand-Unix  Thu Dec 16 01:08:44 1982
To: INFO-CPM@BRL, H19-PEOPLE@Mit-Mc
Via:  Rand-Unix; 17 Dec 82 23:42-EST
Via:  Brl; 18 Dec 82 0:21-EST
Via:  Brl-Bmd; 18 Dec 82 0:40-EST

	I've been using a clock/calendar that interrupts once a second and
calls a service routine that sends the current time to the bottom right
corner of the terminal screen.  To do this it sends escape sequences to
save the cursor, position it, and restore it.  The characters are sent
by  BIOS calls to CONOUT.
	Randomly, the terminal would print the time but then fail
to restore the cursor, or switch into reverse video or some other mode.
Things got worse with a new terminal rom (the Super19 ROM for the Heath
H-19) running at 38.4K baud, because this rom has a host of new
escape sequences for extra modes, some of which reinterprete the 
standard ASCII characters.  Having the terminal suddenly in never-never land
is a real pain; to recover you have to go into off-line mode, and reset
the correct modes.
	It turn out that the BIOS is sending characters to the terminal
when it isn't ready to accept them.  At least one gets lost; when the last-
arrived character is an Escape, and its successor is overtaken by another
character, the terminal switches executes a faulty sequence.  For example:

	'ESC k p' --  'ESC k' is restore cursor, 'p' is data
	If 'k' is overtaken, the terminal executes 'ESC p' = reverse video !

	My CONOUT implements hardware handshaking, using the H-89's
8250 serial chip.  I assumed that this, coupled with handshaking by the
H-19 terminal, would prevent dropped characters.  

	NOT SO!! -- because the interrupt routine uses the console output data
port the following sequence of events can and does occur:

	main program sends character to CONOUT
		CONOUT checks clear-to-send line:  it's clear
		now clock interrupts
			saves registers
			clock routine sends a string of characters,
			   filling the terminal buffer
			terminal turns off clear-to-send line: not clear now
			restores registers & returns
		  character sent to terminal (!!)
		  returns to main program
	
	In other words, the real-time status of the CTS line changes from
the time CONOUT reads the line to when it outputs the character.

	Solutions: (1) disable interrupts before reading CTS, enable after
sending the character; have the clock routine use a private version of CONOUT
that doesn't enable interrupts.  (2) Set a flag on entry to CONOUT, reset it
on exit; when flag is set have the clock routine poll CTS until clear before
returning.
	This complexity wouldn't arise if the 8250 had on-chip handshaking
(like the Z-80 SIO) and didn't send out a character until the CTS line
is clear.  I guess the moral is not to trust an interruptible handshake!

	My suspicions that the Super19 ROM was at fault were unfounded, and
I appreciate the time Bob Todd at Extended Technology Systems took to check 
out my questions.  It is indeed a high performance addition to the H-19.
With hardware handshaking and 38.4K baud, text can be redisplayed and edited
very effectively.  
	Now I'm curious to see what the game writers can do with it!
	.


*** Problem during mail receipt from Arpanet ***

info-cpm (12/18/82)

>From bridger@Rand-Unix  Thu Dec 16 01:16:06 1982
To: INFO-CPM@BRL, H19-PEOPLE@Mit-Mc
Via:  Rand-Unix; 18 Dec 82 0:00-EST
Via:  Brl; 18 Dec 82 0:22-EST
Via:  Brl-Bmd; 18 Dec 82 0:41-EST

	I've been using a clock/calendar that interrupts once a second and
calls a service routine that sends the current time to the bottom right
corner of the terminal screen.  To do this it sends escape sequences to
save the cursor, position it, and restore it.  The characters are sent
by  BIOS calls to CONOUT.
	Randomly, the terminal would print the time but then fail
to restore the cursor, or switch into reverse video or some other mode.
Things got worse with a new terminal rom (the Super19 ROM for the Heath
H-19) running at 38.4K baud, because this rom has a host of new
escape sequences for extra modes, some of which reinterprete the 
standard ASCII characters.  Having the terminal suddenly in never-never land
is a real pain; to recover you have to go into off-line mode, and reset
the correct modes.
	It turn out that the BIOS is sending characters to the terminal
when it isn't ready to accept them.  At least one gets lost; when the last-
arrived character is an Escape, and its successor is overtaken by another
character, the terminal switches executes a faulty sequence.  For example:

	'ESC k p' --  'ESC k' is restore cursor, 'p' is data
	If 'k' is overtaken, the terminal executes 'ESC p' = reverse video !

	My CONOUT implements hardware handshaking, using the H-89's
8250 serial chip.  I assumed that this, coupled with handshaking by the
H-19 terminal, would prevent dropped characters.  

	NOT SO!! -- because the interrupt routine uses the console output data
port the following sequence of events can and does occur:

	main program sends character to CONOUT
		CONOUT checks clear-to-send line:  it's clear
		now clock interrupts
			saves registers
			clock routine sends a string of characters,
			   filling the terminal buffer
			terminal turns off clear-to-send line: not clear now
			restores registers & returns
		  character sent to terminal (!!)
		  returns to main program
	
	In other words, the real-time status of the CTS line changes from
the time CONOUT reads the line to when it outputs the character.

	Solutions: (1) disable interrupts before reading CTS, enable after
sending the character; have the clock routine use a private version of CONOUT
that doesn't enable interrupts.  (2) Set a flag on entry to CONOUT, reset it
on exit; when flag is set have the clock routine poll CTS until clear before
returning.
	This complexity wouldn't arise if the 8250 had on-chip handshaking
(like the Z-80 SIO) and didn't send out a character until the CTS line
is clear.  I guess the moral is not to trust an interruptible handshake!

	My suspicions that the Super19 ROM was at fault were unfounded, and
I appreciate the time Bob Todd at Extended Technology Systems took to check 
out my questions.  It is indeed a high performance addition to the H-19.
With hardware handshaking and 38.4K baud, text can be redisplayed and edited
very effectively.  
	Now I'm curious to see what the game writers can do with it!

info-cpm (12/18/82)

>From bridger@Rand-Unix  Thu Dec 16 01:51:25 1982
To: INFO-CPM@BRL, H19-PEOPLE@Mit-Mc
Via:  Rand-Unix; 17 Dec 82 23:27-EST
Via:  Brl; 17 Dec 82 23:56-EST
Via:  Brl-Bmd; 18 Dec 82 0:07-EST

	I've been using a clock/calendar that interrupts once a second and
calls a service routine that sends the current time to the bottom right
corner of the terminal screen.  To do this it sends escape sequences to
save the cursor, position it, and restore it.  The characters are sent
by  BIOS calls to CONOUT.
	Randomly, the terminal would print the time but then fail
to restore the cursor, or switch into reverse video or some other mode.
Things got worse with a new terminal rom (the Super19 ROM for the Heath
H-19) running at 38.4K baud, because this rom has a host of new
escape sequences for extra modes, some of which reinterprete the 
standard ASCII characters.  Having the terminal suddenly in never-never land
is a real pain; to recover you have to go into off-line mode, and reset
the correct modes.
	It turn out that the BIOS is sending characters to the terminal
when it isn't ready to accept them.  At least one gets lost; when the last-
arrived character is an Escape, and its successor is overtaken by another
character, the terminal switches executes a faulty sequence.  For example:

	'ESC k p' --  'ESC k' is restore cursor, 'p' is data
	If 'k' is overtaken, the terminal executes 'ESC p' = reverse video !

	My CONOUT implements hardware handshaking, using the H-89's
8250 serial chip.  I assumed that this, coupled with handshaking by the
H-19 terminal, would prevent dropped characters.  

	NOT SO!! -- because the interrupt routine uses the console output data
port the following sequence of events can and does occur:

	main program sends character to CONOUT
		CONOUT checks clear-to-send line:  it's clear
		now clock interrupts
			saves registers
			clock routine sends a string of characters,
			   filling the terminal buffer
			terminal turns off clear-to-send line: not clear now
			restores registers & returns
		  character sent to terminal (!!)
		  returns to main program
	
	In other words, the real-time status of the CTS line changes from
the time CONOUT reads the line to when it outputs the character.

	Solutions: (1) disable interrupts before reading CTS, enable after
sending the character; have the clock routine use a private version of CONOUT
that doesn't enable interrupts.  (2) Set a flag on entry to CONOUT, reset it
on exit; when flag is set have the clock routine poll CTS until clear before
returning.
	This complexity wouldn't arise if the 8250 had on-chip handshaking
(like the Z-80 SIO) and didn't send out a character until the CTS line
is clear.  I guess the moral is not to trust an interruptible handshake!

	My suspicions that the Super19 ROM was at fault were unfounded, and
I appreciate the time Bob Todd at Extended Technology Systems took to check 
out my questions.  It is indeed a high performance addition to the H-19.
With hardware handshaking and 38.4K baud, text can be redisplayed and edited
very effectively.  
	Now I'm curious to see what the game writers can do with it!
	.


*** Problem during mail receipt from Arpanet ***

info-cpm (12/20/82)

>From Thieret.WBST@Parc-Maxc  Sat Dec 18 13:12:20 1982
In-Reply-To: bridger's message of Friday, 17 Dec 1982 19:07-PST
To: bridger@Rand-Unix
Cc: INFO-CPM@BRL, H19-PEOPLE@Mit-Mc
Via:  Parc-Maxc; 20 Dec 82 12:55-EST
Via:  Brl; 20 Dec 82 14:03-EST
Via:  Brl-Bmd; 20 Dec 82 14:28-EST

Please tell me something about the Super19 ROM for the H-19 terminal.  Where
can I get one ?  What does it do that is so great? How much is it?  If it really
helps (allows >9600 baud) I'm really interested.  Thanks.

Tracy Thieret