3 # Simulate EVOLIS Dualys printer
8 use Data::Dump qw(dump);
23 s/\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0// && warn "FIXME: string 15 null bytes";
25 die "no escape at beginning",dump($_) unless s/^\x1B//;
27 my @a = split(/;/,$_);
31 my $f = $a[0] || die 'missing feeder';
32 print "feeder $f | $feeder->{$f}\n";
34 } elsif ( $c eq 'Pc' ) {
37 my $temperature = $a[2];
38 print "temperature $color = $temperature\n";
39 } elsif ( $c eq 'Pr' ) {
40 print "improve $a[0]\n";
41 # FIXME windows sends it, cups doesn't
42 } elsif ( $c eq 'Db' ) { # XXX not in cups
43 my ( $color, $two, $data ) = @a;
44 $two eq '2' or die '2';
45 my $path = "page-Db-$color-$page.pbm";
47 save_pbm $path, 648, 1015, $data; # FIXME 1016?
48 } elsif ( $c eq 'Dbc' ) { # XXX not in cups
49 my ( $color, $line, $len, $data ) = @a;
50 while ( $len > length($data) ) {
51 warn "# slurp more ",length($data), " < $len\n";
54 $len == length $data or warn "wrong length $len != ", length $data;
56 my $path = "page-Dbc-$color-$page.pbm";
59 my ( $w, $h ) = ( 646, 1081 ); # from driver
60 # ( $w, $h ) = ( 636, 994 ); # from test card
61 $h = int( length($data) * 8 / $w );
62 save_pbm $path, $w, $h, $data;
65 warn "UNKNOWN: $c ", dump(@a);
70 my ( $path, $w, $h, $data ) = @_;
71 open(my $pbm, '>', $path);
72 print $pbm "P4\n$w $h\n", $data;
74 print "saved $path $w * $h size ", -s $path, "\n";