📄 onewirecontainer16.java
字号:
return capdu; } /** * Gets the current <code>ResponseAPDU</code> received from this Java iButton * * @return current <code>ResponseAPDU</code> received from this Java iButton */ public ResponseAPDU getResponseAPDUInfo () { return rapdu; } /** * Gets the run time value set for this Java iButton * * @return run time value of this Java iButton * * @see #setRunTime */ public int getRunTime () { return runTime; } /** * Gets the select run time value set for this Java iButton * * @return run time value of this Java iButton on select operations * * @see #setSelectRunTime */ public int getSelectRunTime () { return selectRunTime; } /** * Gets the load run time value set for this Java iButton * * @return run time value of this Java iButton on load operations * * @see #setLoadRunTime */ public int getLoadRunTime () { return loadRunTime; } /** * Sets the run time value for this Java iButton * * @param runTime a <code>4</code> bit value (<code>0 -15</code>) that * represents the expected run time of the device * * Actual run time is calculated as followed: * <code><pre> * runTime * 250 + 62.5 mS <BR> * Therefore, 0 -> 0 * 250 + 62.5 = 62.5 mS * 1 -> 1 * 250 + 62.5 = 312.5 mS </pre></code> * and so on. * * @throws IllegalArgumentException Invalid run time value * * @see #getRunTime */ public void setRunTime (int newRunTime) throws IllegalArgumentException { if ((newRunTime > 15) || (newRunTime < 0)) throw new IllegalArgumentException("Run Time value should be between 0 and 15."); runTime = newRunTime; } /** * Sets the select operation run time value for this Java iButton. * The select-applet operation may require special consideration * because APDU processing is done on a select. * * @param runTime a <code>4</code> bit value (<code>0 -15</code>) that * represents the expected run time of the device on a * select operation. This value should not be less than * the normal <code>runTime</codE> value. * * Actual run time is calculated as followed: * <code><pre> * runTime * 250 + 62.5 mS <BR> * Therefore, 0 -> 0 * 250 + 62.5 = 62.5 mS * 1 -> 1 * 250 + 62.5 = 312.5 mS </pre></code> * and so on. * * @throws IllegalArgumentException Invalid run time value * * @see #getSelectRunTime */ public void setSelectRunTime (int newRunTime) throws IllegalArgumentException { if ((newRunTime > 15) || (newRunTime < 0)) throw new IllegalArgumentException("Run Time value should be between 0 and 15."); selectRunTime = newRunTime; } /** * Sets the load operation run time value for this Java iButton. * The last packet of a load-applet operation may require special consideration * because additional processing is performed once the applet is loaded. * All non-final load packets run based on the normal <code>runTime</code> * value. * * @param runTime a <code>4</code> bit value (<code>0 -15</code>) that * represents the expected run time of the device on a * final load packet. This value should not be less than * the normal <code>runTime</code> value. * * Actual run time is calculated as followed: * <code><pre> * runTime * 250 + 62.5 mS <BR> * Therefore, 0 -> 0 * 250 + 62.5 = 62.5 mS * 1 -> 1 * 250 + 62.5 = 312.5 mS </pre></code> * and so on. * * @throws IllegalArgumentException Invalid run time value * * @see #getLoadRunTime */ public void setLoadRunTime (int newRunTime) throws IllegalArgumentException { if ((newRunTime > 15) || (newRunTime < 0)) throw new IllegalArgumentException("Run Time value should be between 0 and 15."); loadRunTime = newRunTime; } /** * Sets the run time value for reading bytes from the output buffer of this Java iButton. * Generally, output data is read giving the button the minimal amount of runtime * needed. However, for larger amounts of data, this may fail, causing the operation * to be retried. To avoid the retry, this value can be altered if something is known about * the size of the output data. * * @param runTime a <code>4</code> bit value (<code>0-15</code>) that * represents the run time of the device for reading * data from the output buffer of this Java Powered iButton * * @throws IllegalArgumentException Invalid run time value * * @see #getLoadRunTime */ public void setReadingRunTime (int newRunTime) throws IllegalArgumentException { if ((newRunTime > 15) || (newRunTime < 0)) throw new IllegalArgumentException("Run Time value should be between 0 and 15."); jibComm.min_read_runtime = newRunTime; } /** * Sets the size of the packets sent on load. * The range can be from <code>64</code> to <code>112</code> bytes. * * @param size new packet size * * @return <code>true</code> if packet size is set to the new value <BR> * <code>false</code> if invalid packet size is requested * * @see #getLoadPacketSize * @see #loadApplet */ public boolean setLoadPacketSize (int size) { // maximum number of bytes send is 124, // 4 for CommandAPDU header, 1 for data length, // 3 to append at sendAPDU(), 4 for JibComm setData header // and 112 for packet size if (size < 64 || size > 112) return false; APDU_PACKET_LENGTH = size; return true; } // setLoadPacketSize() /** * Gets the size of the packets sent on load. * * @return size of the packets sent on load * * @see #setLoadPacketSize * @see #loadApplet * */ public int getLoadPacketSize () { return APDU_PACKET_LENGTH; } // getLoadPacketSize() /** * Sets the PIN used to communicate with this Java iButton. * Once this method has been called, the PIN will be sent to every method * that requires a PIN. * * @param passwd PIN to be set and sent to this Java iButton for each command * that requires a PIN * * @see #getCommandPINMode * @see #setCommandPINMode * @see #setCommonPIN */ public void setPIN (String passwd) { password = passwd; } // setPIN() //------------------------------------------------------------------------- //-------- Firmware Command methods //------------------------------------------------------------------------- /** * Gets the amount of free RAM in this Java iButton. No PIN required. * * @return <code>ResponseAPDU</code> with a data field containing the amount * of free RAM in this Java iButton. Value returned is in little endian * format. * <ul> * <li>Success SW 0x9000. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * */ public ResponseAPDU getFreeRAM () throws OneWireException, OneWireIOException, IllegalArgumentException { capdu = new CommandAPDU(CLA, INS, ( byte ) 0x01, ( byte ) 0x01); rapdu = sendAPDU(capdu, runTime); return rapdu; } // getFreeRAM() /** * Gets requested number of bytes of random data generated by this Java * iButton. No PIN required. * * @param numBytes the number of bytes requested. <code>numByes</code> * should not exceed <code>119</code>. If the number is greater * than <code>119</code>, the API only returns <code>119</code>. * * @return <code>ResponseAPDU</code> with a data field containing random * bytes generated * <ul> * <li>Success SW 0x9000. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] */ public ResponseAPDU getRandomBytes (int numBytes) throws OneWireException, OneWireIOException, IllegalArgumentException { // maximum number of bytes return is 124, // 2 for status word, 3 to discard and 119 for data if (numBytes > 119) numBytes = 119; byte[] data = new byte [2]; data [0] = ( byte ) (numBytes & 0xFF); data [1] = ( byte ) ((numBytes >> 8) & 0xFF); capdu = new CommandAPDU(CLA, INS, ( byte ) 0x01, ( byte ) 0x0D, data); rapdu = sendAPDU(capdu, runTime); return rapdu; } // getRandomBytes() /** * Gets the firmware version string. No PIN required. * * @return <code>ResponseAPDU</code> with a data field containing the firmware * version string of this Java iButton * <ul> * <li>Success SW 0x9000. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] */ public ResponseAPDU getFirmwareVersionString () throws OneWireException, OneWireIOException, IllegalArgumentException { capdu = new CommandAPDU(CLA, INS, ( byte ) 0x01, ( byte ) 0x00); rapdu = sendAPDU(capdu, runTime); return rapdu; } // getFirmwareVersionString() /** * Gets the last error value. * If the error reporting mode is set (<code>1</code>), then this method * will return the value of the last exception. No PIN required. * * @return <code>ResponseAPDU</code> containing the last exception value * <ul> * <li>Success SW 0x9000. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #getErrorReportingMode * @see #setErrorReportingMode */ public ResponseAPDU getLastError () throws OneWireException, OneWireIOException, IllegalArgumentException { capdu = new CommandAPDU(CLA, INS, ( byte ) 0x01, ( byte ) 0x0F); rapdu = sendAPDU(capdu, runTime); return rapdu; } // getLastError() /** * Gets the Error Reporting Mode. This function is not supported in * the <code>.033</code> version of the firmware. No PIN required. * * @return <code>ResponseAPDU</code> containing the error reporting mode * <ul> * <li>Success SW 0x9000. * <li>Failure SW 0x6A02. Command not supported by this Java iButton. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -