title: Unkown error 0x16 on smartcard reader access
body: <p>I am trying to change the buzzer duration on the ACR1252U.</p>
  
  <p>Link to API:
  <a href="http://www.acs.com.hk/download-manual/6402/API-ACR1252U-1.09.pdf" rel="nofollow noreferrer">http://www.acs.com.hk/download-manual/6402/API-ACR1252U-1.09.pdf</a></p>
  
  <p>According to the API documentation I need the 'E0000028010A' command to change the buzzer status, whereby '0A' marks the duration as 0A*10ms (Page 44).</p>
  
  <p>Following Java code is used:</p>
  
  <pre><code>public static void main(String[] args) {
      try {
          byte[] send = new byte[6];
  
          send[0] = (byte) 0xE0; // Commandclass
          send[1] = (byte) 0x00; // Protocoll
          send[2] = (byte) 0x00; // Param 1
          send[3] = (byte) 0x28; // Param 2: Buzzerstatus
          send[4] = (byte) 0x01; // Change Flag
          send[5] = (byte) 0x0A; // Duration: 0A*10ms =&gt; 100ms
  
          Card card = getCard("DIRECT"); // Works!
          CardChannel channel = card.getBasicChannel(); // Works!
          CommandAPDU command = new CommandAPDU(send); // Works!
          channel.transmit(command); // EXCEPTION!
      } catch (Exception ex) {
          ex.printStackTrace();
      }
  }
  
  public static Card getCard(String target) throws Exception {
      TerminalFactory factory = TerminalFactory.getDefault();
      List&lt;CardTerminal&gt; terminals = factory.terminals().list();
      for (CardTerminal t : terminals) {
          if (t.getName().equals("ACS ACR1252 Dual Reader PICC 0")) {
              Card card = t.connect(target);
              return card;
          }
      }
      throw new Exception();
  }
  </code></pre>
  
  <p>But this results in the following stacktrace indicating the "unkown error 0x16":</p>
  
  <pre><code>javax.smartcardio.CardException: sun.security.smartcardio.PCSCException: Unknown error 0x16
      at sun.security.smartcardio.ChannelImpl.doTransmit(ChannelImpl.java:219)
      at sun.security.smartcardio.ChannelImpl.transmit(ChannelImpl.java:90)
      at readerconfig.TagConfig.main(TagConfig.java:24)
  Caused by: sun.security.smartcardio.PCSCException: Unknown error 0x16
      at sun.security.smartcardio.PCSC.SCardTransmit(Native Method)
      at sun.security.smartcardio.ChannelImpl.doTransmit(ChannelImpl.java:188)
      ... 2 more
  </code></pre>
  
  <p>I've spent hours on searching for anything in this direction however I couldn't find anything. I have even tried another device, which still generated this error.</p>
  
  <p>Either I have completely gone blind or something is not set up correctly with my computer. All I can say is, that I have already successfully written and read from NFC tags using this reader. But I just can't change the config of the reader itself.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I've also found this alternative way to send the command:</p>
  
  <pre><code>byte[] send = new byte[5];
  send[0] = (byte) 0xE0;
  send[1] = (byte) 0x0;
  send[2] = (byte) 0x0;
  send[3] = (byte) 0x18; // Tries to read firmware version
  send[4] = (byte) 0x0;
  
  Card card = CardUtils.getCard("DIRECT"); // Works!
  card.transmitControlCommand(3500, send);
  </code></pre>
  
  <p>But this results in the "unknown error 0x1":</p>
  
  <pre><code>javax.smartcardio.CardException: transmitControlCommand() failed
      at sun.security.smartcardio.CardImpl.transmitControlCommand(CardImpl.java:236)
      at readerconfig.ReaderConfig.main(ReaderConfig.java:28)
  Caused by: sun.security.smartcardio.PCSCException: Unknown error 0x1
      at sun.security.smartcardio.PCSC.SCardControl(Native Method)
      at sun.security.smartcardio.CardImpl.transmitControlCommand(CardImpl.java:232)
      ... 1 more
  </code></pre>