source: projects/perl-tools/alter-udo-parser @ 27

Last change on this file since 27 was 1, checked in by sven, 16 years ago

Erstimport

File size: 885 bytes
Line 
1#!/usr/bin/perl
2#
3# Usage: udo-parser.pl [DATEINAME]
4#   liest von Textdatei oder stdin eine Datei in Udos favorisiertem Format,
5#   nach dem Zeilen etwa so aussehen:
6#   "[hexadezimal] # [dezimal]"
7#   Pro Zeile ein Byte.
8#   Gibt auf STDOUT den Bytestrom aus.
9#
10#   Geschrieben 30.03.2008 21:00
11#
12
13my $handler = STDIN;
14open($handler, '<', $ARGV[0]) if(@ARGV > 0);
15
16my $line=0;
17my $hex,$dec;
18while(<$handler>) {
19    $line++;
20    unless(/([0-9a-fA-F]{2})\s*#\s*([0-9]{1,3})/) {
21        print STDERR "Zeile $line: Formatfehler! Überspringe Zeile $line...\n";
22        next;
23    }
24
25    $hex=$1; $dec=$2;
26    if(hex $hex ne $dec) {
27        print STDERR "Zeile $line: Hex($hex)/Dez($dec)-Angabe stimmen nicht überein (hex entspricht ",hex $hex,").\n";
28        print STDERR "Zeile $line: Nutze Dezimal-Angabe fuer Streifen\n";
29    }
30
31    print pack("C", $dec);
32    # ja das wars schon ;)
33}
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License