title: Android POS Printer ESC/POS
body: <p>So I have been writing an Android app for a Bluetooth Printer for a while and I have realised that this is actually the ESC/POS standard: <a href="http://nicholas.piasecki.name/blog/wp-content/uploads/2009/12/ESC-POS-Command-Guide.pdf" rel="noreferrer">http://nicholas.piasecki.name/blog/wp-content/uploads/2009/12/ESC-POS-Command-Guide.pdf</a></p>
  
  <p>Now the document I am using for my printer is a limited subset of these commands and can be found here: <a href="https://dl.dropboxusercontent.com/u/88265006/%E4%BA%A7%E5%93%81/Printer%27s%20user%20manual/SP-MP-300-Technical%20Manual.pdf" rel="noreferrer"><a href="https://dl.dropboxusercontent.com/u/88265006/%E4%BA%A7%E5%93%81/Printer" rel="noreferrer">https://dl.dropboxusercontent.com/u/88265006/%E4%BA%A7%E5%93%81/Printer</a>'s%20user%20manual/SP-MP-300-Technical%20Manual.pdf</a></p>
  
  <pre><code>        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);
          }
  </code></pre>
  
  <p>I can connect to the printer, initialise it with an "ESC @" command and I can write with the above commands, but I cannot seem to get any of the "visual" effects in terms of ANY kind of barcode. This is my attempt for a 1D EAN13 code (0000000000000):</p>
  
  <pre><code>        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);
  </code></pre>
  
  <p>Where mService actually writes the data. The best output I get is 0█0█0█0█0█0█0█0█0█0█0█0█0█0█ - after sending the data many times in a row.</p>
  
  <p>If I remove the final  end byte after multiple sends I get 14 0's, and I have also tried adding an ending 0 to the height, width, textPosition and level arrays, with no affect.</p>
  
  <p>I have also looked in the following places:
  <a href="http://www.manualslib.com/manual/689542/Axiohm-A795.html?page=91" rel="noreferrer">http://www.manualslib.com/manual/689542/Axiohm-A795.html?page=91</a><br/>
  <a href="http://pyramidacceptors.com/phoenix-printer/esc-pos-command-set/" rel="noreferrer">http://pyramidacceptors.com/phoenix-printer/esc-pos-command-set/</a><br/>
  <a href="http://www.vbforums.com/showthread.php?754493-RESOLVED-Printing-Barcode-with-ESC-POS-on-Epson-Printers" rel="noreferrer">http://www.vbforums.com/showthread.php?754493-RESOLVED-Printing-Barcode-with-ESC-POS-on-Epson-Printers</a><br/>
  <a href="http://www.manualslib.com/manual/753647/Axiohm-A630.html?page=51" rel="noreferrer">http://www.manualslib.com/manual/753647/Axiohm-A630.html?page=51</a><br/>
  <a href="https://www.sparkfun.com/datasheets/Components/General/Driver%20board.pdf" rel="noreferrer">https://www.sparkfun.com/datasheets/Components/General/Driver%20board.pdf</a><br/>
  <a href="https://stackoverflow.com/questions/308588/where-can-i-find-a-esc-pos-epson-barcode-test-program">Where can I find a &quot;ESC/POS&quot; Epson Barcode Test Program?</a><br/></p>