Device-LaCrosse-WS23xx
view release on metacpan or search on metacpan
memory_map_2300.PL view on Meta::CPAN
}
$previous_address = $address;
# Anything in plain parentheses, at the end, is a comment:
# 0266 4 | LCD contrast: $BCD+1 (Read Only: ....)
# strip it off.
$line =~ s/\s*\([^\(]+\)$//;
# Is it a definition line?
if ($line =~ m!^\|\s+([^ 0-9].*?)\s*:\s*(.*)!) {
my ($desc, $formula) = ($1, $2);
push @map, {
desc => $desc,
name => _canonical_name($desc),
address => $address,
length => 1,
};
# FIXME: formula
$formula =~ s{<(\S+)>}{
my $key = $1;
defined $macro{$key}
or die "$mapfile:$.: Undefined macro <$key>";
$macro{$key};
}ge;
if ($formula =~ s/\s*\[(.*)\]\s*//) {
$map[-1]->{units} = $1;
}
$map[-1]->{formula} = $formula;
}
elsif ($line =~ m!^_/!) {
my $l = $address - $map[-1]->{address} + 1;
if ($l > 10) {
die "$mapfile:$.: preposterous length";
}
$map[-1]->{length} = $l;
}
}
elsif ($line =~ /^\s*macro \s+ (\S+) \s+ = \s+ (\S.*\S)/x) {
memory_map_2300.PL view on Meta::CPAN
my $_memory_map = <<'END_MEMORY_MAP';
END_MMAP_HEADER
for my $entry (@map) {
my $name = $entry->{name};
if (my $units = $entry->{units}) {
$name .= " [$units]";
}
printf { $mmap_fh } "%04X:%-2d %-40s %s\n", @{$entry}{"address","length"},
$name, $entry->{formula};
}
print { $mmap_fh } <<'END_MMAP_REST';
END_MEMORY_MAP
my $Canonical = <<'END_CANONICAL';
Max Maximum | Maximal
Min Minimum | Minimal
Indoor Indoors | Inside | In
t/10fakedata.t view on Meta::CPAN
while (my $line = <$map_fh>) {
chomp $line;
$line =~ s/\s+$//; # Remove trailing whitespace
# E.g. 0019 0 alarm set flags
if ($line =~ s!^([0-9a-f]{4})\s+([0-9a-f])\s*!!i) {
$fakedata[hex($1)] = hex($2);
if ($line =~ m!^\|\s+([^ 0-9].*?)\s*:\s*(.*)!) {
my ($desc, $formula) = ($1, $2);
if ($formula =~ /\(=(.*)\)$/) {
push @sample_data, [ $desc, $1 ];
}
}
}
}
close $map_fh;
# Create some hardcoded tests. This requires knowledge of
# the sample data values in the memory map file. These
# tests aren't completely duplicates of the above. These
( run in 0.252 second using v1.01-cache-2.11-cpan-26ccb49234f )