2.0.35 i4l ATset patch

Johnny Tevessen (j.tevessen@gmx.de)
Wed, 11 Nov 1998 08:41:47 +0100


--wac7ysb48OaltWcw
Content-Type: text/plain; charset=us-ascii

Hi!

This patch adds to the i4l ttyI interface:

o Fix error handling in "ATIsomething<CR>"
o Ability to redial the last number by "ATDL<CR>"
o Ability to redo the last command by "A/"

which I've seen in the Hayes AT command set since my 14k4 days and which
I think are both very handy.

ciao,
johnny

-- 
Trust noone.

--wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="2.0.35-i4lat-patch"

--- linux/include/linux/isdn.h.old Sun Jun 7 15:29:02 1998 +++ linux/include/linux/isdn.h Sun Jun 7 16:38:41 1998 @@ -536,6 +536,8 @@ int pluscount; /* Counter for +++ sequence */ int lastplus; /* Timestamp of last + */ char mdmcmd[255]; /* Modem-Commandbuffer */ + char mdmcmdlast[255]; /* Last command got */ + char lastdialed[40]; /* Last number used to dialout */ } atemu; /* Private data (similar to async_struct in <linux/serial.h>) */ --- linux/drivers/isdn/isdn_tty.c.old Sun Jun 7 15:28:48 1998 +++ linux/drivers/isdn/isdn_tty.c Tue Jun 9 12:19:24 1998 @@ -2445,10 +2445,29 @@ * Get phone-number from modem-commandbuffer */ static void -isdn_tty_getdial(char *p, char *q, int max) +isdn_tty_getdial(char *p, char *q, int max, modem_info *info) { - int first = 1; - + int first; + if (*p == 'L') { + if ('\0' == info->emu.lastdialed[0]) { + *q = '\0'; + } else { + strncpy(q, info->emu.lastdialed, max-1); + q[max-1] = '\0'; + /* Spill out the number */ + if (info->emu.mdmreg[12] & 4) { + /* "\r\n12345" */ + char eb[3]; + eb[0] = info->emu.mdmreg[3]; + eb[1] = info->emu.mdmreg[4]; + eb[2] = '\0'; + isdn_tty_at_cout(eb, info); + isdn_tty_at_cout(q, info); + } + } + return; + } + first = 1; max--; while (strchr("0123456789,#.*WPTS-", *p) && *p && (max > 0)) { if ((*p >= '0' && *p <= '9') || ((*p == 'S') && first)) { @@ -3072,6 +3091,8 @@ } #endif /* CONFIG_ISDN_AUDIO */ +#define ISDIGIT(ch) ((ch >= '0') && (ch <= '9')) + /* * Parse and perform an AT-command-line. */ @@ -3095,13 +3116,15 @@ break; case 'D': /* D - Dial */ - isdn_tty_getdial(++p, ds, sizeof(ds)); + isdn_tty_getdial(++p, ds, sizeof(ds), info); p += strlen(p); if (!strlen(m->msn)) isdn_tty_modem_result(10, info); - else if (strlen(ds)) + else if (strlen(ds)) { + strncpy(info->emu.lastdialed, ds, sizeof (info->emu.lastdialed) - 1); + info->emu.lastdialed[sizeof (info->emu.lastdialed) - 1] = '\0'; isdn_tty_dial(ds, info, m); - else + } else PARSE_ERROR; return; case 'E': @@ -3135,11 +3158,26 @@ break; } break; - case 'I': + case 'I': { /* I - Information */ - p++; - isdn_tty_at_cout("\r\nLinux ISDN", info); - switch (*p) { + char id0; + id0 = *++p; + if (!ISDIGIT(id0)) { + id0 = '0'; + } else if (ISDIGIT((u_char)p[1])) { + /* ATI with number >9 */ + p++; + do { + p++; + } while (ISDIGIT((u_char)*p)); + PARSE_ERROR; + break; + } + /* "ATI1" != "ATI12" */ + /* To avoid "Linux ISDN//ERROR" */ + if ((id0 >= '0') && (id0 <= '2')) + isdn_tty_at_cout("\r\nLinux ISDN", info); + switch (id0) { case '0': case '1': p++; @@ -3149,6 +3187,9 @@ isdn_tty_report(info); break; default: + PARSE_ERROR; + break; + } } break; case 'O': @@ -3272,8 +3313,11 @@ eb[1] = 0; isdn_tty_at_cout(eb, info); } - if (m->mdmcmdl >= 2) + if (m->mdmcmdl >= 2) { + /* includes "A/" */ + strcpy(m->mdmcmdlast, m->mdmcmd); isdn_tty_parse_at(info); + } m->mdmcmdl = 0; continue; } @@ -3303,6 +3347,27 @@ case 1: if (c == 'T') m->mdmcmd[m->mdmcmdl++] = c; + else if (c == '/') { + /* "A/": Repeat last command */ + if ('\0' == m->mdmcmdlast[0]) { + /* Simply ignore */ + } else { + if (m->mdmreg[12] & 4) { + /* "/\rLASTCMD" */ + eb[0] = c; + eb[1] = 0; + isdn_tty_at_cout(eb, info); + eb[0] = m->mdmreg[3]; + isdn_tty_at_cout(eb, info); + isdn_tty_at_cout(m->mdmcmdlast, info); + } + m->mdmcmdl = strlen(m->mdmcmdlast); + strcpy(m->mdmcmd, m->mdmcmdlast); + isdn_tty_parse_at(info); + m->mdmcmdl = 0; + continue; + } + } break; default: m->mdmcmd[m->mdmcmdl++] = c;

--wac7ysb48OaltWcw--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/