use strict; my $HEAD = '0000 006D 0000 0022'; my $R_LIN = '00AF 00AF'; my $R_LOUT = '0016 05E7'; my $R_0 = '0016 0015'; my $R_1 = '0016 0040'; my $R_TMPL = 'D,D,F,-F'; my $DEVID = 7; my @FID = (0..255); foreach my $fid (@FID) { print "Dev: $DEVID, Func: $fid\n"; print $HEAD, "\n"; print $R_LIN, "\n"; foreach my $type (split(/,/, $R_TMPL)) { my $bit; if($type eq 'D') { $bit = unpack('b*', pack('C', $DEVID)); } if($type eq 'd') { $bit = unpack('B*', pack('C', $DEVID)); } if($type eq '-D') { $bit = unpack('b*', pack('C', 0xff - $DEVID)); } if($type eq '-d') { $bit = unpack('B*', pack('C', 0xff - $DEVID)); } if($type eq 'F') { $bit = unpack('b*', pack('C', $fid)); } if($type eq 'f') { $bit = unpack('B*', pack('C', $fid)); } if($type eq '-F') { $bit = unpack('b*', pack('C', 0xff - $fid)); } if($type eq '-f') { $bit = unpack('B*', pack('C', 0xff - $fid)); } $bit =~ s/([01])/($1 ? $R_1 : $R_0) . ' '/eg; $bit =~ s/ +$//; print $bit; print "\n"; } print $R_LOUT, "\n"; print "\n"; }