From 8d30ca7e32abdb11405e7e62ec1505df23f28928 Mon Sep 17 00:00:00 2001 From: Armin Schindler Date: Wed, 26 Jan 2000 18:35:05 +0000 Subject: [PATCH] New version of control utility. Added activate-function for isdnlog trace information. --- eicon/README | 8 ++ eicon/aclocal.m4 | 20 +++++ eicon/config.h.in | 3 + eicon/configure | 58 +++++++++++--- eicon/configure.in | 1 + eicon/eiconctrl.c | 168 ++++++++++++++++++++++++++++++++++++++--- eicon/eiconctrl.man.in | 19 +++-- 7 files changed, 250 insertions(+), 27 deletions(-) diff --git a/eicon/README b/eicon/README index c238af7c..d3aea7ed 100644 --- a/eicon/README +++ b/eicon/README @@ -25,6 +25,14 @@ in a specified directory. In addition, this utility provides some trace and debug features. +If you want to use isdnlog with your active Eicon card, the good +news are, you can activate this with the command + + eiconctrl isdnlog on + +(off course, you can deactivate this using "eiconctrl isdnlog off"). +The bad news are, this is only possible with the +DIVA Server BRI card. NOTICE : This package is also part of isdn4k-utils package for isdn4linux diff --git a/eicon/aclocal.m4 b/eicon/aclocal.m4 index 75d0f534..e9ee53ee 100644 --- a/eicon/aclocal.m4 +++ b/eicon/aclocal.m4 @@ -20,6 +20,26 @@ AC_DEFUN(AC_CHECK_XLOG, [ ]) +dnl +dnl Check for TRACE +dnl + +AC_DEFUN(AC_CHECK_TRACE, [ + OLD_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="-nostdinc -I${CONFIG_KERNELDIR} -I/usr/include" + have_trace="no" + AC_MSG_CHECKING([for TRACE in ${CONFIG_KERNELDIR}/drivers/isdn/eicon/eicon.h]) + AC_TRY_COMPILE([#include + #include ],int x = TRACE_OK;,have_trace="yes",) + AC_MSG_RESULT("${have_trace}") + CPPFLAGS="$OLD_CPPFLAGS" + if test "$have_trace" != "no" ; then + AC_DEFINE(HAVE_TRACE) + fi + AC_SUBST(HAVE_TRACE) +]) + + dnl dnl Check for PCI in native driver dnl diff --git a/eicon/config.h.in b/eicon/config.h.in index 64c8f6a7..75d690a3 100644 --- a/eicon/config.h.in +++ b/eicon/config.h.in @@ -1,6 +1,9 @@ /* define if we have XLOG capability */ #undef HAVE_XLOG +/* define if we have TRACE capability */ +#undef HAVE_TRACE + /* define if we have PCI code in native driver */ #undef HAVE_NPCI diff --git a/eicon/configure b/eicon/configure index 2cdd8371..e0d127b0 100755 --- a/eicon/configure +++ b/eicon/configure @@ -1565,15 +1565,48 @@ EOF + OLD_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="-nostdinc -I${CONFIG_KERNELDIR} -I/usr/include" + have_trace="no" + echo $ac_n "checking for TRACE in ${CONFIG_KERNELDIR}/drivers/isdn/eicon/eicon.h""... $ac_c" 1>&6 +echo "configure:1573: checking for TRACE in ${CONFIG_KERNELDIR}/drivers/isdn/eicon/eicon.h" >&5 + cat > conftest.$ac_ext < + #include +int main() { +int x = TRACE_OK; +; return 0; } +EOF +if { (eval echo configure:1583: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + have_trace="yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + echo "$ac_t"""${have_trace}"" 1>&6 + CPPFLAGS="$OLD_CPPFLAGS" + if test "$have_trace" != "no" ; then + cat >> confdefs.h <<\EOF +#define HAVE_TRACE 1 +EOF + + fi + + + if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:1571: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:1604: checking whether ${CC-cc} needs -traditional" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext < Autoconf TIOCGETP @@ -1591,7 +1624,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < Autoconf TCGETA @@ -1616,17 +1649,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1620: checking for $ac_hdr" >&5 +echo "configure:1653: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1630: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1663: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1655,12 +1688,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1659: checking for $ac_func" >&5 +echo "configure:1692: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1720: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1708,7 +1741,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:1712: checking for working mmap" >&5 +echo "configure:1745: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1716,7 +1749,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -2081,6 +2114,7 @@ s%@CPP@%$CPP%g s%@CONFIG_KERNELDIR@%$CONFIG_KERNELDIR%g s%@HAVE_XLOG@%$HAVE_XLOG%g s%@HAVE_NPCI@%$HAVE_NPCI%g +s%@HAVE_TRACE@%$HAVE_TRACE%g s%@INSTALL@%$INSTALL%g s%@MANDATE@%$MANDATE%g s%@CONFIG_EICONCTRL_DEBUG@%$CONFIG_EICONCTRL_DEBUG%g diff --git a/eicon/configure.in b/eicon/configure.in index 844eb649..d0ec4548 100644 --- a/eicon/configure.in +++ b/eicon/configure.in @@ -40,6 +40,7 @@ AC_CHECK_HEADER($CONFIG_KERNELDIR/drivers/isdn/eicon/eicon.h,, dnl Checks for typedefs, structures, and compiler characteristics. AC_CHECK_XLOG AC_CHECK_NPCI +AC_CHECK_TRACE dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL diff --git a/eicon/eiconctrl.c b/eicon/eiconctrl.c index 1093771a..fa4a3d41 100644 --- a/eicon/eiconctrl.c +++ b/eicon/eiconctrl.c @@ -21,6 +21,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log$ + * Revision 1.11 2000/01/24 19:57:37 armin + * Added INSTALL and README file. + * Some updates and new option for configure script. + * * Revision 1.10 2000/01/12 07:05:09 armin * Fixed error on loading old S card. * @@ -146,8 +150,7 @@ char *spid_state[] = }; -#ifdef HAVE_NPCI -#ifdef HAVE_XLOG +#if HAVE_XLOG || HAVE_TRACE /*********** XLOG stuff **********/ #define byte __u8 @@ -1174,7 +1177,6 @@ void spid_event(FILE * stream, struct msg_s * message, word code) /*********** XLOG stuff end **********/ #endif /* XLOG */ -#endif /* NPCI */ void usage() { fprintf(stderr,"usage: %s add (add card)\n",cmd); @@ -1183,7 +1185,10 @@ void usage() { fprintf(stderr," or: %s [-d ] [-v] load [options]\n",cmd); fprintf(stderr," or: %s [-d ] debug []\n",cmd); fprintf(stderr," or: %s [-d ] manage [read|exec ] (management-tool)\n",cmd); -#ifdef HAVE_NPCI +#ifdef HAVE_TRACE + fprintf(stderr," or: %s [-d ] xlog [cont|] (retrieve XLOG)\n",cmd); + fprintf(stderr," or: %s [-d ] isdnlog [on|off] (D-Channel log)\n",cmd); +#else #ifdef HAVE_XLOG fprintf(stderr," or: %s [-d ] xlog [cont] (request XLOG)\n",cmd); #endif @@ -2028,6 +2033,31 @@ void eicon_management(void) goto redraw1; } + if (man_ent[h_line].type == 0x06) { /* Trace Event */ + int tcmd = 0x05; + i = strlen(Man_Path); + if (Man_Path[strlen(Man_Path)-1] != '\\') strcat(Man_Path, "\\"); + strcat(Man_Path, man_ent[h_line].Name); + if (man_ent[h_line].status & 0x02) tcmd = 0x06; + if (get_manage_element(Man_Path, tcmd) < 0) { + clear(); + mvaddstr(0,0, "Error ioctl Management-interface"); + refresh(); + return; + } + sleep(1); + Man_Path[i] = 0; + if (get_manage_element(Man_Path, 0x02) < 0) { + clear(); + mvaddstr(0,0, "Error ioctl Management-interface"); + refresh(); + return; + } + h_line = 0; + stat_y = 0; + goto redraw1; + + } beep2(); goto Keyboard; case 'r': @@ -2123,7 +2153,11 @@ int main(int argc, char **argv) { if (argc > 1) { if (!strcmp(argv[arg_ofs], "-d")) { arg_ofs++; + if (arg_ofs >= argc) + usage(); strcpy(ioctl_s.drvid, argv[arg_ofs++]); + if (arg_ofs >= argc) + usage(); if (!strcmp(argv[arg_ofs], "-v")) { arg_ofs++; verbose = 1; @@ -2138,9 +2172,9 @@ int main(int argc, char **argv) { } else usage(); ac = argc - (arg_ofs - 1); - if (ac < 2) + if (arg_ofs >= argc) usage(); - fd = open("/dev/isdnctrl",O_RDWR); + fd = open("/dev/isdnctrl",O_RDWR | O_NONBLOCK); if (fd < 0) { perror("/dev/isdnctrl"); exit(-1); @@ -2544,9 +2578,84 @@ int main(int argc, char **argv) { return 0; } -#ifdef HAVE_NPCI +#ifdef HAVE_TRACE + if (!strcmp(argv[arg_ofs], "xlog")) { + int dfd = fd; + int cont = 0; + char file[300]; + unsigned char buffer[1000]; + unsigned char inbuffer[1000]; + int pos = 0, ret = 1; + unsigned char byte = 0; + char *p, *q; + unsigned long val, sec; + + if (argc > (++arg_ofs)) { + if (!strcmp(argv[arg_ofs], "cont")) + cont = 1; + else { + strcpy(file, argv[arg_ofs]); + cont = 2; + dfd = open(file, O_RDWR); + if (dfd < 0) { + fprintf(stderr, "File not found.\n"); + exit(-1); + } + } + } + mb = malloc(sizeof(eicon_manifbuf)); + strcpy (Man_Path, "\\Trace\\Log Buffer"); + if (cont < 2) + get_manage_element(Man_Path, 0x05); + while(1) { + memset(buffer, 0, sizeof(buffer)); + memset(inbuffer, 0, sizeof(inbuffer)); + fflush(stdout); + while((byte != 13) && (byte != 10) && (pos < 998) && (ret > 0)) { + if ((ret = read(dfd, &byte, 1)) == 1) { + inbuffer[pos++] = byte; + } + } + byte = 0; + pos = 0; + if ((strlen(inbuffer) > 10) && (strncmp(inbuffer, "XLOG: ", 6) == 0)) { + p = inbuffer + 6; + val = strtol(p, &q, 16); + sec=val/1000; + printf("%5ld:%04ld:%03ld - ", + (long)sec/3600, + (long)sec%3600, + (long)val%1000 ); + p = q; + val = strtol(p, &q, 16); + p = q; + val = strtol(p, &q, 16); + (unsigned short) *buffer = (unsigned short) val; + pos = 2; + while ((p != q) && (*q != 0)) { + p = q; + val = strtol(p, &q, 16); + buffer[pos++] = val; + } + pos = 0; + xlog(stdout, buffer); + } + if ((ret == 0) && (cont == 2)) + break; + if ((ret < 0) && (cont != 1)) + break; + if ((ret < 0) && (cont == 1)) + usleep(10000); + ret = 1; + } + if (cont < 2) + get_manage_element(Man_Path, 0x06); + close(fd); + return 0; + } +#else #ifdef HAVE_XLOG - if (!strcmp(argv[arg_ofs], "xlog")) { + if (!strcmp(argv[arg_ofs], "xlog")) { int cont = 0; int ii; int ret_val; @@ -2666,7 +2775,48 @@ int main(int argc, char **argv) { return 0; } #endif /* XLOG */ -#endif /* NPCI */ +#endif /* TRACE */ + +#ifdef HAVE_TRACE + if (!strcmp(argv[arg_ofs], "isdnlog")) { + int tcmd = 0x05; + int dval = 513; + int ctype = -1; + + if ((ctype = ioctl(fd, EICON_IOCTL_GETTYPE + IIOCDRVCTL, &ioctl_s)) < 1) { + perror("ioctl GETTYPE"); + exit(-1); + } + switch (ctype) { + case EICON_CTYPE_MAESTRAP: + case EICON_CTYPE_MAESTRA: + break; + default: + fprintf(stderr, "Adapter type %d does not supported this.\n", ctype); + exit(-1); + } + mb = malloc(sizeof(eicon_manifbuf)); + + if (argc > (++arg_ofs)) { + if (!strcmp(argv[arg_ofs++], "off")) { + tcmd = 0x06; + dval = 1; + } + } + ioctl_s.arg = dval; + if (ioctl(fd, EICON_IOCTL_DEBUGVAR + IIOCDRVCTL, &ioctl_s) < 0) { + perror("Error changing debug value."); + exit(-1); + } + strcpy (Man_Path, "\\Trace\\Log Buffer"); + if (get_manage_element(Man_Path, tcmd) < 0) { + fprintf(stderr, "Error or already in that state.\n"); + exit(-1); + } + close(fd); + return 0; + } +#endif /* TRACE */ if (!strcmp(argv[arg_ofs], "manage")) { mb = malloc(sizeof(eicon_manifbuf)); diff --git a/eicon/eiconctrl.man.in b/eicon/eiconctrl.man.in index 842e9303..6cde5d2d 100644 --- a/eicon/eiconctrl.man.in +++ b/eicon/eiconctrl.man.in @@ -6,9 +6,9 @@ .\" groff -man -Tascii eiconctrl.1 for ASCII output, or .\" groff -man -Tps eiconctrl.1 for PostScript output .\" -.TH EICONCTRL 8 "@MANDATE@" isdn4k-utils-@I4LVERSION@ "Linux System Administration" +.TH EICONCTRL 8 "@MANDATE@" eiconctrl-V1.1 "Linux System Administration" .SH NAME -eiconctrl \- configure Eicon.Diehl active ISDN adaptor +eiconctrl \- configure Eicon active ISDN adaptor .SH SYNOPSIS .B eiconctrl [-v] [-d .IB Driver-Id ] @@ -16,7 +16,7 @@ eiconctrl \- configure Eicon.Diehl active ISDN adaptor .B ... .SH DESCRIPTION .B eiconctrl -is used to setup the Eicon.Diehl +is used to setup the Eicon .SM ISDN device driver and for downloading the firmware into the .SM ISDN @@ -24,7 +24,7 @@ card. .LP The use of .I eiconctrl -makes sense, if you are using an active Eicon.Diehl ISDN card only. +makes sense, if you are using an active Eicon ISDN card only. .LP .SH OPTIONS .TP @@ -79,6 +79,8 @@ Downloads the protocol- and dsp-code into the card and starts operation. .br .BR 1tr6 " German ISDN Protocol" .br +.BR .... " other protocols are also possible" +.br .RE .LP .RS @@ -108,11 +110,16 @@ Downloads the protocol- and dsp-code into the card and starts operation. .BI "manage " [read | exec " " ] Starts Management-Interface. .TP -.BI "xlog " [cont] +.BI "xlog " [cont | ] Retrieving XLOG entries of adapter. With option .I cont given, it will be on a continuous cycle. +Using a driver release 1.77 or newer you can specify a +trace-file for the xlog interpreter. +.TP +.BI "isdnlog " [on | off] +Switch trace-information for isdnlog on/off. .LP .SH EXAMPLE .TP @@ -125,7 +132,7 @@ loads and starts S2M type adapter with protocol E-DSS1. .SH BUGS No bugs so far. .SH AUTHOR -\(co 1999 by Armin Schindler +\(co 2000 by Armin Schindler .LP .SH SEE ALSO .BR isdnctrl "(8), " isdnctrl "(4), " ttyI "(4), " isdn_cause "(7), " isdninfo (4).