【发布时间】:2020-04-01 22:34:32
【问题描述】:
我正在尝试使用 EPSON TM-T20 使用 ESC POS 命令打印二维码
我可以打印简单的文本,展开,剪纸,但是当我尝试打印二维码时......不成功
我使用的是 Linux,我的打印机位于 /dev/usb/lp1。
我相信 ESC POS 命令没问题,因为有另一台打印机 (TANCA TP650) 使用相同的命令打印二维码,而这另一台打印机也没问题。
这是我在 Qt C++ 中的代码
vetor.append(0x1D);// GS ( k pL pH cn fn n1 n2 (cn=49, fn=65)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(0x04);
vetor.append('\0');
vetor.append(0x31);//cn=49
vetor.append(0x41);//fn=65
vetor.append(50);//n1 48..49 ou 49..50 ????
vetor.append('\0');//n2
//f67 := #29+#40+#107+#03+#00+#49+#67 + Chr(tamanho mod 17);
vetor.append(0x1D);// GS ( k pL pH cn fn n (cn=49, fn=67)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(0x03);
vetor.append('\0');
vetor.append(0x31);//cn
vetor.append(0x43);//fn=67
vetor.append(3); //tamanho 1..16
//f69 := #29+#40+#107+#03+#00+#49+#69+#03;
vetor.append(0x1D);//GS ( k pL pH cn fn n (cn=49, fn=69)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(0x03);
vetor.append('\0');
vetor.append(49);//cn
vetor.append(69);//fn
vetor.append(48);// error correction level 48..51 ????
len+=3;
qDebug() << "qrcode epson " << len << str;
qDebug() << (len & 0xFF) << ((len & 0xFF00) >> 8);
//f80 := #29+#40+#107 + AnsiChar(l mod 256) + AnsiChar(l div 256) + #49+#80+#48;
vetor.append(0x1D);//GS ( k pL pH cn fn m d1...dk (cn=49, fn=80)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(len & 0xFF);
vetor.append((len & 0xFF00) >> 8);
vetor.append(0x31);//cn
vetor.append(0x50);//fn
vetor.append(0x30);//m
vetor.append(str);
//f81 := #29+#40+#107+#03+#00+#49+#81+#48;
vetor.append(0x1D);//GS ( k pL pH cn fn m (cn=49, fn=81)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(0x03);
vetor.append('\0');
vetor.append(49);//cn
vetor.append(81);//fn
vetor.append(48);//m
谢谢
【问题讨论】: