summaryrefslogtreecommitdiff
path: root/doc/developer/escp2.xml
blob: 91d90cdce744b04ec50397531569e0fbd4e9e387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
<chapter>
  <title>ESC/P2</title>
  <para>
    This is a description of the ESC/P2 raster commands used by the
    Gutenprint printer driver, which is a subset of the complete
    command set.  Note that these are <emphasis>not</emphasis> always
    correct, and are certainly not complete.
  </para>
  <para>
    All ESCP/2 raster commands begin with the <literal>ESC</literal>
    character (0x1b), followed by either one or two command characters
    and arguments where applicable.  Older commands generally have one
    command character.  Newer commands usually have a
    &lsquo;<literal>(</literal>&rsquo; (left parenthesis) followed by
    a command character and a byte count for the arguments that
    follow.  The byte count is a 16-bit (2 byte) binary integer, in
    little endian order.
  </para>
  <para>
    All arguments listed here are of the form
    <literal>name[bytes]</literal> where <literal>[bytes]</literal> is
    the number of bytes that comprise the argument.  The arguments
    themselves are usually one, two, or four byte integers, always
    little endian (the least significant bits come first).  Presumably
    this is to match Intel processors.
  </para>
  <para>
    In some cases, the same command sequence identifies different
    versions of the same command, depending upon the number of bytes
    of arguments.
  </para>
  <sect1>
    <title>Standard commands</title>
    <variablelist>
      <title>ESC/P2 Commands</title>
      <varlistentry>
        <term><literal>ESC @</literal></term>
        <listitem>
          <para>
            Reset the printer.  Discards any output, ejects the
            existing page, returns all settings to their default.
            Always use this before printing a page.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (G <varname>BC</varname>=1
            <varname>ON1</varname></literal></term>
        <listitem>
          <para>
            Turn on graphics mode.  <varname>ON</varname> should be
            <constant>1</constant> (turn on graphics mode).
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (U <varname>BC</varname>=1
            <varname>UNIT1</varname></literal></term>
        <listitem>
          <para>
            Set basic unit of measurement used by printer.  This is
            expressed in multiples of 1/3600".  At 720 DPI,
            <varname>UNIT</varname> is <constant>5</constant>; at
            360 DPI, <varname>UNIT</varname> is
            <constant>10</constant>.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (U <varname>BC</varname>=5
            <varname>PAGEUNITS1</varname> <varname>VUNIT1</varname>
            <varname>HUNIT1</varname>
            <varname>BASEUNIT2</varname></literal></term>
        <listitem>
          <para>
            Set basic units of measurement used by the printer.
            <varname>PAGEUNIT</varname> is the unit of page
            measurement (for commands that set page dimensions and
            the like).  <varname>VUNIT</varname> is the unit of
            vertical measurement (for vertical movement commands).
            <varname>HUNIT</varname> is the unit of horizontal
            movement (for horizontal positioning commands).  All of
            these units are expressed in
            <varname>BASEUNIT</varname>, which is in reciprocal
            inches.  Typically, <varname>BASEUNIT</varname> is
            <constant>1440</constant>.  In 720 DPI mode,
            <varname>PAGEUNIT</varname>, <varname>VUNIT</varname>,
            and <varname>HUNIT</varname> are all
            <constant>2</constant>; in 1440&times;720 DPI mode,
            <varname>PAGEUNIT</varname> and <varname>VUNIT</varname>
            are normally set to <constant>2</constant>;
            <varname>HUNIT</varname> is set to
            <constant>1</constant>.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (K <varname>BC</varname>=2
            <varname>ZERO1</varname>
            <varname>GRAYMODE1</varname></literal></term>
        <listitem>
          <para>
            Set color or grayscale mode, on printers supporting an
            explicit grayscale mode.  These printers can be
            identified because they are advertised as having more
            black nozzles than nozzles of individual colors.
            Setting grayscale mode allows use of these extra nozzles
            for faster printing.  <varname>GRAYMODE</varname> should
            be <constant>0</constant> or <constant>2</constant> for
            color, <constant>1</constant> for grayscale.
            <varname>ZERO</varname> should always be
            <constant>0</constant>.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (i <varname>BC</varname>=1
            <varname>INTERLEAVE1</varname></literal></term>
        <listitem>
          <para>
            If <varname>INTERLEAVE</varname> is
            <constant>1</constant>, use printer interleave mode
            (referred to by Epson as "MicroWeave".  On older printers,
            this is used to turn on printer interleave; on newer
            printers, it prints one row at a time.  All printers
            support this mode.  It should only be used at 720 (or
            1440&times;720) DPI.  The Epson Stylus Pro series
            indicates additional modes (with additional optionss on
            newer ones):
          </para>
          <variablelist>
            <varlistentry>
              <term><constant>2</constant></term>
              <listitem>
                <para>
                  &ldquo;Full-overlap&rdquo;
                </para>
              </listitem>
            </varlistentry>
            <varlistentry>
              <term><constant>3</constant></term>
              <listitem>
                <para>
                  &ldquo;Four-pass&rdquo;
                </para>
              </listitem>
            </varlistentry>
            <varlistentry>
              <term><constant>4</constant></term>
              <listitem>
                <para>
                  &ldquo;Full-overlap 2&rdquo;
                </para>
              </listitem>
            </varlistentry>
          </variablelist>
          <para>
            Any of these commands can be used with the high four
            bits set to either <constant>3</constant> or
            <constant>0</constant>.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC U
            <varname>DIRECTION1</varname></literal></term>
        <listitem>
          <para>
            If <varname>DIRECTION</varname> is
            <constant>1</constant>, print unidirectionally; if
            <constant>0</constant>, print bidirectionally.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (s <varname>BC</varname>=1
            <varname>SPEED1</varname></literal></term>
        <listitem>
          <para>
            On some older printers, this controls the print head
            speed.  <varname>SPEED</varname> of
            <constant>2</constant> is 10 inches/sec;
            <varname>SPEED</varname> of <constant>0</constant> or 1
            is 20.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (e <varname>BC</varname>=2
            <varname>ZERO1</varname>
            <varname>DOTSIZE1</varname></literal></term>
        <listitem>
          <para>
            Choose print dotsize.  <varname>DOTSIZE</varname> can
            take on various values, depending upon the printer.
            Almost all printers support <constant>0</constant> and
            <constant>2</constant>.  Variable dot size printers
            allow a value of <varname>16</varname>.  Other than the
            value of <varname>16</varname>, this appears to be
            ignored at resolutions of 720 DPI and above.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (C <varname>BC</varname>=2
            <varname>PAGELENGTH2</varname></literal></term>
        <term><literal>ESC (C <varname>BC</varname>=4
            <varname>PAGELENGTH4</varname></literal></term>
        <listitem>
          <para>
            Set the length of the page in &ldquo;pageunits&rdquo;
            (see <literal>ESC (U</literal> above).  The second form
            of the command allows setting of longer page lengths on
            new printers (these happen to be the printers that
            support variable dot size).
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (c <varname>BC</varname>=4
            <varname>TOP2</varname>
            <varname>LENGTH2</varname></literal></term>
        <term><literal>ESC (c <varname>BC</varname>=8
            <varname>TOP4</varname>
            <varname>LENGTH4</varname></literal></term>
        <listitem>
          <para>
            Set the vertical page margins of the page in
            &ldquo;pageunits&rdquo; (see <literal>ESC (U</literal>
            above).  The margins are specified as the top of the
            page and the length of the page.  The second form of the
            command allows setting of longer page lengths on new
            printers (these happen to be the printers that support
            variable dot size).
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (S <varname>BC</varname>=8
            <varname>WIDTH4</varname>
            <varname>LENGTH4</varname></literal></term>
        <listitem>
          <para>
            Set the width and length of the printed page region in
            &ldquo;pageunits&rdquo; (see <literal>ESC (U</literal>
            above).
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (v <varname>BC</varname>=2
            <varname>ADVANCE2</varname></literal></term>
        <term><literal>ESC (v <varname>BC</varname>=4
            <varname>ADVANCE4</varname></literal></term>
        <listitem>
          <para>
            Feed vertically <varname>ADVANCE</varname>
            &ldquo;vertical units&rdquo; (see <literal>ESC
            (U</literal> above) from the current print head
            position.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (V <varname>BC</varname>=2
            <varname>ADVANCE2</varname></literal></term>
        <term><literal>ESC (V <varname>BC</varname>=4
            <varname>ADVANCE4</varname></literal></term>
        <listitem>
          <para>
            Feed vertically <varname>ADVANCE</varname>
            &ldquo;vertical units&rdquo; (see <literal>ESC
            (U</literal> above) from the top margin.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC ($ <varname>BC</varname>=4
            <varname>OFFSET4</varname></literal></term>
        <listitem>
          <para>
            Set horizontal position to <varname>OFFSET</varname>
            from the left margin.  This command operates on printers
            of the 740 class and newer (all printers with variable
            dot size).
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC $
            <varname>OFFSET2</varname></literal></term>
        <listitem>
          <para>
            Set horizontal position to <varname>OFFSET</varname>
            from the left margin.  This command operates on printers
            of the 740 class and newer (all printers with variable
            dot size).
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (\ <varname>BC</varname>=4
            <varname>UNITS2</varname>
            <varname>OFFSET2</varname></literal></term>
        <listitem>
          <para>
            Set horizontal position to <varname>OFFSET</varname>
            from the previous print head position, measured in
            <varname>UNITS</varname>.  <varname>UNITS</varname> is
            measured in inverse inches, and should be set to 1440 in
            all cases.  This operates on all 1440 dpi printers that
            do not support variable dot size.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (/ <varname>BC</varname>=4
            <varname>OFFSET4</varname></literal></term>
        <listitem>
          <para>
            Set horizontal position to <varname>OFFSET</varname>
            from the previous print head position, measured in
            &ldquo;horizontal units&rdquo; (see <literal>ESC
            (U</literal> above).  This operates on all variable dot
            size printers.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC \
            <varname>OFFSET2</varname></literal></term>
        <listitem>
          <para>
            Set horizontal position to <varname>OFFSET</varname>
            from the previous print head position, measured in basic
            unit of measurement (see <literal>ESC (U</literal>
            above). This is used on all 720 dpi printers, and can
            also be used on 1440 dpi printers in lower resolutions
            to save a few bytes.  Note that
            <varname>OFFSET</varname> may be negative.  The range of
            values for this command is between
            <constant>-16384</constant> and
            <constant>16383</constant>.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC r
            <varname>COLOR1</varname></literal></term>
        <term><literal>ESC (r <varname>BC</varname>=2
            <varname>DENSITY1</varname>
            <varname>COLOR1</varname></literal></term>
        <listitem>
          <para>
            Set the ink color.  The first form is used on four-color
            printers; the second on six-color printers.
            <varname>DENSITY</varname> is <constant>0</constant> for
            dark inks, <constant>1</constant> for light.
            <varname>COLOR</varname> is
          </para>
          <table>
            <title>Colors</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="id"/>
              <colspec colnum="2" colname="color"/>
              <thead>
                <row>
                  <entry><varname>COLOR</varname></entry>
                  <entry>Color name</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>0</constant></entry>
                  <entry>Black</entry>
                </row>
                <row>
                  <entry><constant>1</constant></entry>
                  <entry>Magenta</entry>
                </row>
                <row>
                  <entry><constant>2</constant></entry>
                  <entry>Cyan</entry>
                </row>
                <row>
                  <entry><constant>4</constant></entry>
                  <entry>Yellow</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            This command is not used on variable dot size printers
            in softweave mode.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC . <varname>COMPRESS1</varname>
            <varname>VSEP1</varname> <varname>HSEP1</varname>
            <varname>LINES1</varname> <varname>WIDTH2</varname>
            data...</literal></term>
        <listitem>
          <para>
            Print data.  <varname>COMPRESS</varname> signifies the
            compression mode.
          </para>
          <table>
            <title>Compression modes</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="id"/>
              <colspec colnum="2" colname="compression"/>
              <thead>
                <row>
                  <entry><varname>COMPRESS</varname></entry>
                  <entry>Compression mode</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>0</constant></entry>
                  <entry>No compression</entry>
                </row>
                <row>
                  <entry><constant>1</constant></entry>
                  <entry>
                    TIFF compression (incorrectly documented as
                    &ldquo;run length encoded&rdquo;)
                  </entry>
                </row>
                <row>
                  <entry><constant>2</constant></entry>
                  <entry>
                    TIFF compression with a special command set.
                  </entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            <varname>VSEP</varname> depends upon resolution and
            printer type.  At 360 DPI, it is always
            <constant>10</constant>.  At 720 DPI, it is normally
            <constant>5</constant>5.  On the ESC 600, it is
            <constant>40</constant> (8 &times; 5}).  On some other
            printers, it varies.
          </para>
          <para>
            <varname>HSEP1</varname> is <constant>10</constant> at
            360 DPI and <constant>5</constant> at 720 or 1440 DPI
            (1440 DPI cannot be printed in one pass; it is printed
            in two passes, with the dots separated in each pass by
            1/720").
          </para>
          <para>
            <varname>LINES</varname> is the number of lines to be
            printed.  It should be <constant>1</constant> in printer
            interleave and 360 DPI.  At 720 DPI softweave, it should
            be the number of lines to be actually printed.
          </para>
          <para>
            <varname>WIDTH</varname> is the number of pixels to be
            printed in each row.  Following this command, a carriage
            return (<constant>13</constant> decimal,
            <literal>0A</literal> hex) should be output to return
            the print head position to the left margin.
          </para>
          <para>
            The basic data format is a string of bytes, with data
            from left to right on the page.  Within each byte, the
            highest bit is first.
          </para>
          <para>
            The TIFF compression is implemented as one count byte
            followed by one or more data bytes.  There are two
            cases:
          </para>
          <orderedlist>
            <listitem>
              <para>
                If the count byte is <constant>128</constant> or
                less, it is followed by ([count] + 1) data bytes.
                So if the count byte is <constant>0</constant>, it
                is followed by 1 data byte; if it is
                <constant>128</constant>, it is followed by 129 data
                bytes.
              </para>
            </listitem>
            <listitem>
              <para>
                If the count byte is greater than 128, it is
                followed by one byte.  This byte is repeated (257 -
                [count]) times.  So if [count] is 129, the next byte
                is treated as though it were repeated 128 times; if
                [count] is 255, it is treated as though it were
                repeated twice.
              </para>
            </listitem>
          </orderedlist>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC i <varname>COLOR1</varname>
            <varname>COMPRESS1</varname> <varname>BITS1</varname>
            <varname>BYTES2</varname> <varname>LINES2</varname>
            data...</literal></term>
        <listitem>
          <para>
            Print data in the newer printers (that support variable
            dot size), and Stylus Pro models.
            <varname>COLOR</varname> is the color.
          </para>
          <table>
            <title>Extended Colors</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="id"/>
              <colspec colnum="2" colname="color"/>
              <thead>
                <row>
                  <entry><varname>COLOR</varname></entry>
                  <entry>Color name</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>0</constant></entry>
                  <entry>Black</entry>
                </row>
                <row>
                  <entry><constant>1</constant></entry>
                  <entry>Magenta</entry>
                </row>
                <row>
                  <entry><constant>2</constant></entry>
                  <entry>Cyan</entry>
                </row>
                <row>
                  <entry><constant>4</constant></entry>
                  <entry>Yellow</entry>
                </row>
                <row>
                  <entry><constant>5</constant></entry>
                  <entry>Alternate black (Stylus C70/C80)</entry>
                </row>
                <row>
                  <entry><constant>6</constant></entry>
                  <entry>Alternate black (Stylus C70/C80)</entry>
                </row>
                <row>
                  <entry><constant>16</constant></entry>
                  <entry>Gray (&ldquo;light black&rdquo;)</entry>
                </row>
                <row>
                  <entry><constant>17</constant></entry>
                  <entry>Light magenta</entry>
                </row>
                <row>
                  <entry><constant>18</constant></entry>
                  <entry>Light cyan</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            <varname>COMPRESS</varname> signifies the compression
            mode:
          </para>
          <table>
            <title>Compression modes</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="id"/>
              <colspec colnum="2" colname="compression"/>
              <thead>
                <row>
                  <entry><varname>COMPRESS</varname></entry>
                  <entry>Compression mode</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>0</constant></entry>
                  <entry>No compression</entry>
                </row>
                <row>
                  <entry><constant>1</constant></entry>
                  <entry>
                    TIFF compression (incorrectly documented as
                    &ldquo;run length encoded&rdquo;)
                  </entry>
                </row>
                <row>
                  <entry><constant>2</constant></entry>
                  <entry>
                    TIFF compression with a special command set, or
                    &ldquo;run length encoding 2&rdquo; on some
                    printers.
                  </entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            <varname>BITS</varname> is the number of bits per pixel.
          </para>
          <para>
            <varname>BYTES</varname> is the number of bytes wide for
            each row (ceiling(BITS &times; width_of_row, 8)}). Note
            that this is different from the <literal>ESC .</literal>
            command above.
          </para>
          <para>
            <varname>LINES</varname> is the number of lines to be
            printed.  This command is the only way to get variable
            dot size printing.  In variable dot mode, the size of
            the dots increases as the value (<constant>1</constant>,
            <constant>2</constant>, or <constant>3</constant>)
            increases.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (D <varname>BC</varname>=4
            <varname>BASE2</varname> <varname>VERTICAL1</varname>
            <varname>HORIZONTAL1</varname></literal></term>
        <listitem>
          <para>
            Set printer horizontal and vertical spacing.  It only
            applies to variable dot size printers in softweave mode
            (and possibly other high end printers).
          </para>
          <para>
            <varname>BASE</varname> is the base unit for this
            command; it must be <constant>14400</constant>.
          </para>
          <para>
            <varname>VERTICAL</varname> is the distance in these
            units between printed rows; it should be
            ((separation_in_nozzles &times; <varname>BASE</varname>
            &divide; 720).
          </para>
          <para>
            <varname>HORIZONTAL</varname> is the horizontal
            separation between dots in a row.  Depending upon the
            printer, this should be either (14400 &divide; 720) or
            (14400 &divide; 360).  The Stylus Pro 9000 manual
            suggests that the settings should match the chosen
            resolution, but that is apparently not the case (or not
            always the case) on other printers.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC (R <varname>BC</varname>=8 00 R E M O T E
            1</literal></term>
        <listitem>
          <para>
            Enters &ldquo;remote mode&rdquo;.  This is a special,
            undocumented command set that is used to set up various
            printer options, such as paper feed tray, and perform
            utility functions such as head cleaning and alignment.
            It does not appear that anything here is actually
            required to make the printer print.  Our best
            understanding of what is in a remote command sequence is
            described in a separate section below.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>ESC 01 @EJL [sp] ID\r\n</literal></term>
        <listitem>
          <para>
            Return the printer ID.  This is considered a remote mode
            command, although the syntax is that of a conventional
            command.  This returns the following information:
          </para>
          <informalexample>
            <screen>@EJL ID\r
MFG:EPSON;
CMD:ESCPL2,BDC;
MDL:[printer model];
CLS:PRINTER;
DES:EPSON [printer model];
\f</screen>
          </informalexample>
          <para>
            After all data has been sent, a form feed byte should be
            sent.
          </para>
        </listitem>
      </varlistentry>
  </variablelist>
  <para>
     All newer Epson printers (STC 440, STP 750) require the
     following command to be sent at least once to enable printing
     at all.  This command specifically takes the printer out of the
     1284.4 packet mode communication protocol and enables normal
     data transfer.  Sending it multiple times is is not harmful, so
     it is normally sent at the beginning of each job:
  </para>
  <informalexample>
    <screen>ESC 01@EJL[space]1284.4[newline]@EJL[space][space][space][space]
[space][newline]ESC@</screen>
  </informalexample>
  <para>
    The proper sequence of initialization commands is:
  </para>
  <informalexample>
    <screen>magic command
ESC @
remote mode if needed
ESC (G
ESC (U
ESC (K (if appropriate)
ESC (i
ESC U (if needed)
ESC (s (if appropriate)
ESC (e
ESC (C
ESC (c
ESC (S
ESC (D (if needed)
ESC (V (optional -- this can be accomplished with ESC (v)</screen>
  </informalexample>
  <para>
    For printing, the proper sequence is:
  </para>
  <informalexample>
    <screen>ESC (v</screen>
  </informalexample>
  <para>
    and repeat for each color:
  </para>
  <!-- This needs better formatting... -->
  <informalexample>
    <screen>ESC ($ or ESC (\ or ESC \
ESC (r or ESC r (if needed---not used with "ESC i" and not needed if the color
has not changed from the previous printed line)
ESC . or ESC i  ...data... [return] (0A hex)</screen>
  </informalexample>
  <para>
    To terminate a page:
  </para>
  <informalexample>
    <screen>[formfeed] (0C hex)
ESC @</screen>
  </informalexample>
</sect1>
<sect1>
  <title>Remote Mode Commands</title>
  <para>
    The following description of remote commands comes out of an
    examination of the sequences used by the printer utilities
    bundled with the Windows drivers for the ESC740, and from other
    sources (some Epson manuals, experimentation, analysis of print
    files).  It is largely speculative as these commands are not all
    documented in the Epson documentation we have access to.
    Generally, newer manuals provide more thorough documentation.
  </para>
  <para>
    Remote command mode is entered when the printer is sent the
    following sequence:
  </para>
  <informalexample>
    <screen>ESC (R BC=8 00 R E M O T E 1</screen>
  </informalexample>
  <para>
    Remote mode commands are then sent, and terminated with the
    following sequence:
  </para>
  <informalexample>
    <screen>ESC 00 00 00</screen>
  </informalexample>
  <para>
    All remote mode commands must be sent before the initial
    <literal>ESC (G</literal> command is sent.
  </para>
  <para>
    This introductory sequence is then followed by a sequence of
    commands.  Each command is constructed as follows:
  </para>
  <orderedlist>
    <listitem>
      <para>
        Two ASCII bytes indicating the function
      </para>
    </listitem>
    <listitem>
      <para>
        A byte count (two bytes, little-endian) for the parameters
      </para>
    </listitem>
    <listitem>
      <para>
        Binary parameters, if any
      </para>
    </listitem>
  </orderedlist>
  <para>
      This is a list of all remote commands we have seen:
  </para>
  <variablelist>
    <title>ESC/P2 Remote Mode Commands</title>
    <varlistentry>
      <term><literal>NC <varname>BC</varname>=2 00
          00</literal></term>
      <listitem>
        <para>
          Print a nozzle check pattern.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>VI <varname>BC</varname>=2 00
          00</literal></term>
      <listitem>
        <para>
          On my 740, prints the following, probably &ldquo;version
          information&rdquo;:
        </para>
        <informalexample>
          <screen>W01286 I02382\r\n</screen>
        </informalexample>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* AI <varname>BC</varname>=3 00 00 00</literal></term>
      <listitem>
        <para>
          Prints a &ldquo;printer ID&rdquo;.  On one 870, prints the
          following:
        </para>
        <informalexample>
          <screen>51-51-50-51-49-48\r\n</screen>
        </informalexample>
        <para>
          The Windows driver has a text entry field where this
          number can be entered, but its purpose is unknown.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* LD <varname>BC</varname>=0</literal></term>
      <listitem>
        <para>
          Load printer defaults from NVRAM, DIP switches, and/or
          ROM. This apparently does not load factory defaults per
          se, but any settings that are saved.  This is commonly
          used right at the end of each print job after the
          <literal>ESC @</literal> printer reset command.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* CH <varname>BC</varname>=2 00
          <varname>xx</varname></literal></term>
      <listitem>
        <para>
          Perform a head cleaning cycle.  The heads to clean are
          determined by parameter <varname>xx</varname>:
      </para>
        <table>
          <title>Head cleaning parameters</title>
          <tgroup cols="2" align="left">
            <colspec colnum="1" colname="id"/>
            <colspec colnum="2" colname="description"/>
            <thead>
              <row>
                <entry><varname>xx</varname></entry>
                <entry>Description</entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry><constant>00</constant></entry>
                <entry>Clean all heads</entry>
              </row>
              <row>
                <entry><constant>01</constant></entry>
                <entry>Clean black head</entry>
              </row>
              <row>
                <entry><constant>02</constant></entry>
                <entry>Clean color heads</entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>
          While <varname>xx</varname> = <constant>00</constant> is
          likely supported by all printers, <varname>xx</varname>
          = <constant>01</constant> and <constant>02</constant>
          are not.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* DT <varname>BC</varname>=3 00
          <varname>xx</varname> 00</literal></term>
      <listitem>
        <para>
          Print an alignment pattern.  There are three patterns,
          which are picked via the choice of
          <varname>xx</varname>.  Pattern <constant>0</constant>
          is coarse, pattern <constant>1</constant> is medium, and
          pattern <constant>2</constant> is fine.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* DA <varname>BC</varname>=4 00
          <varname>xx</varname> 00
          <varname>yy</varname></literal></term>
      <listitem>
        <para>
          Set results for the alignment pattern.
          <varname>xx</varname> is the pattern
          (<constant>1</constant>--<constant>3</constant>);
          <varname>yy</varname> is the best choice from the set
          (<constant>1</constant>--<constant>7</constant> or
          <constant>1</constant>--<constant>15</constant>).  This
          does not save to NVRAM, so when the printer is powered
          off, the setting will be lost.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* SV <varname>BC</varname>=0</literal></term>
      <listitem>
        <para>
          Save the current settings to NVRAM.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* RS <varname>BC</varname>=1
          01</literal></term>
      <listitem>
        <para>
          Reset the printer.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* IQ <varname>BC</varname>=1
          01</literal></term>
      <listitem>
        <para>
          Get ink quantity.  This requires direct access to the
          printer port.  The return looks like
        </para>
        <informalexample>
          <screen>IQ:KKCCMMYY</screen>
        </informalexample>
        <para>
          or
        </para>
        <informalexample>
          <screen>IQ:KKCCMMYYccmm</screen>
        </informalexample>
        <para>
          (for 4-color and 6-color printers respectively), where
          each pair of digits are hexadecimal representations of
          percent.
        </para>
      </listitem>
    </varlistentry>
</variablelist>
<para>
  The following two commands have been observed on an STP 870.
</para>
<variablelist>
    <varlistentry>
      <term><literal>* IR <varname>BC</varname>=2 00
          <varname>xx</varname></literal></term>
      <listitem>
        <para>
          <emphasis>Function unknown</emphasis>.  This command has
          been observed on an STP 870 with
          <varname>xx</varname>=<constant>03</constant> at the start
          of a job and <varname>xx</varname>=<constant>02</constant>
          at the end of a job (where it is followed by an
          <literal>LD</literal> command).  When in roll mode, the
          values change to
          <varname>xx</varname>=<constant>01</constant> at the start
          of a job and <varname>xx</varname>=<constant>00</constant>
          at the end of a job.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term><literal>* FP <varname>BC</varname>=3 00
          <varname>pos</varname>[2]</literal></term>
      <listitem>
        <para>
          Specify the horizontal left margin in units of 1/360 inch.
          The default value for <varname>pos</varname> is
          <constant>0</constant>.  For borderless printing on
          printers that support it, a value of
          <constant>-80</constant> (<constant>FFB0h</constant>)
          should be used.
        </para>
      </listitem>
    </varlistentry>
  </variablelist>
  <para>
    The commands below are partially documented in the Stylus Pro
    9000 manual.  Much of this information is interpreted; none is
    tested.
  </para>
  <variablelist>
      <varlistentry>
        <term><literal>* SN <varname>BC</varname>=3 00
            <varname>xx</varname> <varname>yy</varname></literal></term>
        <listitem>
          <para>
            Select Mechanism Sequence.  <varname>xx</varname>
            controls which sub-operation is performed.
            <varname>xx</varname>=<constant>00</constant> selects
            the &ldquo;Feed paper sequence setting&rdquo;.
            <varname>yy</varname> can take on the following values
            (on the STP 870, at any rate):
          </para>
          <table>
            <title>Media types</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="id"/>
              <colspec colnum="2" colname="description"/>
              <thead>
                <row>
                  <entry><varname>yy</varname></entry>
                  <entry>Media type</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>0</constant></entry>
                  <entry>Default</entry>
                </row>
                <row>
                  <entry><constant>1</constant></entry>
                  <entry>Plain paper</entry>
                </row>
                <row>
                  <entry><constant>2</constant></entry>
                  <entry>Postcards</entry>
                </row>
                <row>
                  <entry><constant>3</constant></entry>
                  <entry>
                    Film (photo quality glossy film, transparencies)
                  </entry>
                </row>
                <row>
                  <entry><constant>4</constant></entry>
                  <entry>Envelopes</entry>
                </row>
                <row>
                  <entry><constant>5</constant></entry>
                  <entry>Plain paper (fast load)</entry>
                </row>
                <row>
                  <entry><constant>6</constant></entry>
                  <entry>
                    Back light film (although this has been observed
                    with heavyweight matte paper)
                  </entry>
                </row>
                <row>
                  <entry><constant>7</constant></entry>
                  <entry>
                    Matte paper (observed with 360 dpi inkjet paper,
                    and photo quality inkjet paper)
                  </entry>
                </row>
                <row>
                  <entry><constant>8</constant></entry>
                  <entry>Photo paper</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            Experimentation suggests that this setting changes
            details of how the printers' cut sheet feeder works,
            presumably to tune it for different types of paper.
          </para>
          <para>
            <varname>xx</varname>=<constant>01</constant> controls
            the platen gap setting;
            <varname>yy</varname>=<constant>00</constant> is the
            default, <varname>yy</varname>=<constant>1</constant> or
            <constant>2</constant> are higher settings.
          </para>
          <para>
            <varname>xx</varname>=<constant>02</constant> controls
            paper loading speed
            (<varname>yy</varname>=<constant>0</constant> is normal,
            <constant>1</constant> is fast, <constant>2</constant>
            is slow).  It appears that <constant>1</constant> is
            used when printing on &ldquo;plain paper&rdquo;,
            &ldquo;360dpi ink jet paper&rdquo; or &ldquo;ink jet
            transparencies&rdquo;, and
            <varname>yy</varname>=<constant>00</constant> for all
            other paper type settings.
          </para>
          <para>
            <varname>xx</varname>=<constant>07</constant> controls
            duplex printing for printers with that capability
            (<varname>yy</varname>=<varname>0</varname> is default,
            for non-duplex printing; <constant>1</constant> is front
            side of the paper, and <varname>2</varname> is back
            side).
          </para>
          <para>
            <varname>xx</varname>=<constant>09</constant> controls
            zero margin printing on the printers with the capability
            of printing zero-margin on all sides (Stylus Photo
            780/790, 890, and 1280/1290).
            <varname>yy</varname>=<constant>0</constant> is the
            default; <constant>1</constant> enables zero margin
            printing.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* PP <varname>BC</varname>=3 00
            <varname>xx</varname>
            <varname>yy</varname></literal></term>
        <listitem>
          <para>
            Set Paper Path.
            <varname>xx</varname>=<constant>2</constant> indicates
            manual feed,
            <varname>xx</varname>=<constant>3</constant> is for roll
            paper.  <varname>yy</varname> selects &ldquo;paper path
            number&rdquo;.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* AC <varname>BC</varname>=2 00
            <varname>xx</varname></literal></term>
        <listitem>
          <para>
            Set Auto Cutting State.
            <varname>xx</varname>=<constant>0</constant> selects
            auto cutting off,
            <varname>xx</varname>=<constant>1</constant> selects
            auto cutting on, and
            <varname>xx</varname>=<constant>2</constant> indicates
            horizontal print page line on.  It appears that with
            auto cutting on, roll paper is cut automatically at the
            point a formfeed character is sent.  The formfeed
            character is normally used to eject a page; with this
            turned on, it also cuts the roll paper.  Horizontal
            print page line on prints a narrow line of black dots at
            the position the paper should be cut manually.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* DR <varname>BC</varname>=4 00 xx
            <varname>DT2</varname></literal></term>
        <listitem>
          <para>
            Set Drying Time.
            <varname>xx</varname>=<constant>00</constant> sets the
            drying time &ldquo;per scan&rdquo; (per pass?);
            <varname>xx</varname>=<constant>01</constant> sets the
            drying time per page. <varname>DT</varname> indicates
            the drying time, which is in seconds if page mode is
            used and in milliseconds if scan mode is used.
            <varname>DT</varname> must not exceed 3600 seconds in
            per-page mode and 10000 milliseconds in per-scan mode.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* IK <varname>BC</varname>=2 00
            <varname>xx</varname></literal></term>
        <listitem>
          <para>
            Select Ink Type.
            <varname>xx</varname>=<constant>00</constant> selects
            dye ink.  Pigment ink is apparently selected by
            <varname>xx</varname>=<constant>01</constant>.  This
            probably does not apply to the consumer-grade printers.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* PZ BC=2 00 xx</literal></term>
        <listitem>
          <para>
            Set Pause After Printing.
            <varname>xx</varname>=<constant>00</constant> selects no
            pause after printing;
            <varname>xx</varname>=<constant>01</constant> selects
            pause after printing.  If turned on, the printer is
            paused after the page is ejected (by the FF byte).  If
            cutting is turned on, the printer is paused
            <emphasis>after</emphasis> the cutting or printing of
            the horizontal cut line.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* EX <varname>BC</varname>=6 00 00 00 00 0x14
          <varname>xx</varname></literal></term>
        <listitem>
          <para>
            Set Vertical Print Page Line Mode.
            <varname>xx</varname>=<constant>00</constant> is off,
            <varname>xx</varname>=<constant>01</constant> is on.  If
            turned on, this prints vertical trim lines at the left
            and right margins.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* EX <varname>BC</varname>=6 00 00 00 00 0x05
            <varname>xx</varname></literal></term>
        <listitem>
          <para>
            Set Roll Paper Mode.  If <varname>xx</varname> is
            <constant>0</constant>, roll paper mode is off; if
            <varname>xx</varname> is <constant>1</constant>, roll
            paper mode is on.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* EX <varname>BC</varname>=3 00
            <varname>xx</varname> <varname>yy</varname></literal></term>
        <listitem>
          <para>
            Appears to be a synonym for the <literal>SN</literal>
            command described above.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* PH <varname>BC</varname>=2 00
            <varname>xx</varname></literal></term>
        <listitem>
          <para>
            Select Paper Thickness.  Set the paper thickness
            <varname>xx</varname> in .1 mm units.  This must not
            exceed <constant>0x10</constant> (1.6 mm).  If the
            thickness is set &ldquo;more than&rdquo; .6 mm (which
            probably means &ldquo;at least&rdquo; 0.6 mm, since the
            other case reads &ldquo;less than 0.5 mm&rdquo;), the
            platen gap is set high irrespective of the
            <literal>SN</literal> command.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* PM <varname>BC</varname>=2 00
            00</literal></term>
        <listitem>
          <para>
            <emphasis>Function unknown</emphasis>. Used on the STC
            3000 at least when using roll feed, and on the STP 870
            in all print files analysed to date.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* ST <varname>BC</varname>=2 00
            <varname>xx</varname></literal></term>
        <listitem>
          <para>
            Epson's STP 750/1200 programming guide refers to the
            <literal>ST</literal> command as &ldquo;Set printer
            state reply&rdquo;.  If <varname>xx</varname> is
            <constant>0</constant> or <constant>2</constant>, the
            printer will not send status replies.  If
            <varname>xx</varname> is <constant>1</constant> or
            <constant>3</constant>, the printer will send status
            replies.  The status replies consist of state, error
            codes, ink leve, firmware version, and warning status.
          </para>
          <para>
            The actual reply is documented as
          </para>
          <informalexample>
            <screen>@BDC ST\r
ST: xx;
[ER: yy;]
IQ: n1n2n3n4;
[WR: w1,w2...;]
RV: zz;
AI:CW:02kkccmmyy, MI:mm
[TC:tttt;]
INK:...;
\f</screen>
          </informalexample>
          <para>
            (<literal>\r</literal> is carriage return;
            <literal>\n</literal> is newline; <literal>\f</literal>
            is formfeed.)
          </para>
          <para>
            <literal>ST</literal> is the printer status:
          </para>
          <table>
            <title>Printer status codes</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="status"/>
              <colspec colnum="2" colname="description"/>
              <thead>
                <row>
                  <entry>Status code</entry>
                  <entry>Description</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>00</constant></entry>
                  <entry>Error</entry>
                </row>
                <row>
                  <entry><constant>01</constant></entry>
                  <entry>Self-test</entry>
                </row>
                <row>
                  <entry><constant>02</constant></entry>
                  <entry>Busy</entry>
                </row>
                <row>
                  <entry><constant>03</constant></entry>
                  <entry>Waiting while printing</entry>
                </row>
                <row>
                  <entry><constant>04</constant></entry>
                  <entry>Idle</entry>
                </row>
                <row>
                  <entry><constant>07</constant></entry>
                  <entry>Cleaning/filling ink heads</entry>
                </row>
                <row>
                  <entry><constant>08</constant></entry>
                  <entry>Not yet initialized/filling heads</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            <literal>ER</literal>, if provided, is the error status:
          </para>
          <table>
            <title>Printer error codes</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="error"/>
              <colspec colnum="2" colname="description"/>
              <thead>
                <row>
                  <entry>Error code</entry>
                  <entry>Description</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>00</constant></entry>
                  <entry>Fatal Error</entry>
                </row>
                <row>
                  <entry><constant>01</constant></entry>
                  <entry>Interface not selected</entry>
                </row>
                <row>
                  <entry><constant>04</constant></entry>
                  <entry>Paper jam</entry>
                </row>
                <row>
                  <entry><constant>05</constant></entry>
                  <entry>Out of ink</entry>
                </row>
                <row>
                  <entry><constant>06</constant></entry>
                  <entry>Paper out</entry>
                </row>
                <row>
                  <entry><constant>0D</constant></entry>
                  <entry>Paper gap error</entry>
                </row>
                <row>
                  <entry><constant>10</constant></entry>
                  <entry>Maintenance request</entry>
                </row>
                <row>
                  <entry><constant>11</constant></entry>
                  <entry>Tear-off mode selected</entry>
                </row>
                <row>
                  <entry><constant>12</constant></entry>
                  <entry>Double feed error</entry>
                </row>
                <row>
                  <entry><constant>1C</constant></entry>
                  <entry>Cutter position error</entry>
                </row>
                <row>
                  <entry><constant>1D</constant></entry>
                  <entry>Cutter jam</entry>
                </row>
                <row>
                  <entry><constant>1E</constant></entry>
                  <entry>Ink color error</entry>
                </row>
                <row>
                  <entry><constant>23</constant></entry>
                  <entry>Ink combination error</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            <literal>IQ</literal> is the amount of ink left, as a
            (decimal!)  percentage expressed in hexadecimal.  The
            values are black, cyan, magenta, and yellow.  6 and 7
            color printers usually specify two or three additional
            values for light cyan, light magenta, and gray.
            However, some low end 6-color printers specify only four
            values.
          </para>
          <para>
            For printers with different ink cartridge options, the
            following additional values may appear:
          </para>
          <table>
            <title>Printer additional ink codes</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="code"/>
              <colspec colnum="2" colname="description"/>
              <thead>
                <row>
                  <entry>Ink code</entry>
                  <entry>Description</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>NA</constant></entry>
                  <entry>Ink cartridge is not inserted</entry>
                </row>
                <row>
                  <entry><constant>RE</constant></entry>
                  <entry>
                    Ink cartridge information cannot be read
                  </entry>
                </row>
                <row>
                  <entry><constant>WE</constant></entry>
                  <entry>
                    Ink cartridge information cannot be written
                  </entry>
                </row>
                <row>
                  <entry><constant>CI</constant></entry>
                  <entry>
                    Ink cartridge is inserted, but has not been read
                  </entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            <literal>WR</literal>, if provided, is the warning status:
          </para>
          <table>
            <title>Printer warning codes</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="warning"/>
              <colspec colnum="2" colname="description"/>
              <thead>
                <row>
                  <entry>Warning code</entry>
                  <entry>Description</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>10</constant></entry>
                  <entry>
                    Black ink low (Photo black on printers using
                    UltraChrome&reg; ink)
                  </entry>
                </row>
                <row>
                  <entry><constant>11</constant></entry>
                  <entry>Cyan</entry>
                </row>
                <row>
                  <entry><constant>12</constant></entry>
                  <entry>Magenta</entry>
                </row>
                <row>
                  <entry><constant>13</constant></entry>
                  <entry>Yellow</entry>
                </row>
                <row>
                  <entry><constant>14</constant></entry>
                  <entry>Light cyan (presumably)</entry>
                </row>
                <row>
                  <entry><constant>15</constant></entry>
                  <entry>Light magenta (presumably)</entry>
                </row>
                <row>
                  <entry><constant>17</constant></entry>
                  <entry>
                    Gray (with UltraChrome-compatible printers)
                  </entry>
                </row>
                <row>
                  <entry><constant>18</constant></entry>
                  <entry>Matte black 1 (UltraChrome)</entry>
                </row>
                <row>
                  <entry><constant>19</constant></entry>
                  <entry>Matte black 2 (UltraChrome)</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            <literal>RV</literal> is the firmware revision (one byte
            ASCII).
          </para>
          <para>
            <literal>AI</literal> is actuator information.  These
            are two byte ASCII codes that indicate ``ink weight rank
            ID'' of KCMY, respectively.
          </para>
          <para>
          <literal>TC</literal>, if provided, is the total time of
          cleaning or ink filling (?).
          </para>
          <para>
            <literal>RC</literal>, if provided, is the firmware
            revision.
          </para>
          <para>
            <literal>INK:</literal> and <literal>MI</literal> are
            <emphasis>not documented</emphasis>.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* SM <varname>BC</varname>=2 00
            <varname>xx</varname></literal></term>
        <listitem>
          <para>
            Set Status Reply Rate.  <varname>xx</varname> is the
            repeat interval in seconds.  If <varname>xx</varname> is
            <constant>0</constant>, the status is returned only when
            the printer's state changes.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* ST <varname>BC</varname>=1
            01</literal></term>
        <listitem>
          <para>
            Reply Printer Status.  The reply is formatted as follows:
          </para>
          <informalexample>
            <screen>@BDC PS\r\nST:<varname>xx</varname>;\f</screen>
          </informalexample>
          <para>
            <literal>\r</literal> is carriage return;
            <literal>\n</literal> is newline; <literal>\f</literal> is
            formfeed).  If <varname>xx</varname> (the reply value) is
            <constant>0</constant> or <constant>2</constant>,
            automatic status update is disabled; if
            <constant>1</constant> or <constant>3</constant>, it is
            enabled.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* SM <varname>BC</varname>=1
            01</literal></term>
        <listitem>
          <para>
            Reply Printer Status Rate.  The reply is formatted as
            follows:
          </para>
          <informalexample>
            <screen>@BDC PS\r\nST:xx;\f</screen>
          </informalexample>
          <para>
            <literal>\r</literal> is carriage return;
            <literal>\n</literal> is newline; <literal>\f</literal> is
            formfeed).  See <literal>SM
              <varname>BC</varname>=2</literal> above for the meaning of
            the return value.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* ??
            <varname>BC</varname>=<varname>xx</varname>
            <varname>y</varname>[1] &hellip;
            <varname>y</varname>[xx]</literal></term>
        <listitem>
          <para>
            Echo Parameters (perhaps better described as Echo
            Commands).  The command string is executed (it would
            appear from the documentation), and the string sent is
            returned using a sequence similar to that described in
            the <literal>ST <varname>BC</varname>=1</literal> and
            <literal>SM <varname>BC</varname>=1</literal> commands.
            Note that in this case the number of bytes is variable!
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* SM <varname>BC</varname>=2 00
            02</literal></term>
        <listitem>
          <para>
            <emphasis>Function unknown</emphasis>.  Used on the STC
            3000 at least when using roll feed.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* JE <varname>BC</varname>=1
            00</literal></term>
        <listitem>
          <para>
            <emphasis>Function unknown</emphasis>.  On new printers
            (STC 740 or newer), this command should be sent after
            all data has been sent.  If this command is not sent,
            and the printer is connected to a Windows system, the
            last page of the job will not print completely.  The
            most likely explanation for for this is that the Windows
            driver typically puts the printer in 1284.4 packet mode,
            and this command has the effect of flushing the buffer
            in the printer.
          </para>
        </listitem>
      </varlistentry>
      <varlistentry>
        <term><literal>* CO <varname>BC</varname>=8 00
            <varname>cutter</varname>[1] <varname>page</varname>[1]
            <varname>unit</varname>[1]
            <varname>position</varname>[4]</literal></term>
        <listitem>
          <para>
            Specify paper cutting on Stylus Photo 2200 (and perhaps
            some other printers).  <varname>cutter</varname> must be
            0.  <varname>page</varname> should be one of the
            following:
          </para>
          <table>
            <title>Paper cutting codes</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="code"/>
              <colspec colnum="2" colname="description"/>
              <thead>
                <row>
                  <entry>Code</entry>
                  <entry>Description</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>0</constant></entry>
                  <entry>All pages</entry>
                </row>
                <row>
                  <entry><constant>1</constant></entry>
                  <entry>First page only</entry>
                </row>
                <row>
                  <entry><constant>2</constant></entry>
                  <entry>Last page only</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            <varname>unit</varname> should be one of the following:
          </para>
          <table>
            <title>Paper cutting units</title>
            <tgroup cols="2" align="left">
              <colspec colnum="1" colname="code"/>
              <colspec colnum="2" colname="description"/>
              <thead>
                <row>
                <entry>Code</entry>
                  <entry>Description</entry>
                </row>
              </thead>
              <tbody>
                <row>
                  <entry><constant>0</constant></entry>
                  <entry>1/360 in.</entry>
                </row>
                <row>
                  <entry><constant>1</constant></entry>
                  <entry>1/720 in.</entry>
                </row>
                <row>
                  <entry><constant>2</constant></entry>
                  <entry>1/1440 in.</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
          <para>
            This command should be used twice.  The first
            <literal>CO</literal> command specifies where the page
            will be cut at the top, and the second specifies where
            the page will be cut at the bottom.  This permits
            cutting both the top and the bottom of the page.
          </para>
        </listitem>
      </varlistentry>
    </variablelist>
  </sect1>
  <sect1>
    <title>Appropriate Remote Commands</title>

    <para>
        All of the remote commands described above are wrapped up with
        the usual boilerplate.  The files always start with
        <literal>00 00 00</literal> and the &ldquo;magic&rdquo;
        command described above, then two <literal>ESC @</literal>s to
        reset the printer.  The remote command sequences come next; if
        they print anything that is usually followed by a
        <literal>FF</literal> (<literal>0C</literal> hex) character to
        feed the page, then the file ends with another two
        <literal>ESC @</literal>s to get back to the ground state.
    </para>
    <para>
        An alignment sequence goes like this:
    </para>
    <orderedlist>
        <listitem>
          <para>
            Host uses <literal>DT</literal> to print an alignment
            sheet.
          </para>
        </listitem>
        <listitem>
          <para>
            User eyeballs the sheet to see which is the best aligned
            pattern.
          </para>
        </listitem>
        <listitem>
          <para>
            Host sends a <literal>DA</literal> command indicating
            which pattern the user chose.
          </para>
        </listitem>
        <listitem>
          <para>
            If the user said &ldquo;realign&rdquo;, meaning he isn't
            done yet, go to step 1.
          </para>
        </listitem>
        <listitem>
          <para>
            We are done: host sends a <literal>SV</literal> command
            and exits.
          </para>
        </listitem>
    </orderedlist>

    <para>
        The sequence used (by the STC 3000, at least) to print from
        the roll feed is (with byte count omitted):
    </para>
    <informalexample>
      <screen>PM 00 00
SN 00 00 00
EX 00 00 00 00 05 01
ST 00 01
SM 00 02</screen>
    </informalexample>
    <para>
        The sequence used by the STP 870 to print on plain paper is
    </para>
    <informalexample>
      <screen>PM 00 00
IR 00 03
SN 00 00 01
SN 00 01 00
SN 00 02 01
EX 00 00 00 00 05 00
FP 00 00 00</screen>
    </informalexample>
    <para>
        and the job finishes with
    </para>
    <informalexample>
      <screen>IR 00 02
LD</screen>
    </informalexample>
    <para>
        For different paper type settings on the STP 870, the
        arguments to <literal>SN</literal> vary.  The arguments to the
        first and third <literal>SN</literal> commands are as outlined
        in the description of the <literal>SN</literal> command above;
        the arguments to the second (&ldquo;platen gap&rdquo;) are
        <literal>00 01 01</literal> for thick papers (&ldquo;matte
        paper&mdash;heavyweight&rdquo;, &ldquo;photo paper&rdquo; and
        &ldquo;premium glossy photo paper&rdquo;) and <literal>00 01
        00</literal> for all others.
    </para>
    <para>
        For roll-mode printing, the STP 870's sequence changes as
        follows.  <literal>IR</literal>'s arguments become <literal>00
        01</literal> in the header, and <literal>00 00</literal> after
        the job, and <literal>EX</literal>'s last argument changes
        from <constant>00</constant> to <constant>01</constant>.
    </para>
    <para>
        For zero-margin printing on the STP 870, the arguments to
        <literal>FP</literal> become <literal>00 0xb0 0xff</literal>.
        This moves the origin about 5.5mm to the left, to a point one
        tenth of an inch to the left of the left-hand edge of the
        paper, allowing printing right up to (and beyond) the edge of
        the paper.  Some printers (at least the STP 870) include white
        absorbent pads at the left margin position and other positions
        (89mm and 100mm on the STP 870) to soak up ink which misses
        the edge of the paper.  Printing off the edge of paper of a
        width not aligned with a pad could result in making a mess of
        the inside of the printer and ink getting on the reverse of
        the paper.
    </para>
  </sect1>
</chapter>