The following section contains information necessary to attach and configure a modem to the native ports, 8-, 64-, and 128-port adapters on AIX.
Topics covered in this section include:
Use the System Management Interface Tool (SMIT) to define a tty port for the device attachment. Most fields are for the general device type. The only field that can affect the modem is the Enable LOGIN field with the following values:
Fields specific to the 128-port asynchronous adapter:
Force Carrier or Ignore Carrier Detect | disable |
Perform Cooked Processing in Adapter | disable |
(AIX Version 3 only) | |
Use Alternate RJ-45 Pinouts* | disable |
Note: * This setting is set to disabled if the 10 pin RJ-45 connector is used. This setting should be enabled if the 8 pin RJ-45 connector is used.
The next step is to physically attach the modem to the serial adapter port using appropriate cabling. If possible, avoid placing the modem and cabling near any high line-noise sources such as florescent lighting, light switches, or uninterruptable power supply (UPS) devices. Sudden, or continuous power fluctuations can cause problems with tty ports (see troubleshooting section for more information).
Most modems require customization of their default settings in order to function properly on the system unit. The commands and settings discussed in this section configure a Hayes compatible modem with the basic parameters needed for operation on the server's serial ports.
There are two methods of configuration commonly used. They are:
The cu command is the interactive and convenient way to program a modem on the server. This command is in the /usr/bin directory and is a part of bosext1.uucp.obj licensed program product.
Direct tty# - Any direct Direct tty43 - Any direct
Note: Any lines in this file that start with a # (pound sign) in the leftmost position are comments only.
AT
The modem should respond with OK. If it does not respond to your command, refer to troubleshooting.
Not having the modem reset also protects changes when &C1 is set, because changing the Carrier Detect status may cause the carrier detect line to toggle on some modems, causing the cu command to drop the line. You may wish to set the modem to &D3 after the final setup is made.
AT&F <enter> ATE1 <enter> AT&D2 <enter> AT&C1 <enter> ATS0=1 <enter> ATS9=12 <enter> AT&W <enter> ~. <enter> (terminate connection)AT Command Descriptions
penable ttyn pshare ttyn pdelay ttyn pdisable ttynThe modem is now configured with the basic commands needed for most AIX serial communication needs.
/*************************************************************/ /* Motalk - A "C" program for modem setup. */ /* */ /* NOTE: This program is supplied as an example only and */ /* is not officially supported by IBM. */ /* */ /* */ /* To create: vi motalk.c <enter> */ /* Usage: motalk /dev/tty? [speed] */ /* */ */*************************************************************/ #include <errno.h> #include <stdio.h> #include <signal.h> #include <fcntl.h> #include <termio.h> FILE *fdr, *fdw; int fd; struct termio term_save, stdin_save; void Exit(int sig) { if (fdr) fclose(fdr); if (fdw) fclose(fdw); ioctl(fd, TCSETA, &term_save); close(fd); ioctl(fileno(stdin), TCSETA, &stdin_save); exit(sig); } main(int argc, char *argv[]) { char *b, buffer[80]; int baud = 0, num; struct termio term, tstdin; if (argc < 2 || !strcmp(argv[1], "-?")) { fprintf(stderr, "Usage: motalk /dev/tty? [speed]\n"); exit(1); } if ((fd = open(argv[1], O_RDWR|O_NDELAY)) < 0 ) { perror(argv[1]); exit(errno); } if (argc > 2) { switch(atoi(argv[2])) { case 300: baud = B300; break; case 1200: baud = B1200; break; case 2400: baud = B2400; break; case 4800: baud = B4800; break; case 9600: baud = B9600; break; case 19200: baud = B19200; break; case 38400: baud = B38400; break; default: baud = 0; fprintf(stderr, "%s: %s is an unsupported baud\n", argv[0], argv[2]); exit(1); } } /* Save stdin and tty state and trap some signals */ ioctl(fd, TCGETA, &term_save); ioctl(fileno(stdin), TCGETA, &stdin_save); signal(SIGHUP, Exit); signal(SIGINT, Exit); signal(SIGQUIT, Exit); signal(SIGTERM, Exit); /* Set stdin to raw mode, no echo */ ioctl(fileno(stdin), TCGETA, &tstdin); tstdin.c_iflag = 0; tstdin.c_lflag &= ~(ICANNON | ECHO); tstdin.c_cc[VMIN] = 0; tstdin.c_cc[VTIME] = 0; ioctl(fileno(stdin), TCSETA, &tstdin); /* Set tty state */ ioctl(fd, TCGETA, &term); term.c_cflag |= CLOCAL|HUPCL; if (baud > 0) { term.c_cflag &= ~CBAUD; term.c_cflag |= baud; } term.c_lflag &= ~ECHO; term.c_cc[VMIN] = 0; term.c_cc[VTIME] = 10; ioctl(fd, TCSETA, &term); fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY); /* Open tty for read and write */ if ((fdr = fopen(argv[1], "r")) == NULL ) { perror(argv[1]); exit(errno); } if ((fdw = fopen(argv[1], "w")) == NULL ) { perror(argv[1]); exit(errno); } /* Talk to the modem */ puts("Ready... Press <ctrl> C to exit"); while (1) { if ((num = read(fileno(stdin), buffer, 80)) > 0) write(fileno(fdw), buffer, num); if ((num = read(fileno(fdr), buffer, 80)) > 0) write(fileno(stdout), buffer, num); } Exit(0); } /* ********************************************************* */ /* ******************** END OF PROGRAM ********************* */ /* ********************************************************* */
cc -o motalk motalk.c
motalk /dev/ttyn #
Where n is the number of the tty port and # is the speed of the tty port. For example, to set port 43 for 9600 bps, the syntax would be:
motalk /dev/tty43 9600
To program a modem automatically with a shell script, use the UUCP cu command. Create and run the following script:
#!/bin/ksh tty=$1 shift speed=$1 shift { while [ -n "$1" ];do echo "$1/r" sleep 2 shift done echo '~.' {| cu -ml $tty -s $speed