#! /usr/bin/perl use strict; use warnings; my @nibbles = (); while (my $line = <>) { chomp $line; if ($line =~ /^ethernet TX: ([0-9]+)$/) { my $nibble = $1; push (@nibbles, $nibble & 0x0F); } } my @bytes = (); for (my $i = 0; $i < @nibbles; $i += 2) { my $byte = $nibbles[$i + 1] << 4 | $nibbles[$i]; push (@bytes, $byte); } print("unsigned char c_data[] = {\n"); for (my $pos = 0; $pos < @bytes; ) { print(" "); for (my $i = 0; $i < 8 and $i < @bytes; ++$i, ++$pos) { printf(" 0x%02X,", $bytes[$pos]); } print("\n"); } print("};\n");