canbusload: show RX/TX direction in bargraph
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>pull/556/head
parent
724e6f7c11
commit
fc2473424e
21
canbusload.c
21
canbusload.c
|
|
@ -75,6 +75,7 @@ extern int optind, opterr, optopt;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
char devname[IFNAMSIZ + 1];
|
char devname[IFNAMSIZ + 1];
|
||||||
|
char recv_direction;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
unsigned int bitrate;
|
unsigned int bitrate;
|
||||||
unsigned int dbitrate;
|
unsigned int dbitrate;
|
||||||
|
|
@ -215,7 +216,7 @@ static void printstats(int signo)
|
||||||
|
|
||||||
for (j = 0; j < NUMBAR; j++) {
|
for (j = 0; j < NUMBAR; j++) {
|
||||||
if (j < percent / PERCENTRES)
|
if (j < percent / PERCENTRES)
|
||||||
printf("X");
|
printf("%c", stat[i].recv_direction);
|
||||||
else
|
else
|
||||||
printf(".");
|
printf(".");
|
||||||
}
|
}
|
||||||
|
|
@ -233,6 +234,7 @@ static void printstats(int signo)
|
||||||
stat[i].recv_bits_total = 0;
|
stat[i].recv_bits_total = 0;
|
||||||
stat[i].recv_bits_dbitrate = 0;
|
stat[i].recv_bits_dbitrate = 0;
|
||||||
stat[i].recv_bits_payload = 0;
|
stat[i].recv_bits_payload = 0;
|
||||||
|
stat[i].recv_direction = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!redraw)
|
if (!redraw)
|
||||||
|
|
@ -366,6 +368,8 @@ int main(int argc, char **argv)
|
||||||
if (nbytes > max_bitrate_len)
|
if (nbytes > max_bitrate_len)
|
||||||
max_bitrate_len = nbytes; /* for nice printing */
|
max_bitrate_len = nbytes; /* for nice printing */
|
||||||
|
|
||||||
|
stat[i].recv_direction = '.';
|
||||||
|
|
||||||
/* handling for 'any' device */
|
/* handling for 'any' device */
|
||||||
if (have_anydev == 0 && strcmp(ANYDEV, stat[i].devname) == 0) {
|
if (have_anydev == 0 && strcmp(ANYDEV, stat[i].devname) == 0) {
|
||||||
anydev_bitrate = stat[i].bitrate;
|
anydev_bitrate = stat[i].bitrate;
|
||||||
|
|
@ -462,6 +466,7 @@ int main(int argc, char **argv)
|
||||||
stat[i].ifindex = addr.can_ifindex;
|
stat[i].ifindex = addr.can_ifindex;
|
||||||
stat[i].bitrate = anydev_bitrate;
|
stat[i].bitrate = anydev_bitrate;
|
||||||
stat[i].dbitrate = anydev_dbitrate;
|
stat[i].dbitrate = anydev_dbitrate;
|
||||||
|
stat[i].recv_direction = '.';
|
||||||
if_indextoname(addr.can_ifindex, stat[i].devname);
|
if_indextoname(addr.can_ifindex, stat[i].devname);
|
||||||
nbytes = strlen(stat[i].devname);
|
nbytes = strlen(stat[i].devname);
|
||||||
if (nbytes > max_devname_len)
|
if (nbytes > max_devname_len)
|
||||||
|
|
@ -469,6 +474,20 @@ int main(int argc, char **argv)
|
||||||
currmax++;
|
currmax++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg.msg_flags & MSG_DONTROUTE) {
|
||||||
|
/* TX direction */
|
||||||
|
if (stat[i].recv_direction == '.')
|
||||||
|
stat[i].recv_direction = 'T';
|
||||||
|
else if (stat[i].recv_direction == 'R')
|
||||||
|
stat[i].recv_direction = 'X';
|
||||||
|
} else {
|
||||||
|
/* RX direction */
|
||||||
|
if (stat[i].recv_direction == '.')
|
||||||
|
stat[i].recv_direction = 'R';
|
||||||
|
else if (stat[i].recv_direction == 'T')
|
||||||
|
stat[i].recv_direction = 'X';
|
||||||
|
}
|
||||||
|
|
||||||
stat[i].recv_frames++;
|
stat[i].recv_frames++;
|
||||||
stat[i].recv_bits_payload += frame.len * 8;
|
stat[i].recv_bits_payload += frame.len * 8;
|
||||||
stat[i].recv_bits_dbitrate += can_frame_dbitrate_length(
|
stat[i].recv_bits_dbitrate += can_frame_dbitrate_length(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue