[dahdi-commits] tzafrir: branch tools/tzafrir/sysfs r8780 - in /tools/team/tzafrir/sysfs: ./ ...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue Jun 15 12:33:03 CDT 2010
Author: tzafrir
Date: Tue Jun 15 12:32:59 2010
New Revision: 8780
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8780
Log:
Merged revisions 8670,8741,8746,8777 via svnmerge from
https://origsvn.digium.com/svn/dahdi/tools/trunk
........
r8670 | seanbright | 2010-05-20 16:10:06 +0300 (ה', 20 מאי 2010) | 1 line
Add dahdi_maint and xpp/twinstar.8 to svn:ignore
........
r8741 | tzafrir | 2010-06-02 20:05:11 +0300 (ד', 02 יונ 2010) | 2 lines
An extra PCI ID for an OpenVox card I ran into.
........
r8746 | dbailey | 2010-06-03 23:56:44 +0300 (ה', 03 יונ 2010) | 4 lines
Add enhanced command line parsing and add more options into how errors are flagged and
what is displayed.
Still runs with the old usage: patlooptest <dahdi device> [<timeout>]
........
r8777 | tzafrir | 2010-06-15 18:44:44 +0300 (ג', 15 יונ 2010) | 9 lines
Convert all '%i' to '%d' in dahdi_cfg
Various values in system.conf were parsed using %i. This means that a
value with a leading 0x was considered hexadecimal and a value with a
leading 0 would be considered octal ('030' == '24' == '0x1E').
This was never documented and seems a potential cause for confusion in
case a leading zero sneaks in. It is thus removed.
........
Modified:
tools/team/tzafrir/sysfs/ (props changed)
tools/team/tzafrir/sysfs/dahdi_cfg.c
tools/team/tzafrir/sysfs/patlooptest.c
tools/team/tzafrir/sysfs/xpp/ (props changed)
tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm
Propchange: tools/team/tzafrir/sysfs/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Jun 15 12:32:59 2010
@@ -10,6 +10,7 @@
configure
dahdi_cfg
dahdi_diag
+dahdi_maint
dahdi_monitor
dahdi_scan
dahdi_speed
Propchange: tools/team/tzafrir/sysfs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun 15 12:32:59 2010
@@ -1,1 +1,2 @@
/tools/branches/2.2:8637
+/tools/trunk:8670-8777
Propchange: tools/team/tzafrir/sysfs/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jun 15 12:32:59 2010
@@ -1,1 +1,1 @@
-/tools/trunk:1-8639
+/tools/trunk:1-8779
Modified: tools/team/tzafrir/sysfs/dahdi_cfg.c
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/dahdi_cfg.c?view=diff&rev=8780&r1=8779&r2=8780
==============================================================================
--- tools/team/tzafrir/sysfs/dahdi_cfg.c (original)
+++ tools/team/tzafrir/sysfs/dahdi_cfg.c Tue Jun 15 12:32:59 2010
@@ -350,7 +350,7 @@
char *tmp;
/* Check legacy (no dial_byname) case */
- if (sscanf(span_string, "%i", &span) == 1) {
+ if (sscanf(span_string, "%d", &span) == 1) {
return span;
}
dahdi_copy_string(tmppath, span_string, sizeof(tmppath));
@@ -444,13 +444,13 @@
error("Span number should be a valid span number, not '%s'\n", realargs[0]);
return -1;
}
- res = sscanf(realargs[1], "%i", &timing);
+ res = sscanf(realargs[1], "%d", &timing);
if ((res != 1) || (timing < 0) || (timing > MAX_TIMING)) {
error("Timing should be a number from 0 to %d, not '%s'\n",
MAX_TIMING, realargs[1]);
return -1;
}
- res = sscanf(realargs[2], "%i", &lc[spans].lbo);
+ res = sscanf(realargs[2], "%d", &lc[spans].lbo);
if (res != 1) {
error("Line build-out (LBO) should be a number from 0 to 7 (usually 0) not '%s'\n", realargs[2]);
return -1;
@@ -592,7 +592,7 @@
error("Syntax error in range '%s'. Should be <val1>-<val2>.\n", args[x]);
return -1;
}
- res2 =sscanf(range[0], "%i", &start);
+ res2 =sscanf(range[0], "%d", &start);
if (res2 != 1) {
error("Syntax error. Start of range '%s' should be a number from 1 to %d\n", args[x], DAHDI_MAX_CHANNELS - 1);
return -1;
@@ -600,7 +600,7 @@
error("Start of range '%s' must be between 1 and %d (not '%d')\n", args[x], DAHDI_MAX_CHANNELS - 1, start);
return -1;
}
- res2 =sscanf(range[1], "%i", &finish);
+ res2 =sscanf(range[1], "%d", &finish);
if (res2 != 1) {
error("Syntax error. End of range '%s' should be a number from 1 to %d\n", args[x], DAHDI_MAX_CHANNELS - 1);
return -1;
@@ -628,7 +628,7 @@
int realchan;
/* It's a single channel */
- res2 =sscanf(args[x], "%i", &chan);
+ res2 =sscanf(args[x], "%d", &chan);
if (res2 != 1) {
error("Syntax error. Channel should be a number from 1 to %d, not '%s'\n", DAHDI_MAX_CHANNELS - 1, args[x]);
return -1;
@@ -676,7 +676,7 @@
static int parse_channel(char *channel, int *startchan)
{
- if (!channel || (sscanf(channel, "%i", startchan) != 1) ||
+ if (!channel || (sscanf(channel, "%d", startchan) != 1) ||
(*startchan < 1)) {
error("DACS requires a starting channel in the form ':x' where x is the channel\n");
return -1;
@@ -987,7 +987,7 @@
error("Invalid rxtone '%s', should be a number > 0.\n", realargs[0]);
return -1;
}
- res = sscanf(realargs[1], "%i", &rxtag);
+ res = sscanf(realargs[1], "%d", &rxtag);
if ((res == 1) && (rxtag < 0))
res = -1;
if (res != 1) {
Modified: tools/team/tzafrir/sysfs/patlooptest.c
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/patlooptest.c?view=diff&rev=8780&r1=8779&r2=8780
==============================================================================
--- tools/team/tzafrir/sysfs/patlooptest.c (original)
+++ tools/team/tzafrir/sysfs/patlooptest.c Tue Jun 15 12:32:59 2010
@@ -23,6 +23,14 @@
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
+ */
+
+/*
+ * This test sends a set of incrementing byte values out the specified
+ * dadhi device. The device is then read back and the read back characters
+ * are verified that they increment as well.
+ * If there is a break in the incrementing pattern, an error is flagged
+ * and the comparison starts at the last value read.
*/
#include <stdio.h>
@@ -38,15 +46,55 @@
#include <dahdi/user.h>
#include "dahdi_tools_version.h"
-#define BLOCK_SIZE 2039
-
-void print_packet(unsigned char *buf, int len)
+#define BLOCK_SIZE 2039
+
+#define CONTEXT_SIZE 7
+/* Prints a set of bytes in hex format */
+static void print_packet(unsigned char *buf, int len)
{
int x;
printf("{ ");
for (x=0;x<len;x++)
printf("%02x ",buf[x]);
printf("}\n");
+}
+
+/* Shows data immediately before and after the specified byte to provide context for an error */
+static void show_error_context(unsigned char *buf, int offset, int bufsize)
+{
+ int low;
+ int total = CONTEXT_SIZE;
+
+ if (offset >= bufsize || 0 >= bufsize || 0 > offset ) {
+ return;
+ }
+
+ low = offset - (CONTEXT_SIZE-1)/2;
+ if (0 > low) {
+ total += low;
+ low = 0;
+ }
+ if (low + total > bufsize) {
+ total = bufsize - low;
+ }
+ buf += low;
+ printf("Offset %d ", low);
+ print_packet(buf, total);
+ return;
+}
+
+/* Shows how the program can be invoked */
+static void usage(const char * progname)
+{
+ printf("%s: Pattern loop test\n", progname);
+ printf("Usage: %s <dahdi device> [-t <secs>] [-r <count>] [-b <count>] [-vh?] \n", progname);
+ printf("\t-? - Print this usage summary\n");
+ printf("\t-t <secs> - # of seconds for the test to run\n");
+ printf("\t-r <count> - # of test loops to run before a summary is printed\n");
+ printf("\t-s <count> - # of writes to skip before testing for results\n");
+ printf("\t-v - Verbosity (repetitive v's add to the verbosity level e.g. -vvvv)\n");
+ printf("\t-b <# buffer bytes> - # of bytes to display from buffers on each pass\n");
+ printf("\n\t Also accepts old style usage:\n\t %s <device name> [<timeout in secs>]\n", progname);
}
int main(int argc, char *argv[])
@@ -61,17 +109,73 @@
unsigned char inbuf[BLOCK_SIZE];
unsigned char outbuf[BLOCK_SIZE];
int setup=0;
- int errors=0;
- int bytes=0;
+ unsigned long bytes=0;
int timeout=0;
- time_t start_time=0;
- if (argc < 2 || argc > 3 ) {
- fprintf(stderr, "Usage: %s <DAHDI device> [timeout]\n",argv[0]);
- exit(1);
- }
- fd = open(argv[1], O_RDWR, 0600);
+ int loop_errorcount;
+ int reportloops = 0;
+ int buff_disp = 0;
+ unsigned long currentloop = 0;
+ unsigned long total_errorcount = 0;
+ int verbose = 0;
+ char * device;
+ int opt;
+ int oldstyle_cmdline = 1;
+
+ /* Parse the command line arguments */
+ while((opt = getopt(argc, argv, "b:s:t:r:v?h")) != -1) {
+ switch(opt) {
+ case 'h':
+ case '?':
+ usage(argv[0]);
+ exit(1);
+ break;
+ case 'b':
+ buff_disp = strtoul(optarg, NULL, 10);
+ if (BLOCK_SIZE < buff_disp) {
+ buff_disp = BLOCK_SIZE;
+ }
+ oldstyle_cmdline = 0;
+ break;
+ case 'r':
+ reportloops = strtoul(optarg, NULL, 10);
+ oldstyle_cmdline = 0;
+ break;
+ case 's':
+ skipcount = strtoul(optarg, NULL, 10);
+ oldstyle_cmdline = 0;
+ break;
+ case 't':
+ timeout = strtoul(optarg, NULL, 10);
+ oldstyle_cmdline = 0;
+ break;
+ case 'v':
+ verbose++;
+ oldstyle_cmdline = 0;
+ break;
+ }
+ }
+
+ /* If no device was specified */
+ if(NULL == argv[optind]) {
+ printf("You need to supply a dahdi device to test\n");
+ usage(argv[0]);
+ exit (1);
+ }
+
+ /* Get the dahdi device name */
+ if (argv[optind])
+ device = argv[optind];
+
+ /* To maintain backward compatibility with previous versions process old style command line */
+ if (oldstyle_cmdline && argc > optind +1) {
+ timeout = strtoul(argv[optind+1], NULL, 10);
+ }
+
+ time_t start_time = 0;
+
+ fd = open(device, O_RDWR, 0600);
if (fd < 0) {
- fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+ fprintf(stderr, "Unable to open %s: %s\n", device, strerror(errno));
exit(1);
}
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &bs)) {
@@ -85,63 +189,106 @@
ioctl(fd, DAHDI_GETEVENT);
i = DAHDI_FLUSH_ALL;
- if (ioctl(fd,DAHDI_FLUSH,&i) == -1)
- {
+ if (ioctl(fd,DAHDI_FLUSH,&i) == -1) {
perror("DAHDI_FLUSH");
exit(255);
- }
- if(argc==3){
- timeout=atoi(argv[2]);
- start_time=time(NULL);
+ }
+
+ /* Mark time if program has a specified timeout */
+ if(0 < timeout){
+ start_time = time(NULL);
printf("Using Timeout of %d Seconds\n",timeout);
}
+ /* ********* MAIN TESTING LOOP ************ */
for(;;) {
+ /* Prep the data and write it out to dahdi device */
res = bs;
- for (x=0;x<bs;x++)
+ for (x = 0; x < bs; x++) {
outbuf[x] = c1++;
+ }
res = write(fd,outbuf,bs);
- if (res != bs)
- {
+ if (res != bs) {
printf("Res is %d: %s\n", res, strerror(errno));
ioctl(fd, DAHDI_GETEVENT, &x);
printf("Event: %d\n", x);
exit(1);
}
- if (skipcount)
- {
- if (skipcount > 1) read(fd,inbuf,bs);
+ /* If this is the start of the test then skip a number of packets before test results */
+ if (skipcount) {
+ if (skipcount > 1) {
+ res = read(fd,inbuf,bs);
+ }
skipcount--;
- if (!skipcount) puts("Going for it...");
+ if (!skipcount) {
+ printf("Going for it...\n");
+ }
continue;
- }
+ }
res = read(fd, inbuf, bs);
if (res < bs) {
- printf("Res is %d\n", res);
+ printf("read error: returned %d\n", res);
exit(1);
}
+ /* If first time through, set byte that is used to test further bytes */
if (!setup) {
c = inbuf[0];
setup++;
}
- for (x=0;x<bs;x++) {
+ /* Test the packet read back for data pattern */
+ loop_errorcount = 0;
+ for (x = 0; x < bs; x++) {
+ /* if error */
if (inbuf[x] != c) {
- printf("(Error %d): Unexpected result, %d != %d, %d bytes since last error.\n", ++errors, inbuf[x],c, bytes);
+ total_errorcount++;
+ loop_errorcount++;
+ if (oldstyle_cmdline) {
+ printf("(Error %ld): Unexpected result, %d != %d, %ld bytes since last error.\n", total_errorcount, inbuf[x],c, bytes);
+ } else {
+ if (1 <= verbose) {
+ printf("Error %ld (loop %ld, offset %d, error %d): Unexpected result, Read: 0x%02x, Expected 0x%02x.\n",
+ total_errorcount,
+ currentloop,
+ x,
+ loop_errorcount,
+ inbuf[x],
+ c);
+ }
+ if (2 <= verbose) {
+ show_error_context(inbuf, x, bs);
+ }
+ }
+ /* Reset the expected data to what was just read. so test can resynch on skipped data */
c = inbuf[x];
- bytes=0;
+ bytes=0; /* Reset the count from the last encountered error */
}
c++;
bytes++;
+ }
+ /* If the user wants to see some of each buffer transaction */
+ if (0 < buff_disp) {
+ printf("Buffer Display %d (errors =%d)\nIN: ", buff_disp, loop_errorcount);
+ print_packet(inbuf, 64);
+ printf("OUT:");
+ print_packet(outbuf, 64);
+ }
+
+ currentloop++;
+ /* Update stats if the user has specified it */
+ if (0 < reportloops && 0 == (currentloop % reportloops)) {
+ printf("Status on loop %lu: Total errors = %lu\n", currentloop, total_errorcount);
+
}
#if 0
printf("(%d) Wrote %d bytes\n", packets++, res);
#endif
- if(timeout && (time(NULL)-start_time)>timeout){
+ if(timeout && (time(NULL)-start_time) > timeout){
printf("Timeout achieved Ending Program\n");
- return errors;
+ printf("Test ran %ld loops of %d bytes/loop with %ld errors\n", currentloop, bs, total_errorcount);
+ return total_errorcount;
}
}
Propchange: tools/team/tzafrir/sysfs/xpp/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Jun 15 12:32:59 2010
@@ -21,3 +21,4 @@
dahdi_pools.8
lsdahdi.8
*.8.html
+twinstar.8
Modified: tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm?view=diff&rev=8780&r1=8779&r2=8780
==============================================================================
--- tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm (original)
+++ tools/team/tzafrir/sysfs/xpp/perl_modules/Dahdi/Hardware/PCI.pm Tue Jun 15 12:32:59 2010
@@ -149,6 +149,8 @@
# Yeastar (from output of modinfo):
'e159:0001/2151' => { DRIVER => 'ystdm8xx', DESCRIPTION => 'Yeastar YSTDM8xx'},
+
+ 'e159:0001/9500:0003' => { DRIVER => 'opvxa1200', DESCRIPTION => 'OpenVox A800P' },
);
$ENV{PATH} .= ":/usr/sbin:/sbin:/usr/bin:/bin";
More information about the dahdi-commits
mailing list