首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android POS打印机ESC/POS

Android POS打印机ESC/POS
EN

Stack Overflow用户
提问于 2014-10-19 01:43:50
回答 1查看 17.4K关注 0票数 7

因此,我已经为蓝牙打印机编写了一段时间的安卓应用程序,我意识到这实际上是ESC/POS标准:http://nicholas.piasecki.name/blog/wp-content/uploads/2009/12/ESC-POS-Command-Guide.pdf

现在,我在打印机上使用的文档是这些命令的有限子集,可以在以下位置找到:https://dl.dropboxusercontent.com/u/88265006/%E4%BA%A7%E5%93%81/Printer's%20user%20manual/SP-MP-300-Technical%20Manual.pdf

代码语言:javascript
复制
        private void initPrinter() {
            byte[] init = new byte[2];
            init[0] = 0x1B;
            init[1] = 0x40;
            mService.write(init);
        }

        private void printText(String message){
            byte[] send;
            try{
                send = message.getBytes("UTF8");
            }
            catch(UnsupportedEncodingException e){
                send = "Error".getBytes();
            }
            initPrinter();
            mService.write(send);
        }

我可以连接到打印机,用"ESC @“命令初始化它,我可以用上面的命令写,但我似乎无法获得任何条形码方面的任何”视觉“效果。这是我对1D EAN13代码(0000000000000)的尝试:

代码语言:javascript
复制
        byte[] height = new byte[3];
        height[0] = 0x1D;
        height[1] = 0x68;
        height[2] = (byte)30;
        //height[3] = 0;

        byte[] width = new byte[3];
        width[0] = 0x1D;
        width[1] = 0x77;
        width[2] = (byte)3;

        byte[] textPos = new byte[3];
        textPos[0] = 0x1D;
        textPos[1] = 0x48;
        textPos[2] = (byte)2;

        byte[] level = new byte[3];
        level[0] = 0x1D;
        level[1] = 0x51;
        level[2] = (byte)32;

        byte[] code = new byte[18];
        code[0] = 0x1D;
        code[1] = 0x6B;
        code[2] = 0x02;
        code[3] = 0x0D;
        code[4] = 0x30;//1
        code[5] = 0x30;//2
        code[6] = 0x30;//3
        code[7] = 0x30;//4
        code[8] = 0x30;//5
        code[9] = 0x30;//6
        code[10] = 0x30;//7
        code[11] = 0x30;//8
        code[12] = 0x30;//9
        code[13] = 0x30;//10
        code[14] = 0x30;//11
        code[15] = 0x30;//12
        code[16] = 0x30;//13

        code[17] = 0x00;//end
        mService.write(height);
        mService.write(width);
        mService.write(textPos);
        mService.write(level);
        mService.write(code);

mService实际写入数据的位置。在连续多次发送数据之后,我得到的最佳输出是0█0█0█0█0█0█0█0█0█0█0█0█0█0█。

如果我在多次发送后删除最后一个结束字节,我得到了14个0,并且我还尝试在height,width,textPosition和level数组中添加一个结束0,但没有任何影响。

我还查看了以下位置:http://www.manualslib.com/manual/689542/Axiohm-A795.html?page=91

http://pyramidacceptors.com/phoenix-printer/esc-pos-command-set/

http://www.vbforums.com/showthread.php?754493-RESOLVED-Printing-Barcode-with-ESC-POS-on-Epson-Printers

http://www.manualslib.com/manual/753647/Axiohm-A630.html?page=51

https://www.sparkfun.com/datasheets/Components/General/Driver%20board.pdf

Where can I find a "ESC/POS" Epson Barcode Test Program?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-26 04:54:59

实际上,在ESC/POS中,打印机会为你计算一些数据。我不应该将校验字节(实际条形码的最后一位)放入我发送给打印机的数据中。

当然,我的文档遗漏了所有的<=符号,这也无济于事。我最终使用了这个文档来寻求帮助:http://content.epson.de/fileadmin/content/files/RSD/downloads/escpos.pdf

我仍然在打印二维码,但我很确定我的问题有点类似。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26442722

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档