From: SMTP%"tihor@acf3.NYU.EDU" 18-JAN-1991 23:14:23.08 To: tihor@acf3.NYU.EDU CC: Subj: Re: Re(2): SET HOST/DER, modem writing Received: from acf3.NYU.EDU by ACF1.NYU.EDU with SMTP; Fri, 18 Jan 1991 23:14:12 EST Received: by acf3.NYU.EDU (5.65/1.34) id AA17891; Fri, 18 Jan 91 23:11:51 -0500 Date: Fri, 18 Jan 91 23:11:51 -0500 From: tihor@acf3.NYU.EDU (Stephen Tihor) Message-Id: <9101190411.AA17891@acf3.NYU.EDU> To: tihor@acf3.NYU.EDU Subject: Re: Re(2): SET HOST/DER, modem writing Newsgroups: comp.os.vms In-Reply-To: article <00942dbd.0616bf40.1374@SOL1.GPS.CALTECH.EDU> of 17 Jan 91 22:50 EST /* acf3:comp.os.vms / carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick) / 10:50 pm Jan 17, 1991 */ > > Does anyone know how to use SET/HOST/DTE TXnn: and issue commands from > > a batch job? I have some modems connected to the TX ports with callback > > security. To change the callback information e.g. telephone numbers), I have to > > do this manually as SET/HOST/DTE only works interactively. The modem call back > > information is long, complex with heaps of CTRL/characters, and no CR until the > > very END! > I had a similar problem trying to control a serial line with set host/dte > from a .com file. Couldn't get it to work so I called DEC support. They told > me that it cannot be done except interactively. It wouldn't be that hard to > write a short program to use QIOs to read and write data directly to and from > the serial line. Here's a program I wrote to do about the same thing that SET HOST/DTE does, with the exceptions that: 1) It doesn't disable flow control on the other end, so it's nowhere near as susceptible to data overruns; and 2) It doesn't send the initial carriage return to the other end. It shouldn't be too difficult to modify it to read from a file instead of a terminal. Hope this helps. #include stdio #include iodef #include ssdef #include ttdef #include tt2def #include descrip #define QUEUE(a,b,c,d,e,f) SYS$QIO(a,b,c,d,0,0,e,f,0,0,0,0) #define ckstat(x) if (((STAT = x) & 7) != 1) SYS$EXIT(STAT) #define CLEAN(x) if(((STAT = x) & 7) != 1) \ { cleanup(chans,termchar); SYS$EXIT(stat); } long STAT; #define ESCCHR ('\\' & 0x1F) sethost() { struct { unsigned short status, count; unsigned char term, dummy, trmlen, linel; } iosb[2]; $DESCRIPTOR(port, "TXA3"); $DESCRIPTOR(termname, "TT"); $DESCRIPTOR(mess, "Type control backslash (^\\) to exit"); static long funcs[3] = { IO$_WRITEVBLK | IO$M_BREAKTHRU, IO$_READVBLK | IO$M_TIMED, IO$_READVBLK }; long termchar[3], tmpchar[3], efn, efs, stat; short chans[2], stm, chan, func, cnt; unsigned char buffer[2][255]; LIB$PUT_OUTPUT(&mess); /* Assign channel to remote line */ ckstat(SYS$ASSIGN(&port, &chans[1], 0, 0)); /* And get terminal characteristics */ ckstat(SYS$QIOW(0,chans[1],IO$_SENSEMODE,&iosb[0],0,0,tmpchar,12,0,0,0,0)); ckstat(iosb[0].status); /* Then set modified characteristics */ tmpchar[1] |= TT$M_NOECHO | TT$M_HOSTSYNC; tmpchar[2] |= TT2$M_PASTHRU; ckstat(SYS$QIOW(0,chans[1],IO$_SETMODE,&iosb[0],0,0,tmpchar,12,0,0,0,0)); ckstat(iosb[0].status); /* Assign channel to local line */ ckstat(SYS$ASSIGN(&termname, &chans[0], 0, 0)); /* And get terminal characteristics */ ckstat(SYS$QIOW(0,chans[0],IO$_SENSEMODE,&iosb[1],0,0,termchar,12,0,0,0,0)); /* Then set modified characteristics */ tmpchar[0] = termchar[0]; tmpchar[1] = termchar[1] | TT$M_NOECHO; tmpchar[2] = termchar[2] | TT2$M_PASTHRU; ckstat(SYS$QIOW(0,chans[0],IO$_SETMODE,&iosb[1],0,0,tmpchar,12,0,0,0,0)); ckstat(iosb[1].status); /* Set up MODEM for appropriate operation */ CLEAN(QUEUE(3,chans[1],funcs[2],&iosb[0],buffer[0],1)); CLEAN(QUEUE(7,chans[0],funcs[2],&iosb[1],buffer[1],1)); while (SYS$WFLOR(1,204) == 1) { for(efn = 2; efn < 8; ++efn) { if(((efn & 2) == 2) && SYS$READEF(efn, tmpchar) == SS$_WASSET) { SYS$CLREF(efn); stm = efn/4; func = efn & 1; chan = func ^ stm; cnt = iosb[stm].count + iosb[stm].trmlen; stat = iosb[stm].status; if (stat == SS$_NORMAL || ((stat == SS$_TIMEOUT) && cnt > 0)) { if(func == 1) { if(stm == 1 && find(ESCCHR, buffer[stm], cnt)) { cleanup(chans,termchar); SYS$EXIT(1); } } efn ^= 1; func ^= 1; chan ^= 1; if (func == 1) cnt = 255; CLEAN(QUEUE(efn,chans[chan],funcs[func],&iosb[stm], buffer[stm],cnt)); } else if(stat == SS$_TIMEOUT && cnt == 0 && func == 1) { func = 2; CLEAN(QUEUE(efn,chans[chan],funcs[func],&iosb[stm], buffer[stm],1)); } else { cleanup(chans,termchar); SYS$EXIT(stat); } } } } } find(c,s,n) char c, *s; int n; { for(--n; n >= 0 && *s != c; ++s, --n); return(n >= 0); } cleanup(chans, termchar) short chans[2]; long termchar[3]; { SYS$CANCEL(chans[0]); SYS$CANCEL(chans[1]); SYS$QIOW(0,chans[0],IO$_SETMODE,0,0,0,termchar,12,0,0,0,0); } /* ---------- */