[comp.unix.xenix] I've got a dialTBIT for the internal TB.

david@llustig.uucp (David Schachter) (02/20/90)

I installed a T18PC and found the dialTBIT program from SCO didn't work work
too well as it assumes the presence of non-volatile memory which the T18PC
lacks.  So I munged it quite a bit to work correctly with the T18PC.  I'd like
to make it available, but the original code has copyright notices for SCO and
Microsoft.  What to do?

SCO, are you willing to renounce the copyright?  (XENIX will no longer be
upgraded, according to SCO Exec. V.P. Doug Michaels, just bug fixes through
1991 and then death, so what's to lose?)

The code has been working for about three weeks without failures (since the
friendly folks at 1-800-TELEBIT helped with a few register settings I didn't
alter correctly.)  By the way, XENIX on an Everex 386/20 handles 1380 cps
incoming through the TB without a hiccup, or discernible foreground impact.
And that's with an 8250, which ain't supposed to work at those speeds.

					-- David Schachter
					   llustig!david@mips.com

bob@consult.UUCP (Bob Willey) (02/21/90)

I know that there are quite a few people out there that are
interested in the same thing. 
If you could come up with a distribution, I am sure you will
find several of us out here that would love to pick it up.
Let us know how you would like to distribute, e-mail or slow-mail.
We could send diskettes if you would like.
Thanks for your time.

-- 
.. Computer Consulting Service     ..    Bob Willey, CDP     ..
.. P.O. Drawer 1690                ..    uunet!consult!bob   ..
.. Easton, Maryland  21601         ..    (301) 820-4670      ..
...............................................................

david@llustig.uucp (David Schachter) (02/24/90)

I could post the diff without compromising the ethics of the SCO/Microsoft
copyright, IMHO.  The diff is 9376 bytes.  Objections?  If not, I'll do it
on Monday, Feb 26.

The T18PC mailing list has seen several dialTBIT programs modified for the
T18PC.  I haven't been able to find out anymore than that.

					-- David Schachter
					   llustig!david@mips.com  OR MAYBE
					   david@llustig.uucp
					   ...!uunet!mips!llustig!david

david@llustig.uucp (David Schachter) (02/27/90)

Here are the diffs to convert SCO's dialTBIT.c for the T18PC internal modem.
It does NOT work with the external modems.

The modem does not wait for dialtone before dialing; Telebit says the behavior
is correct; I disagree, hence the first comment.  Error handling in one of the
original routines is questionable; I added a comment to that effect.  A change
orthogonal to the T18PC changes is to make the S0 register time-of-day
sensitive, since my site uses the modem line as an auxiliary voice line during
certain hours.  Flow control is disabled; I'm not sure whether XENIX handles
it correctly, and the system works fine without it, transferring full news
feeds and email.  Perhaps a more loaded system would experience failures.

These changes are in the public domain.  If you have questions or suggestions
or bug fixes, I'd like to hear about 'em.  If you have an extra car, or too
much money, or gold, I'd like to get some.  Absolute power over space and time,
too.

					-- David Schachter
					   llustig!david@mips.com  OR MAYBE
					   david@llustig.uucp
					   ...!uunet!mips!llustig!david



9a10,13
> /* Modified by D. Schachter, Jan. 31, 1990: Copy dialTBIT.c, change MDDIALOUT
> 	to add S7=60.  A bunch of other changes for the internal modem.  Also
> 	change ATDP to ATDPW, to wait for first dial tone.  (Telebit doesn't,
> 	which they say is correct, but I think they are wrong.)
57a62,63
> /* Added by D. Schachter, Jan. 31, 1990, for time-of-day S0 register setting */
> #include <time.h>
117d122
<  * M0		- Speaker disabled at all times
121c126,127
<  * S0=1		- Answer on first ring
---
>  * S0=1		- Answer on first ring (or on third, depending on time-of-day)
> 			  see comment in hangup().
123c129
<  * S7=40	- Set connect timeout to default value
---
>  * S7=40	- Set connect timeout
127,128c133,134
<  * S51=254	- Set serial port baud rate automatically, using 19200 for PEP.
<  * S52=2	- Go on hook when dtr drops and reset to NV-RAM
---
>  * S51=5	- Irrelevant on internal modem
>  * S52=1	- Go on hook when dtr drops
132,133c138
<  * S58=2	- DTE uses CTS/RTS flow control.
<  * S59=052	- Set prompt to "*" (?)
---
>  * S58=0	- No flow control (XENIX problem w/uucico setting raw mode.)
135,136c140,141
<  * S66=0	- Don't lock interface speed, just go with the flow.
<  * S68=255	- DCE uses whatever flow control DTE uses
---
>  * S66=1	- Lock interface speed
>  * S68=3	- Flow control from modem to computer is XONXOFF
140d144
<  * &W		- Write all of this into Non-Volatile RAM
144,145c148,150
< #define	MDSETUP1 "AT&FE0F1M0Q4V1X3S2=043S45=0S48=1S50=0S51=254S52=2\r"
< #define MDSETUP2 "ATS53=1S54=3S55=0S58=2S60=0S66=0S68=255S92=1S110=255S111=255&W\r"
---
> #define	MDSETUP1 "AT&FE0F1Q4V1X3S2=043S7=40S45=0S48=1S50=0S51=5S52=1S53=1\r"
> #define MDSETUP2 "ATS0=1S54=3S55=0S58=0S60=0S66=1S68=3S92=1S110=255S111=255\r"
> #define MDSETUP3 "ATS0=3S54=3S55=0S58=0S60=0S66=1S68=3S92=1S110=255S111=255\r"
240a246
>  *  S7=60	- Set 60 second timeout for PEP-tones-last connections
242c248
< #define	MDDIALOUT "ATS66=1S110=255\r"
---
> #define	MDDIALOUT "ATS66=1S110=255S7=60\r"
318d323
< int zflag = 0;				/* set to setup modem		*/
419c424,427
< 				zflag++;
---
> /* Modified by D. Schachter, Jan. 31, 1990: Internal modem has no non-volatile
>    memory so I modified hflag to reset parameters and cause -z to invoke it
>    instead of old zflag stuff. */
> 				hflag++;
440c448
< 	if (hflag || zflag)
---
> 	if (hflag)
456,460d463
< 		else if (zflag)
< 		{
< 			fprintf (stderr,
< 				"Usage:\t%s -z devicename speed\n", argv[0]);
< 		}
472c475
< 	if (!(hflag || zflag))
---
> 	if (!hflag)
600,607d602
< 	/*
< 	 * Since this is the first connect, the modem needs to
< 	 * figure out our baud rate.
< 	 */
< 	if (mdsync () == RC_FAIL)
< 	{
< 		cleanup (RC_FAIL | retcode);
< 	}
610c605
< 	 *  Initialize the modem
---
> 	 * Set up modem for generic dial out settings.
612,614c607
< 	if (zflag)
< 	{
< 	    DEBUG(6, "Initializing modem at %s\n", acu);
---
> 	DEBUG(3, "Setting DIAL OUT mode%c", '\n');
616,623c609,614
< 	    if (mdwrite(MDSETUP1) == -1)
< 		{
< 			cleanup (RC_FAIL | retcode);
< 		}
< 	    if (mdread (timeout) != OK)
< 		{
< 			cleanup (RC_FAIL | retcode);
< 		}
---
> /* Modified by D. Schachter, Jan. 31, 1990: Internal modem has no non-volatile
>    memory so we have to reset things before each call.						 */
> 	if (mdwrite(MDSETUP1) == -1)
> 		cleanup (RC_FAIL | retcode);
> 	if (mdread (timeout) != OK)
> 		cleanup (RC_FAIL | retcode);
625,676c616
< 	    /*
< 	     * Since MDSETUP1 sets the "autobaud" mode, it forgot our
< 	     * baud rate...
< 	     */
< 		if (mdsync () == RC_FAIL)
< 		{
< 			cleanup (RC_FAIL | retcode);
< 		}
< 
< 	    if (mdwrite (MDSETUP2) == -1)
< 		{
< 			cleanup (RC_FAIL | retcode);
< 		}
< 	    if (mdread (timeout) != OK)
< 		{
< 			cleanup (RC_FAIL | retcode);
< 		}
< 
< 	    cleanup (re_getty ("modem init"));
< 	}
< 
< 	/*
< 	 *  Reset and put modem into command mode
< 	 */
< 	reset:
< 
< 	DEBUG(3, "Resetting modem%c", '\n');
< 
< 	if (mdwrite(MDRESET) == -1)
< 	{
< 		cleanup(RC_FAIL | retcode);
< 	}
< 
< 	if (mdread(timeout) != OK)
< 	{
< 		if (hangup(timeout) == -1)
< 		{
< 			cleanup(RC_FAIL | retcode | RCE_HANGUP);
< 		}
< 		goto reset;
< 	}
< 
< 	/*
< 	 *  Must wait at least 0.5 seconds after reset
< 	 *  for Telebit to recover and receive commands.
< 	 *	Then, since MDRESET made it forget our baud rate,
< 	 *	we need to mdsync() again.
< 	 */
< 	nap(500L);
< 
< 	if (mdsync () == RC_FAIL)
< 	{
---
> 	if (mdwrite (MDSETUP2) == -1)
678c618,619
< 	}
---
> 	if (mdread (timeout) != OK)
> 		cleanup (RC_FAIL | retcode);
680,684d620
< 	/*
< 	 * Set up modem for generic dial out settings.
< 	 */
< 	DEBUG(3, "Setting DIAL OUT mode%c", '\n');
< 
686d621
< 	{
688d622
< 	}
690d623
< 	{
692d624
< 	}
694d625
< #ifdef LATER
696,743d626
< 	 *  If we were given a specific baudrate to use, and that
< 	 *  baudrate less than or equal to 2400, unlock the modem speed.
< 	 */
< 	if ((lowbaud == highbaud) && (highbaud <= B2400))
< 	{
< 		char speedstr[9], speed[5];
< 		DEBUG(3, "Unlocking modem speed%c", '\n');
< 
< 		if (mdwrite(MDUNLOCK) == -1)
< 		{
< 			cleanup(RC_FAIL | retcode);
< 		}
< 		if (mdread(timeout) != OK)
< 		{
< 			cleanup(RC_FAIL | retcode);
< 		}
< 		strcpy(speedstr, "ATS50=0\r");
< 
< 		switch (lowbaud)
< 		{
< 		    case B300:
< 			strcpy(speedstr, "ATS50=1\r");
< 			strcpy(speed,"300");
< 			break;
< 		    case B1200:
< 			strcpy(speedstr, "ATS50=2\r");
< 			strcpy(speed,"1200");
< 			break;
< 		    case B2400:
< 			strcpy(speedstr, "ATS50=3\r");
< 			strcpy(speed,"2400");
< 			break;
< 		}
< 		DEBUG(3, "Setting modem connect speed to %s baud\n", speed);
< 
< 		if (mdwrite(speedstr) == -1)
< 		{
< 			cleanup(RC_FAIL | retcode);
< 		}
< 		if (mdread(timeout) != OK)
< 		{
< 			cleanup(RC_FAIL | retcode);
< 		}
< 		speedlock = 0;
< 	}
< #endif /* LATER */
< 
< 	/*
850c733
< 	sprintf(command, "ATDT%s\r", phone);
---
> 	sprintf(command, "ATDPW%s\r", phone);
857c740,742
< 	timeout = 6 * strlen(phone) + 15;
---
> /* Modified by D. Schachter, Jan. 31, 1990: Increase timeout for slow remote
>    modems.
> 	timeout = 6 * strlen(phone) + 45;
933a819,821
> 	time_t now;
> 	struct tm *tm_struct;
> 	char * second_setup_string;
953c841
< 		/* Give it a minute to think about it */
---
> 		/* Give it a second to think about it */
962,967c850
< 		/*
< 		 * First sync the baud rate.
< 		 * Don't bother sending the hangup stuff
< 		 * if we couldn't even sync baud rates.
< 		 */
< 		if (mdsync () != RC_FAIL)
---
> 		if (mdwrite (MDHANGUP) == -1)
969,978c852,853
< 			if (mdwrite (MDHANGUP) == -1)
< 			{
< 				retcode = old_retcode;
< 				return (rcode);
< 			}
< 
< 			if (mdread (htime) == OK)
< 			{
< 				rcode = 0;
< 			}
---
> 			retcode = old_retcode;
> 			return (rcode);
980a856,858
> 		if (mdread (htime) == OK)
> 			rcode = 0;
> 
992a871,892
> 
> /* Added by D. Schachter, Jan. 31, 1990: Internal modem has no non-volatile
> 	memory, so we have to reset things for dialin use when hanging up. */
> 		if (mdwrite(MDSETUP1) == -1)
> 			cleanup (RC_FAIL | retcode);
> 		if (mdread (timeout) != OK)
> 			cleanup (RC_FAIL | retcode);
> 
> /* Modified by D. Schachter, Jan. 31, 1990 to make program sensitive to time-
>    of-day for selecting whether to answer on first or third ring.  From mid-
>    night to 9 am, first ring.  After 9 am, third ring.						 */
> 
> 		now = time(NULL);
> 		tm_struct = localtime(&now);
> 		if ((tm_struct -> tm_hour) < 9)
> 			second_setup_string = MDSETUP2;
> 		else
> 			second_setup_string = MDSETUP3;
> 	    if (mdwrite (second_setup_string) == -1)
> 			cleanup (RC_FAIL | retcode);
> 	    if (mdread (timeout) != OK)
> 			cleanup (RC_FAIL | retcode);
994a895,897
> /* The error handling in here is botched; I should clean this up but I don't
>    really care enough.  -- D. Schachter, Jan. 31, 1990, 4:16 am				 */
> 
1277,1352d1179
< /*
<  * In order to figure out our baud rate, the modem needs
<  * an "a" character.  We send it twice for good measure,
<  * and pause 1/4 second after each one.
<  */
< mdsync()
< {
< 	int (*old_alrm)();
< 	char buf[MAXLINE];
< 	int count = 0, n;
< 
< 	old_alrm = signal(SIGALRM, nil);	/* alarms are non-fatal here */
< 
< 	DEBUG (7, "Syncing baud rate...", "");
< 
< 	while (++count < 10)
< 	{
< 		/*
< 		 * Send 'a'<pause>'a'<pause>... to make the modem sync to our
< 		 * baud rate.
< 		 */
< 		sendsync ();
< 
< 		/*
< 		 * Send ATQ4 to make sure the modem has response codes
< 		 * enabled.  If the modem is talking our speed, this will
< 		 * always result in "OK".  First we eat output from
< 		 * the modem.
< 		 */
< 		mdflush ();
< 		mdwrite ("ATQ4\r");
< 
< 		/*
< 		 * If we don't get "OK" in 2 seconds, we ain't gonna.
< 		 */
< 		if (mdread(2) == OK ) {
< 		   break;
< 		}
< 	}
< 
< 	/*
< 	 * At debug level 9, we print an 'a' every time we send one.
< 	 * These dots make things look prettier.
< 	 */
< 	DEBUG (9, "%s", "...");
< 
< 	signal (SIGALRM, old_alrm);
< 
< 	if (count < 10)
< 	{
< 		DEBUG (7, "%s\n", "done.");
< 		return (0);
< 	}
< 	else
< 	{
< 		DEBUG (7, "%s\n", "FAIL");
< 		return (RC_FAIL);
< 	}
< }
< 
< #define NSYNCS	4		/* Number of a's to send each time */
< 
< /*
<  * Sendsync: Send a's to make the modem sync to our baud rate.
<  */
< sendsync ()
< {
< 	int count = 0;
< 	
< 	while (count++ < NSYNCS)
< 	{
< 		write (fd, "a", 1);
< 		DEBUG (9, "%c", 'a');
< 		nap (250L); /* wait between each one */
< 	}
< }