From c1fcb4135e77fac4ff4d8904ab380caae3ba8811 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Thu, 29 Dec 2011 22:33:48 +0100 Subject: [PATCH] Simple tool to convert commandline parameste data to 32bit frame data. --- tools/param2HexFrame.pl | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tools/param2HexFrame.pl diff --git a/tools/param2HexFrame.pl b/tools/param2HexFrame.pl new file mode 100644 index 0000000..3efbf1a --- /dev/null +++ b/tools/param2HexFrame.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl -w + +use strict; + +for (my $i=0; $i<=$#ARGV; $i++) +{ + print "Frame $i = "; + my @list = split(",", $ARGV[$i]); + + my $frame = 0; + my $first = 1; + my $ebene = 0; + my $bit = 0; + if ($#list >= 0 && $#list <= 9) + { + my $ele = 0; + foreach my $ele (@list) + { + if ($first == 1) + { + $ebene = ($ele - 1) * 9; + $first = 2; + + } elsif ($first == 2) { + $first = 0; + if ($ele < 32) + { + $frame |= $ele << 27; + } + } else { + if ($ele < 10) + { + $bit = $ebene + $ele-1; + $frame |= (1 << $bit); + } + } + } + printf("0x%08x = ", $frame); + printf("0b%032b\n", $frame); + } +} +