Stefan Schuermans commited on 2012-03-21 21:42:02
Showing 1 changed files, with 31 additions and 0 deletions.
... | ... |
@@ -0,0 +1,31 @@ |
1 |
+#! /usr/bin/perl |
|
2 |
+ |
|
3 |
+use strict; |
|
4 |
+use warnings; |
|
5 |
+ |
|
6 |
+my @nibbles = (); |
|
7 |
+while (my $line = <>) { |
|
8 |
+ chomp $line; |
|
9 |
+ |
|
10 |
+ if ($line =~ /^ethernet TX: ([0-9]+)$/) { |
|
11 |
+ my $nibble = $1; |
|
12 |
+ push (@nibbles, $nibble & 0x0F); |
|
13 |
+ } |
|
14 |
+} |
|
15 |
+ |
|
16 |
+my @bytes = (); |
|
17 |
+for (my $i = 0; $i < @nibbles; $i += 2) { |
|
18 |
+ my $byte = $nibbles[$i + 1] << 4 | $nibbles[$i]; |
|
19 |
+ push (@bytes, $byte); |
|
20 |
+} |
|
21 |
+ |
|
22 |
+print("unsigned char c_data[] = {\n"); |
|
23 |
+for (my $pos = 0; $pos < @bytes; ) { |
|
24 |
+ print(" "); |
|
25 |
+ for (my $i = 0; $i < 8 and $i < @bytes; ++$i, ++$pos) { |
|
26 |
+ printf(" 0x%02X,", $bytes[$pos]); |
|
27 |
+ } |
|
28 |
+ print("\n"); |
|
29 |
+} |
|
30 |
+print("};\n"); |
|
31 |
+ |
|
0 | 32 |