guy@proper.UUCP (Guy Hillyer ) (02/09/84)
Here are a couple of programs for reading and setting options on the Lear-Siegler ADM22 terminal. I would be interested to know if anyone finds these useful. -guy- (proper!guy) ---------------------adm22get.c------------------------- /* * command to get and print adm22 options. * * proper!guy 11-29-83 */ #include <sgtty.h> #include <signal.h> struct sgttyb ttyb; char rdln_command[2] = {'\033', '$'}; char stat_line[11]; main () { register int i; int noresponse(); gtty (2, &ttyb); ttyb.sg_flags |= RAW; stty (2, &ttyb); write (2, rdln_command, 2); signal (SIGALRM, noresponse); alarm (6); /* in case it isn't really an adm22 */ for (i = 0; i < 11; i++) read (0, stat_line + i, 1); ttyb.sg_flags &= ~RAW; stty (2, &ttyb); for (i = 0; i < 10; i++) printf ("%x ", stat_line[i] & 0xF); printf ("\n"); } noresponse () { ttyb.sg_flags &= ~RAW; stty (2, &ttyb); printf ("adm22get: No response from terminal\n"); exit (); } -----------------adm22set.c---------------------------- /* * command to set up adm22 options. * each argument is a value for a set-up nybble * as diplayed on the status line in set-up mode. * * proper!guy 11-29-83 */ #include <sgtty.h> struct sgttyb ttyb; char wrln_command[2] = {'\033', '%'}; char stat_line[10]; main (argc, argv) int argc; char *argv[]; { register int i; int j; int x; if (argc != 11) { printf("Proper usage is: %s <10 set up values>\n", argv[0]); exit (); } gtty (1, &ttyb); ttyb.sg_flags |= RAW; stty (1, &ttyb); for (i = 0; i < 10; i++) { sscanf (argv[i+1], "%x", &x); stat_line[i] = x & 0xF; } write (1, wrln_command, 2); for (i=0; i < 10; i++) { for (j=0; j < 10000; j++); /* a brief delay */ write (1, stat_line + i, 1); } ttyb.sg_flags &= ~RAW; stty (1, &ttyb); }