Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 206795
b: refs/heads/master
c: ddbfe74
h: refs/heads/master
i:
  206793: 2e21e19
  206791: e2f8fcf
v: v3
  • Loading branch information
Stefan Richter committed Jul 27, 2010
1 parent 0b35fcf commit 0035df7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 57 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 83ef7c75939f45f8da46976cdca4db0727276a2d
refs/heads/master: ddbfe74958ec21c3d58d5a46dd6f4048bc7969a4
105 changes: 49 additions & 56 deletions trunk/tools/firewire/nosy-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,11 +903,12 @@ set_input_mode(void)

int main(int argc, const char *argv[])
{
uint32_t buf[128 * 1024];
uint32_t filter;
int length, retval, view;
int fd = -1;
FILE *output = NULL, *input = NULL;
poptContext con;
int retval;
int view;
char c;
struct pollfd pollfds[2];

Expand Down Expand Up @@ -961,70 +962,62 @@ int main(int argc, const char *argv[])

setvbuf(stdout, NULL, _IOLBF, BUFSIZ);

if (1) {
uint32_t buf[128 * 1024];
uint32_t filter;
int length;
filter = ~0;
if (!option_iso)
filter &= ~(1 << TCODE_STREAM_DATA);
if (!option_cycle_start)
filter &= ~(1 << TCODE_CYCLE_START);
if (view == VIEW_STATS)
filter = ~(1 << TCODE_CYCLE_START);

filter = ~0;
if (!option_iso)
filter &= ~(1 << TCODE_STREAM_DATA);
if (!option_cycle_start)
filter &= ~(1 << TCODE_CYCLE_START);
if (view == VIEW_STATS)
filter = ~(1 << TCODE_CYCLE_START);
ioctl(fd, NOSY_IOC_FILTER, filter);

ioctl(fd, NOSY_IOC_FILTER, filter);
ioctl(fd, NOSY_IOC_START);

ioctl(fd, NOSY_IOC_START);
pollfds[0].fd = fd;
pollfds[0].events = POLLIN;
pollfds[1].fd = STDIN_FILENO;
pollfds[1].events = POLLIN;

pollfds[0].fd = fd;
pollfds[0].events = POLLIN;
pollfds[1].fd = STDIN_FILENO;
pollfds[1].events = POLLIN;

while (run) {
if (input != NULL) {
if (fread(&length, sizeof length, 1, input) != 1)
while (run) {
if (input != NULL) {
if (fread(&length, sizeof length, 1, input) != 1)
return 0;
fread(buf, 1, length, input);
} else {
poll(pollfds, 2, -1);
if (pollfds[1].revents) {
read(STDIN_FILENO, &c, sizeof c);
switch (c) {
case 'q':
if (output != NULL)
fclose(output);
return 0;
fread(buf, 1, length, input);
} else {
poll(pollfds, 2, -1);
if (pollfds[1].revents) {
read(STDIN_FILENO, &c, sizeof c);
switch (c) {
case 'q':
if (output != NULL)
fclose(output);
return 0;
}
}

if (pollfds[0].revents)
length = read(fd, buf, sizeof buf);
else
continue;
}

if (output != NULL) {
fwrite(&length, sizeof length, 1, output);
fwrite(buf, 1, length, output);
}
if (pollfds[0].revents)
length = read(fd, buf, sizeof buf);
else
continue;
}

switch (view) {
case VIEW_TRANSACTION:
handle_packet(buf, length);
break;
case VIEW_PACKET:
print_packet(buf, length);
break;
case VIEW_STATS:
print_stats(buf, length);
break;
}
if (output != NULL) {
fwrite(&length, sizeof length, 1, output);
fwrite(buf, 1, length, output);
}

switch (view) {
case VIEW_TRANSACTION:
handle_packet(buf, length);
break;
case VIEW_PACKET:
print_packet(buf, length);
break;
case VIEW_STATS:
print_stats(buf, length);
break;
}
} else {
poptPrintUsage(con, stdout, 0);
}

if (output != NULL)
Expand Down

0 comments on commit 0035df7

Please sign in to comment.