# USB with padded Linux header (LINKTYPE_USB_LINUX_MMAPPED)
# This is the one produced by Beagleboard sniffer GSOC.
+# Debug levels:
+# 1 - frame request and frame response
+# 2 - parsed frames
+# 4 - raw data
my $debug = 0;
-GetOptions('debug' => \$debug);
+GetOptions('debug=i' => \$debug);
# Frame format as parsed by libpcap 1.0.0 and 1.1.1. Not sure if format
# changed on different versions.
print "\n";
- if ($debug) {
+ if ($debug & 1) {
my ($key, $value);
print "\tREQ: $key => $value\n" while (($key, $value) = each(%req));
print "\tRESP: $key => $value\n" while (($key, $value) = each(%resp));
sub process_frame($) {
my %frame = %{ @_[0] };
- if ($debug > 1) {
+ if ($debug & 2) {
my ($key, $value);
+ print "PARSED data:\n";
print "\t\tRAW: $key => $value\n" while (($key, $value) = each(%frame));
print "\n";
}
my $strdata = $log->data($index);
my @data=unpack('C*', $strdata);
- if ($debug > 2) {
+ if ($debug & 4) {
+ print "RAW DATA: ";
for (my $i = 0; $i < scalar(@data); $i++) {
printf " %02x", $data[$i];
}
$frame{"Payload"} = $payload;
$frame{"PayloadSize"} = $payload_size;
- if ($debug > 1) {
- my ($key, $value);
- print "\t$key => $value\n" while (($key, $value) = each(%frame));
- printf "\n";
- }
process_frame(\%frame);
}
}