cansniffer: fix colorization when notching relevant bits
When notching marked (and colored) bits with the interactive '#' command the binary output omits colored bits - as intended. But when switching back to the hex and ASCII output the bytes with notched bits remained uncolored even when some bits inside the hex bytes would have needed to be colored. The check for the colored output was a logical AND operation which is fine for the binary representation but needed to be a bit-wise operation in the hex/ASCII byte mode case. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>pull/201/head
parent
eb639c1b3d
commit
bceadb8696
|
|
@ -646,7 +646,7 @@ void print_snifline(int id){
|
||||||
else {
|
else {
|
||||||
|
|
||||||
for (i=0; i<sniftab[id].current.can_dlc; i++)
|
for (i=0; i<sniftab[id].current.can_dlc; i++)
|
||||||
if ((color) && (sniftab[id].marker.data[i]) && (!(sniftab[id].notch.data[i])))
|
if ((color) && (sniftab[id].marker.data[i] & ~sniftab[id].notch.data[i]))
|
||||||
printf("%s%02X%s ", ATTCOLOR, sniftab[id].current.data[i], ATTRESET);
|
printf("%s%02X%s ", ATTCOLOR, sniftab[id].current.data[i], ATTRESET);
|
||||||
else
|
else
|
||||||
printf("%02X ", sniftab[id].current.data[i]);
|
printf("%02X ", sniftab[id].current.data[i]);
|
||||||
|
|
@ -657,7 +657,7 @@ void print_snifline(int id){
|
||||||
for (i=0; i<sniftab[id].current.can_dlc; i++)
|
for (i=0; i<sniftab[id].current.can_dlc; i++)
|
||||||
if ((sniftab[id].current.data[i] > 0x1F) &&
|
if ((sniftab[id].current.data[i] > 0x1F) &&
|
||||||
(sniftab[id].current.data[i] < 0x7F))
|
(sniftab[id].current.data[i] < 0x7F))
|
||||||
if ((color) && (sniftab[id].marker.data[i]) && (!(sniftab[id].notch.data[i])))
|
if ((color) && (sniftab[id].marker.data[i] & ~sniftab[id].notch.data[i]))
|
||||||
printf("%s%c%s", ATTCOLOR, sniftab[id].current.data[i], ATTRESET);
|
printf("%s%c%s", ATTCOLOR, sniftab[id].current.data[i], ATTRESET);
|
||||||
else
|
else
|
||||||
putchar(sniftab[id].current.data[i]);
|
putchar(sniftab[id].current.data[i]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue