--- ray/src/rt/devcomm.c 1990/02/22 11:46:13 1.12 +++ ray/src/rt/devcomm.c 1990/03/12 11:08:44 1.16 @@ -12,8 +12,6 @@ static char SCCSid[] = "$SunId$ LBL"; #include "standard.h" -#include - #include "color.h" #include "driver.h" @@ -22,15 +20,17 @@ static char SCCSid[] = "$SunId$ LBL"; #define DEVPATH getenv("PATH") /* device search path */ #endif +#ifndef DELAY +#define DELAY 20 /* seconds to wait for response */ +#endif + #ifndef BSD #define vfork fork #endif extern char *getpath(), *getenv(); -int onsigio(); - -int comm_close(), comm_clear(), comm_paintr(), comm_errout(), +static int comm_close(), comm_clear(), comm_paintr(), comm_errout(), comm_getcur(), comm_comout(), comm_comin(), comm_flush(); struct driver comm_driver = { @@ -76,17 +76,13 @@ char *dname, *id; goto syserr; if ((devin = fdopen(p2[0], "r")) == NULL) goto syserr; - /* verify & get resolution */ + /* verify initialization */ putw(COM_SENDM, devout); fflush(devout); if (getw(devin) != COM_RECVM) return(NULL); - fread((char *)&comm_driver.pixaspect, - sizeof(comm_driver.pixaspect), 1, devin); - comm_driver.xsiz = getw(devin); - comm_driver.ysiz = getw(devin); - /* input handling */ - signal(SIGIO, onsigio); + /* get driver parameters */ + comm_flush(); /* set error vectors */ cmdvec = comm_comout; if (wrnvec != NULL) @@ -106,7 +102,6 @@ comm_close() /* done with driver */ cmdvec = NULL; /* reset error vectors */ if (wrnvec != NULL) wrnvec = stderr_v; - signal(SIGIO, SIG_DFL); fclose(devout); fclose(devin); while ((pid = wait(0)) != -1 && pid != devchild) @@ -144,6 +139,13 @@ comm_flush() /* flush output to driver */ { putc(COM_FLUSH, devout); fflush(devout); + if (getc(devin) != COM_FLUSH) + reply_error("flush"); + fread((char *)&comm_driver.pixaspect, + sizeof(comm_driver.pixaspect), 1, devin); + comm_driver.xsiz = getw(devin); + comm_driver.ysiz = getw(devin); + comm_driver.inpready = getw(devin); } @@ -170,7 +172,6 @@ char *str; { putc(COM_COMOUT, devout); myputs(str, devout); - fflush(devout); } @@ -190,8 +191,7 @@ char *prompt; if (getc(devin) != COM_COMIN) reply_error("comin"); mygets(buf, devin); - if (comm_driver.inpready > 0) - comm_driver.inpready--; + comm_driver.inpready = getw(devin); } @@ -236,11 +236,4 @@ char *routine; stderr_v(routine); stderr_v(": driver reply error\n"); quit(1); -} - - -static -onsigio() /* input ready */ -{ - comm_driver.inpready++; }