⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shaibuttonuser33.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    * @param owc The DS1961S iButton that this object will refer to.    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    *    * @see #SHAiButtonUser33(SHAiButtonCopr,OneWireContainer33,boolean,byte[])    * @see #SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr)    */   public SHAiButtonUser33(SHAiButtonCopr copr, SHAiButtonCopr authCopr,                           OneWireContainer33 owc)      throws OneWireException, OneWireIOException   {      //setup service filename      this(copr,authCopr);      //hold container reference and address      if(!setiButton33(owc))         throw new OneWireException("Invalid SHA user");   }   /**    * <P>Creates a valid SHAiButtonUser object.  If the service file,    * whose name is taken from the <code>SHAiButtonCopr</code>, is not    * found on the user iButton, a OneWireException is thrown with the    * message "Invalid SHA user".</P>    *    * <P>Note: The same coprocessor can be used for write-authorization as    * authentication if you're transaction system is using unsigned transaction    * data.</P>    *    * @param coprBindCode The Coprocessor Bind Code without the information.    * @param fileName The file name from the Coprocessor.    * @param fileNameExt The file extenstion from the Coprocessor    * @param authCopr The SHAiButtonCopr used to generate the write-authorization    *        MAC for the copy-scratchpad command of the DS1961S.    * @param owc The DS1961S iButton that this object will refer to.    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    *    * @see #SHAiButtonUser33(SHAiButtonCopr,OneWireContainer33,boolean,byte[])    * @see #SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr)    */   public SHAiButtonUser33(byte[] coprBindCode, byte[] fileName,                           int fileNameExt, OneWireContainer33 owc)      throws OneWireException, OneWireIOException   {      //make sure fullBindCode has appropriate ff padding      System.arraycopy(ffBlock, 0, this.fullBindCode, 0, 15);      //create string representation of service filename      copr.getFilename(this.serviceFile,0);      this.strServiceFilename = new String(fileName) + "."                                + (int)fileNameExt;      //hold container reference and address      if(!setiButton33(owc))         throw new OneWireException("Invalid SHA user");   }   /**    * <P>Creates a mostly unitialized SHAiButtonUser object.  This constructor    * merely copies the coprocessors 7 byte binding code into a local cache    * and stores the name of the account service file used for all user    * iButtons.</P>    *    * <P>Since this constructor leaves data unitialized, you should be very    * careful with the use of it.  It is expected that after calling this    * constructor, the user will call <code>setiButton</code> to finish the    * initialization process.  On memory-starved platforms, this should help    * optimize memory usage.</P>    *    * <P>Note: The same coprocessor can be used for write-authorization as    * authentication if you're transaction system is using unsigned transaction    * data.</P>    *    * @param copr The SHAiButtonCopr to which the user object is tied.  This    *        Coprocessor contains the necessary binding code and service    *        filename, necessary for both locating a user and recreating his    *        unique secret.    * @param authCopr The SHAiButtonCopr used to generate the write-authorization    *        MAC for the copy-scratchpad command of the DS1961S.    *    *    * @see #SHAiButtonUser33(SHAiButtonCopr,OneWireContainer33,boolean,byte[])    * @see #SHAiButtonUser33(SHAiButtonCopr,SHAiButtonCopr,OneWireContainer33)    */   public SHAiButtonUser33(SHAiButtonCopr copr, SHAiButtonCopr authCopr)   {      //hold a reference to the coprocessor      this.copr = authCopr;      //make sure fullBindCode has appropriate ff padding      System.arraycopy(ffBlock, 0, this.fullBindCode, 0, 15);      //create string representation of service filename      copr.getFilename(this.serviceFile,0);      this.strServiceFilename = new String(this.serviceFile) + "."                                + (int)copr.getFilenameExt();   }   /**    * <P>Modifies this SHA iButton so that it refers to another DS1961S    * container.  This function only copies the reference to the    * OneWireContainer, copes the reference to it's 1-Wire address, and    * then asserts that the iButton contains a valid acccount info file    * associated with the system.</P>    *    * @param owc The <code>OneWireContainer33</code> this object will refer to.    *    * @return <code>true</code> if a valid account service file exists on    *         this <code>OneWireContainer33</code>.    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    */   public synchronized boolean setiButton33(OneWireContainer33 owc)      throws OneWireException, OneWireIOException   {      //hold container reference      this.ibc33 = owc;      //and address      this.address = owc.getAddress();      //clear account information      this.accountPageNumber = -1;      //make sure account info is properly setup      if(!checkAccountPageInfo(owc))         return false;      //setup the fullBindCode with rest of info      this.fullBindCode[4] = (byte)this.accountPageNumber;      System.arraycopy(this.address,0,                       this.fullBindCode,5,7);      //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\      if(DEBUG)      {         IOHelper.writeLine("------------------------------------");         IOHelper.writeLine("Loaded DS1961S User");         IOHelper.writeLine("address");         IOHelper.writeBytesHex(owc.getAddress());         IOHelper.writeLine("accountPageNumber: " + accountPageNumber);         IOHelper.writeLine("serviceFilename: " + strServiceFilename);         IOHelper.writeLine("------------------------------------");      }      //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\      return true;   }   /**    * <P>Modifies this SHA iButton so that it refers to another 1963S.    * If this object already has an appropriate instance of OneWireContainer,    * that instance is updated with the new address.</P>    *    * @param adapter The adapter that the device can be found on.    * @param address The address of the 1-Wire device    *    * @return <code>true</code> if a valid account service file exists on    *         this <code>OneWireContainer18</code>.    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    */   public synchronized boolean setiButtonUser(DSPortAdapter adapter,                                              byte[] address)      throws OneWireException, OneWireIOException   {      if(this.ibc33==null)         this.ibc33 = new OneWireContainer33();      this.ibc33.setupContainer(adapter,address);      return setiButton33(this.ibc33);   }   /**    * <P>Modifies this SHA iButton so that it refers to another device.    * If this object does not already has an appropriate instance of    * OneWireContainer, it returns false immediately, because there is    * no adapter info available.  Otherwise, it reuses the same adapter.</P>    *    * @param address The address of the 1-Wire device    *    * @return <code>true</code> if a valid account service file exists on    *         this <code>OneWireContainer18</code>.    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    */   public synchronized boolean setiButtonUser(byte[] address)      throws OneWireException, OneWireIOException   {      if(this.ibc33==null)         return false;      this.ibc33.setupContainer(this.ibc33.getAdapter(),address);      return setiButton33(this.ibc33);   }   /**    * <P>Returns the value of the write cycle counter for the    * page where the account data is stored.  If the write    * cycle counter has ever been retrieved, this returns the    * cached value.  Otherwise, this method reads the value    * from the part.</P>    *    * <P>Since the DS1961S has no "write cycle counters", this function    * always returns -1.</P>    *    * @return the value of the write cycle counter for the    *         account data page.    *    * @throws OneWireIOException on a 1-Wire communication error such as    *         reading an incorrect CRC from a 1-Wire device.  This could be    *         caused by a physical interruption in the 1-Wire Network due to    *         shorts or a newly arriving 1-Wire device issuing a 'presence pulse'.    * @throws OneWireException on a communication or setup error with the 1-Wire    *         adapter    */   public synchronized int getWriteCycleCounter()      throws OneWireException, OneWireIOException   {      //DS1961S has no write cycle counters      return -1;   }   /**    * <P>Returns <code>true</code> if this buttons account data is stored    * on a page that has a write cycle counter.</P>    *    * <P>Since the DS1961S has no "write cycle counters", this function    * always returns false.</P>    *    * @return <code>true</code> if account page has write cycle counter.    */   public synchronized boolean hasWriteCycleCounter()   {      //DS1961S has no write cycle counters      return false;   }   /**    * <P>This function creates the full 15-byte binding data for the    * coprocessor to use to recreate this user's secret on the copr's    * workspace page.  This function is located in the SHAiButtonUser    * class to support binding codes for user buttons who use alternate    * techniques (such as the DS1961S) for secret computation.</P>    *    * <P>For the DS1963S user iButton, the format of the full bind code is    * as follows:    *   <PRE>    *      ( 0x0000FF ), ( 0x0000FF ), ( 0x0000FF ), ( 0x0000FF ),    *      (svcPageNum), (deviceAN+0), (deviceAN+1), (deviceAN+2),    *      (deviceAN+3), (deviceAN+4), (deviceAN+5), (deviceAN+6),    *      ( 0x0000FF ), ( 0x0000FF ), ( 0x0000FF )    *   </PRE></P>    *    * @param bindCode the 7-byte binding code from coprocessor's service file    * @param fullBindCode the 15-byte full binding code to to be copied into    *                     the coprocessor's scratchpad.  There should be 15    *                     bytes available starting from the offset.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -