From: Robert L K. <rl...@al...> - 2000-01-25 13:21:13
|
Date: Tue, 25 Jan 2000 07:50:04 -0500 From: Karl Heinz Kremer <kh...@kh...> Cc: gim...@so... Robert L Krawitz <rl...@al...> said: [ ... ] > > I believe it. The way the ESC( commands work, the first byte after > ESC(<char> is a byte count for the rest of the command. Correct me if I'm wrong, but I think the first two bytes are the byte count (low byte and hight byte). So the short version has "1 0" and the new 740 version "5 0", which makes it seven parameters total. You're correct. > What was your source of information for the five parameter version?=20 The document 4clr_99a.pdf on the ercipd site, page 29. > > http://www.ercipd.com/isv/edr_docs.htm In escp2_init_printer your ESC(U command takes only five arguments including the byte count, so I guess what you are saying is that there are only two versions of this command, and the new version should have to more parameters? Right, there are two versions -- the regular and the "extended" version. The new code has both, depending upon the kind of printer: case 720 : if (escp2_has_cap(model, MODEL_VARIABLE_DOT_MASK, MODEL_VARIABLE_4)) fwrite("\033(U\005\000\002\002\001\240\005", 10, 1, prn); else fwrite("\033(U\001\000\005", 6, 1, prn); break; The new command sequence is a lot more logical than the old; I just have to finish the conversion. It wouldn't entirely surprise me if they don't mix very well. PS: Is it necessary that I reply to your mail address and CC the list, or can I just reply to the list? Just me is OK. BTW, here's a perl script that I use to lex Epson print files that I wrote a while back to help me. I'm going to put it in the repository. It doesn't actually translate anything, just analyzes the lexical tokens. #!/usr/bin/perl while (<>) { $stuff .= $_; } %seqtable = ( "@", 0, "(G", "VARIABLE", "(U", "VARIABLE", "U", 1, "(K", 4, "(i", "VARIABLE", "(e", "VARIABLE", "(c", "VARIABLE", "(V", "VARIABLE", "(v", "VARIABLE", "(S", "VARIABLE", "(r", "VARIABLE", "(/", "VARIABLE", "(\$", "VARIABLE", "(D", "VARIABLE", "(R", "VARIABLE", "\\", 2, "\$", 2, "(\\", "VARIABLE", "(C", "VARIABLE", "r", 1, ".", "SPECIAL", "i", "SPECIAL1" ); $esc = "\033"; $skipcount = 0; $curpos = 0; $verbose = 0; sub do_special_command { print "\n"; printf "%08x ", $curpos; print "1b "; for ($i = 1; $i < 8; $i++) { $char = substr($stuff, $i, 1); $nchar = unpack("C", $char); if ($i < 2 && $nchar >= 32 && $nchar < 127) { print " $char "; } else { printf "%02x ", unpack("C", $char); } } $comptype = unpack("C", substr($stuff, 2, 1)); $dots = unpack("v", substr($stuff, 6, 2)); $something = unpack("C", substr($stuff, 5, 1)); print " ($dots, $something) "; $savedots = $dots; $dots *= $something; $curpos += 8; substr($stuff, 0, 8) = ""; if ($comptype == 0) { $bytes = ($dots + 7) / 8; if ($verbose) { for ($k = 0; $k < $bytes; $k++) { $char = substr($stuff, $i, 1); printf "%02x", unpack("C", $char); } } $curpos += $bytes; substr($stuff, 0, $bytes) = ""; } elsif ($comptype == 1) { while ($something > 0) { $dots = $savedots; while ($dots > 0) { $counter = unpack("C", substr($stuff, 0, 1)); $curpos++; substr($stuff, 0, 1) = ""; if ($counter <= 127) { $counter++; if ($verbose) { for ($k = 0; $k < $counter; $k++) { $char = substr($stuff, $i, 1); printf "%02x ", unpack("C", $char); } } $curpos += $counter; substr($stuff, 0, $counter) = ""; $dots -= 8 * $counter; } else { $counter = 257 - $counter; if ($verbose) { for ($k = 0; $k < $counter; $k++) { $char = substr($stuff, 0, 1); printf "%02x ", unpack("C", $char); } } $curpos++; substr($stuff, 0, 1) = ""; $dots -= 8 * $counter; } } $something--; } } else { print "\nUnknown compression type $comptype!\n"; } } sub do_special1_command { print "\n"; printf "%08x ", $curpos; print "1b "; for ($i = 1; $i < 9; $i++) { $char = substr($stuff, $i, 1); $nchar = unpack("C", $char); if ($i < 2 && $nchar >= 32 && $nchar < 127) { print " $char "; } else { printf "%02x ", unpack("C", $char); } } $comptype = unpack("C", substr($stuff, 3, 1)); $bitsperpixel = unpack("C", substr($stuff, 4, 1)); $dots = unpack("v", substr($stuff, 5, 2)); $something = unpack("v", substr($stuff, 7, 2)); print " ($dots, $something, $bitsperpixel) "; $dots *= 8; $savedots = $dots; $dots *= $something; $curpos += 9; substr($stuff, 0, 9) = ""; if ($comptype == 0) { $bytes = ($dots + 7) / 8; if ($verbose) { for ($k = 0; $k < $bytes; $k++) { $char = substr($stuff, $i, 1); printf "%02x", unpack("C", $char); } } $curpos += $bytes; substr($stuff, 0, $bytes) = ""; } elsif ($comptype == 1) { while ($something > 0) { $dots = $savedots; while ($dots > 0) { $counter = unpack("C", substr($stuff, 0, 1)); $curpos++; substr($stuff, 0, 1) = ""; if ($counter <= 127) { $counter++; # printf(" (%d) ", $counter); if ($verbose) { for ($k = 0; $k < $counter; $k++) { $char = substr($stuff, $i, 1); printf "%02x ", unpack("C", $char); } } $curpos += $counter; substr($stuff, 0, $counter) = ""; $dots -= 8 * $counter; } else { $counter = 257 - $counter; # printf(" (%d %d) ", $counter, unpack("C", substr($stuff, 0, 1))); if ($verbose) { $char = substr($stuff, 0, 1); for ($k = 0; $k < $counter; $k++) { printf "%02x ", unpack("C", $char); } } $curpos++; substr($stuff, 0, 1) = ""; $dots -= 8 * $counter; } } $something--; } } else { print "\nUnknown compression type $comptype!\n"; } } while ($stuff ne "") { if (substr($stuff, 0, 1) eq "$esc") { $found = 0; foreach $key (keys %seqtable) { if (substr($stuff, 1, length $key) eq $key) { $skipchars = $seqtable{$key}; if ($skipchars eq "SPECIAL") { do_special_command; $found = 2; } elsif ($skipchars eq "SPECIAL1") { do_special1_command; $found = 2; } else { print "\n"; printf "%08x ", $curpos; print "1b "; $startoff = 0; if ($skipchars eq "VARIABLE") { $lchar = substr($stuff, (length $key) + 1, 1); $nlchar = unpack("C", $lchar); $hchar = substr($stuff, (length $key) + 2, 1); $nhchar = unpack("C", $hchar); $skipchars = ($nhchar * 256) + $nlchar; $startoff = 2; } for ($i = 0; $i < $skipchars + (length $key) + $startoff; $i++) { $char = substr($stuff, $i + 1, 1); $nchar = unpack("C", $char); if ($i < 2 && $nchar >= 32 && $nchar < 127) { print " $char "; } else { printf "%02x ", unpack("C", $char); } } $found = 1; } $bytes = length($key) + 1 + $skipchars + $startoff; last; } } if (! $found) { print "\n"; printf "%08x ", $curpos; print "1b "; substr($stuff, 0, 1) = ""; $curpos += 1; } elsif ($found == 1) { substr($stuff, 0, $bytes) = ""; $curpos += $bytes; } else { } } else { $char = substr($stuff, 0, 1); $nchar = unpack("C", $char); if ($nchar >= 32 && $nchar < 127) { print " *$char "; } else { printf "*%02x ", unpack("C", $char); } $curpos++; substr($stuff, 0, 1) = ""; } } |