BlinkenArea - GitList
Repositories
Blog
Wiki
mips_sys
Code
Commits
Branches
Tags
Search
Tree:
6e87eaa
Branches
Tags
master
mips_sys
stuff
eth_tx_log_2_c_data.pl
script to convert testbed log to C data array
Stefan Schuermans
commited
6e87eaa
at 2012-03-21 21:42:02
eth_tx_log_2_c_data.pl
Blame
History
Raw
#! /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");