[ Previous Article | Book Contents | Library Home | Legal | Search ]
AIX Versions 3.2 and 4 Asynchronous Communications Guide

Appendix L: 7318 Buddy Mode Application Program Interface (API)

The following information describes the API for buddy mode. Included is a short explanation of how to show or change buddy mode settings, using the cnsview command.

#include <stropts.h>
#include <cs_term.h>
 
main()
{
struct strioctl strioctl;
long controls = 0;
int fid = 0;     /* use stdin for ioctl */                         
strioctl.ic_cmd = CS_TIOCMGET;
strioctl.ic_timout = 5;         /* timeout value unimportant */
strioctl.ic_dp = (char *)&controls;
strioctl.ic_len = sizeof(controls);
if (ioctl(fid, I_STR, &strioctl) < 0) {
 perror("modem");
 exit(1);
}
printf("modem controls=0x%lx\n", controls);
exit(0);
}
                                                                             

The CS_TIOCMGET IOCTL fetches the current state of 7318 modem controls, including the extended controls that are only valid when the port is in buddy mode. The CS_TIOCMSET IOCTL sets the current state of 7318 serial port modem controls. Only output bits can be set. Changes to the input controls are ignored.

The available modem controls are:

CS_TIOCM_DTR             Data terminal ready (output)
CS_TIOCM_RTS             Request to send (output)
CS_TIOCM_CTS             Clear to send (input)
CS_TIOCM_CD              Carrier Detected (input)
CS_TIOCM_RI              Ring Indicator (input, buddy mode)
CS_TIOCM_DSR             Data Set Ready (input, buddy mode)
CS_TIOCM_ALOOP           Analog Loopback (output, buddy mode)
CS_TIOCM_DLOOP           Digital Loopback (output, buddy mode)

When a port is not in buddy mode, CS_TIOCM_RI is always 0 and CS_TIOCM_DSR is always 1.

Note: These ioctls are only available to 7318s running the direct connect protocols (Model P10s and S20s with direct attach enabled).

The cnsview command also has a way to read and set the buddy mode controls. You can set and show the extmodem property on 7318 serial ports in buddy mode. This property reports an error if the port is not in buddy mode. For example:

cnsview /dev/tty2
>>show extmodem
dsr:    1
ri:     0
aloop:  0
dloop:  0
 
>>set extmodem aloop
 
>>show extmodem
dsr:    1
ri:     0
aloop:  1
dloop:  0

[ Previous Article | Book Contents | Library Home | Legal | Search ]