jbayer@ispi.UUCP (id for use with uunet/usenet) (09/17/88)
This is a patch for the recent version of Pcomm 1.1 which was recently posted to the net. It corrects a problem when accessing a port which has modem control on it, and another problem with some stupid modems on the market. See the README for a full description. Jonathan Bayer Intelligent Software Products, Inc. 19 Virginia Ave. Rockville Centre, NY 11570 uunet!ispi!jbayer = = = = = = = = = = = = = cut here = = = = = = = = = = = = = = = = #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: README patch # Wrapped by news@ on Fri Sep 16 22:06:35 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(2211 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XThe enclosed patches fix two problems with pcomm 1.1, with the first Xpatch applied. X XThe first bug is that after pcomm sets the CLOCAL mode it doesn't Xre-open the tty port. This is important if the program is sharing a Xdial-out port with uucp and you have to specify a port which has modem Xcontrol. In this case the program would just chug merrily along Xsending characters to the modem, while the OS would not pass them along Xto the modem. X XThe addition to port.c allows Pcomm to be able to access the modem if Xthe port was originally opened with modem control. line_set() removes Xthe modem control, but the open file still has it. By re-opening the Xport here, and then closing the old file descriptor, Pcomm can access Xthe port correctly. X XThe second bug is not with Pcomm directly, but with some stupid modems Xwhich are on the market. Some modems cannot receive the AT commands at Xthe full baud rate they are set at. The sent_str() routine is the Xproblem here. The modifications force Pcomm to send characters to the Xmodem at a rate of 10 chars per second. Each character is sent at the Xcorrect baud rate, there is just a delay of 1/10 sec inserted between Xeach character. The modem commands in port.c which use the send_str() Xfunction now call slow_send_str(). See the changes in both port.c and Xdial.c. The function do_pause() is dial.c does the delay. do_pause() Xdepends on the environment variable HZ to store the number of clock Xticks per second. X X XA few features I would like to see added to pcomm are: X1. VERY IMPORTANT: Please add a patchlevel.h file indicating X the patchlevel of the current system. X2. a local dialing directory, probably with a name like: X .pcomm.phone X in the user's home directory X X3. zmodem support built in, possibly using external programs X4. Compuserve B protocol X5. Adding the lock file format and location to the configuration file. X6. A possible check of long distance numbers is to limit the number X of digits in a phone number. Also, specify which digit would be X the SECOND digit of the area code; if it is a zero or a 1 then X it is an area code and therefore a long-distance number. I have X not done any work on this since I don't have that problem. X X END_OF_FILE if test 2211 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'patch' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'patch'\" else echo shar: Extracting \"'patch'\" \(5281 characters\) sed "s/^X//" >'patch' <<'END_OF_FILE' X*** dial.c- Fri Sep 16 22:01:32 1988 X--- dial.c Fri Sep 16 22:01:58 1988 X*************** X*** 123,133 **** X--- 123,182 ---- X return; X } X X+ X+ /* The following routines was added by J. Bayer to slow down the transmission X+ ** of commands to the modem. Some modems choke if the commands are sent X+ ** at full speed. This code is designed to send the commands at a speed X+ ** of app. 10 characters per second. This is different from the baud rate X+ */ X+ int slow_send = 0; X+ X+ /* do_pause depends on the environment variable HZ to store X+ ** the number of clock ticks per second. If it is X+ ** not there then it will default to 50, which is X+ ** a reasonable number for Xenix X+ */ X+ X+ void do_pause() X+ { X+ #include <sys/types.h> X+ #include <sys/times.h> X+ struct tms t; X+ long t1; X+ int hz = 0; X+ char *home; X+ unsigned int sleep(); X+ X+ if ((home = getenv("HZ")) != NULL) X+ hz = atoi(home); X+ if (!hz) hz = 50; X+ X+ t1 = times(&t); X+ while ( (times(&t) - t1) < hz/10); X+ } /* do_pause */ X+ X+ X+ void X+ slow_send_str(s) X+ char *s; X+ { X+ void send_str(); X+ X+ slow_send++; X+ send_str(s); X+ slow_send--; X+ } /* slow_send_str */ X+ X+ X+ X+ X+ X /* X * Send a string to the modem. Performs all the character synonym X * translations. No sanity checking on the "m_cur" value. X */ X X+ X void X send_str(s) X char *s; X*************** X*** 151,156 **** X--- 200,206 ---- X if (skip) { X skip = 0; X write(fd, s, 1); X+ if (slow_send) do_pause(); X ioctl(fd, TCSBRK, 1); X #ifdef DEBUG X fprintf(stderr, "send_str: '%c', %02x, %03o, %d\n", *s, *s, *s, *s); X*************** X*** 197,202 **** X--- 247,254 ---- X } X X write(fd, s, 1); X+ if (slow_send) do_pause(); X+ X #ifdef DEBUG X fprintf(stderr, "send_str: '%c', %02x, %03o, %d\n", *s, *s, *s, *s); X #endif /* DEBUG */ X*************** X*** 209,214 **** X--- 261,268 ---- X } X return; X } X+ X+ X X /* X * Read the result codes coming back from the modem. Test for the 6 X*** port.c- Fri Sep 16 22:01:22 1988 X--- port.c Fri Sep 16 22:01:58 1988 X*************** X*** 31,42 **** X int j, k, lfd, list[NUM_TTY], cmask, tbaud; X char file[80], buf[80], message[80], *strdup(); X unsigned int sleep(); X! void error_win(), line_set(), release_port(), send_str(); X void free_ptr(); X #ifndef ASCII_PID X int progpid; X #endif /* ASCII_PID */ X X /* X * If we already have a port, see if it is good enough for the X * current request. X--- 31,44 ---- X int j, k, lfd, list[NUM_TTY], cmask, tbaud; X char file[80], buf[80], message[80], *strdup(); X unsigned int sleep(); X! void error_win(), line_set(), release_port(), send_str(), slow_send_str(); X void free_ptr(); X #ifndef ASCII_PID X int progpid; X #endif /* ASCII_PID */ X X+ int fd1; /* added by J. Bayer */ X+ X /* X * If we already have a port, see if it is good enough for the X * current request. X*************** X*** 137,143 **** X X /* open the device (ignore DCD) */ X sprintf(buf, "/dev/%s", modem->tty[modem->t_cur]); X! if ((fd = open(buf, O_RDWR|O_NDELAY)) < 0) { X if (getty_status) X set_getty(modem->tty[modem->t_cur], 1); X sprintf(file, "Can't open port '%s' for read and write", buf); X--- 139,145 ---- X X /* open the device (ignore DCD) */ X sprintf(buf, "/dev/%s", modem->tty[modem->t_cur]); X! if ((fd1 = fd = open(buf, O_RDWR|O_NDELAY)) < 0) { X if (getty_status) X set_getty(modem->tty[modem->t_cur], 1); X sprintf(file, "Can't open port '%s' for read and write", buf); X*************** X*** 145,150 **** X--- 147,171 ---- X } X /* change line settings */ X line_set(); X+ X+ /* This section added by J. Bayer. It allows Pcomm to be X+ ** able to access the modem if the port was originally opened X+ ** with modem control. line_set() removes the modem control, X+ ** but the open file still has it. By re-opening the port X+ ** here, and then closing the old file descriptor, Pcomm X+ ** can access the port correctly X+ */ X+ X+ if ((fd = open(buf, O_RDWR)) < 0) { X+ if (getty_status) X+ set_getty(modem->tty[modem->t_cur], 1); X+ sprintf(file, "Can't open port '%s' for read and write", buf); X+ error_win(1, file, ""); X+ } X+ close(fd1); X+ X+ /* End of addition */ X+ X /* turn off the "no delay" mode */ X fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY); X /* load the modem data base */ X*************** X*** 165,175 **** X tbaud = dir->baud[dir->d_cur]; X dir->baud[dir->d_cur] = modem->init_sp[modem->t_cur]; X line_set(); X! send_str(modem->init[modem->m_cur]); X dir->baud[dir->d_cur] = tbaud; X } X else X! send_str(modem->init[modem->m_cur]); X sleep(1); X return(0); X } X--- 186,206 ---- X tbaud = dir->baud[dir->d_cur]; X dir->baud[dir->d_cur] = modem->init_sp[modem->t_cur]; X line_set(); X! X! /* changed by J. Bayer to be a slow send. See my comments X! ** in dial.c for the reason. X! */ X! X! slow_send_str(modem->init[modem->m_cur]); X dir->baud[dir->d_cur] = tbaud; X } X else X! X! /* changed by J. Bayer to be a slow send. See my comments X! ** in dial.c for the reason. X! */ X! X! slow_send_str(modem->init[modem->m_cur]); X sleep(1); X return(0); X } X END_OF_FILE if test 5281 -ne `wc -c <'patch'`; then echo shar: \"'patch'\" unpacked with wrong size! fi # end of 'patch' fi echo shar: End of shell archive. exit 0