summaryrefslogtreecommitdiff
path: root/hdlcstress.c
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-04-02 15:01:23 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-04-02 15:01:23 +0000
commit8c29f87f0fe6465a171644f1d916481d0d2def4f (patch)
treee8bed76b71f1403ac98910d49f06adc9446ed3f2 /hdlcstress.c
parentd05dcdd0b516e1200cd1b5e0be94a40099ae3020 (diff)
hdlcstress.c: add option -b not to stress BRI too much
Aparantly the HFC chip can't stand the heat of this test. Let's give it an occasional rest. Also add getopts support. git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@6292 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'hdlcstress.c')
-rw-r--r--hdlcstress.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/hdlcstress.c b/hdlcstress.c
index becc3d9..6704f1f 100644
--- a/hdlcstress.c
+++ b/hdlcstress.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <fcntl.h>
+#include <getopt.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
@@ -49,6 +50,7 @@
#define BLOCK_SIZE 2041
static int hdlcmode = 0;
+static int bri_delay = 0;
static unsigned short fcstab[256] =
@@ -144,19 +146,27 @@ void send_packet(unsigned char *buf, int len)
int main(int argc, char *argv[])
{
- int res, x;
+ int res, ch, x;
struct dahdi_params tp;
struct dahdi_bufferinfo bi;
int bs = BLOCK_SIZE;
unsigned char c=0;
unsigned char outbuf[BLOCK_SIZE];
- if (argc < 2) {
- fprintf(stderr, "Usage: %s <DAHDI device>\n", argv[0]);
+
+ while((ch = getopt(argc, argv, "b")) != -1) {
+ switch(ch) {
+ case 'b': bri_delay = 300000; break;
+ case '?': exit(1);
+ }
+ }
+
+ if (argc - optind != 1) {
+ fprintf(stderr, "Usage: %s [-b] <DAHDI device>\n", argv[0]);
exit(1);
}
- fd = open(argv[1], O_RDWR, 0600);
+ fd = open(argv[optind], 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", argv[optind], strerror(errno));
exit(1);
}
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &bs)) {
@@ -209,6 +219,11 @@ int main(int argc, char *argv[])
#if 0
printf("Wrote %d of %d bytes\n", res, c);
#endif
+ /* The HFC chip can't be bombarded too much. If a write has
+ failed, let it recover */
+ if (bri_delay)
+ usleep(bri_delay);
+
c = bit_next(c);
#if 0
printf("(%d) Wrote %d bytes\n", packets++, res);