title: Open a cash drawer connected to a usb printer
body: <p>I have a cash drawer connected to an Epson TM-T20 connected on a <strong>USB</strong> port.
  I have found an example <a href="http://www.unix.com/unix-dummies-questions-answers/30250-printing-5-raw-characters-printer.html" rel="nofollow">here</a> and applied their ideas to with the codes from <a href="http://keyhut.com/popopen.htm" rel="nofollow">here </a> to the printer:</p>
  
  <pre><code>echo -en "\033\160\040\025" | lp -d "USB_TM-T20" -o raw
  </code></pre>
  
  <p>But this doesn't seem to work. Since epson provides a java library, I decided to have a look at it and decompiled it.</p>
  
  <pre><code>protected byte[] getOpenDrawerCommand()
  {
    byte[] arrayOfByte = new byte[5];
    if (this.m_objDrawerPort.isSupportRealTimeCommand())
    {
      arrayOfByte[0] = 16;
      arrayOfByte[1] = 20;
      arrayOfByte[2] = 1;
      arrayOfByte[3] = (byte)this.m_objDrawerSettings.getPinNumber(); // seems to be 0
      arrayOfByte[4] = (byte)this.m_objDrawerSettings.getOnTime(true); // between 1 and 8
    }
    else
    {
      arrayOfByte[0] = 27;
      arrayOfByte[1] = 112;
      arrayOfByte[2] = (byte)this.m_objDrawerSettings.getPinNumber(); // seems to be 0
      arrayOfByte[3] = (byte)this.m_objDrawerSettings.getOnTime(false); // [1, 255]
      arrayOfByte[4] = (byte)this.m_objDrawerSettings.getOffTime(false); // [1, 255]
    }
    return arrayOfByte;
  }
  </code></pre>
  
  <p>We see that the values from the keyfile seem to be correct (at least the first two). Unfortunately I was unable to find the code where it sends the data.
  Do you have an idea where I can find more information? The epson website seems to be kind of sparse. </p>
  
  <p><strong>Edit</strong>:
  It turns out that the connection cable was damaged and the new cable needed to be repinned in order to connect to the printer.</p>