* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
* %sccs.include.proprietary.c%
static char sccsid
[] = "@(#)hys24.c 8.1 (Berkeley) %G%";
* hyspopn24(telno, flds, dev) connect to hayes smartmodem (pulse call)
* hystopn24(telno, flds, dev) connect to hayes smartmodem (tone call)
* return codes: >0 - file number - ok CF_DIAL,CF_DEVICE - failed
hyspopn24(telno
, flds
, dev
)
return hysopn24(telno
, flds
, dev
, 0);
hystopn24(telno
, flds
, dev
)
return hysopn24(telno
, flds
, dev
, 1);
hysopn24(telno
, flds
, dev
, toneflag
)
sprintf(dcname
, "/dev/%s", dev
->D_line
);
DEBUG(4, "dc - %s\n", dcname
);
logent(dcname
, "TIMEOUT");
signal(SIGALRM
, alarmtr
);
dh
= open(dcname
, 2); /* read/write */
for (ii
= telno
; *ii
; ii
++)
fixline(dh
, dev
->D_speed
);
if (dochat(dev
, flds
, dh
)) {
logent(dcname
, "CHAT FAILED");
hyscls24(dh
, 1);/* make sure the line is reset */
write(dh
, "AT&F&D3&C1E0M0X3QV0Y\r", 21);
if (expect("0\r", dh
) != 0) {
logent(dcname
, "HSM not responding OK");
write(dh
, telno
, strlen(telno
));
logent(dcname
, "Modem Hung");
signal(SIGALRM
, alarmtr
);
for (ix
= 0; ix
< 16; ix
++) {
read(dh
, resultbuf
+ ix
, 1);
DEBUG(6, "character read = 0x%X \n", resultbuf
[ix
]);
if ((0x7f & resultbuf
[ix
]) == 0xd)
result
= atol(resultbuf
);
logent("HSM Spurious OK response", _FAILED
);
logent("HSM connected at 300 baud!", _FAILED
);
logent("HSM No Carrier", _FAILED
);
logent("HSM Error", _FAILED
);
logent("HSM No dialtone", _FAILED
);
logent("HSM detected BUSY", _FAILED
);
logent("HSM No quiet answer", _FAILED
);
logent("HSM Unknown response", _FAILED
);
strcpy(devSel
, dev
->D_line
);
} else if (speed
!= dev
->D_speed
) {
DEBUG(4, "changing line speed to %d baud\n", speed
);
logent(dcname
, "CAN'T OPEN");
DEBUG(4, "hayes ok\n", CNULL
);
sprintf(dcname
, "/dev/%s", devSel
);
DEBUG(4, "Resetting fd = %d\n", fd
);
DEBUG(4, "Hanging up fd = %d\n", fd
);
* Since we have a getty sleeping on this line, when it wakes
* up it sends all kinds of garbage to the modem.
* Unfortunatly, the modem likes to execute the previous
* command when it sees the garbage. The previous command
* was to dial the phone, so let's make the last command
write(fd
, "\rATH\rATZ\r", 9);
ioctl(fd
, TIOCFLUSH
, &fff
);