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

📄 memorybankshaee.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*--------------------------------------------------------------------------- * Copyright (C) 1999 Dallas Semiconductor Corporation, All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of Dallas Semiconductor * shall not be used except as stated in the Dallas Semiconductor * Branding Policy. *--------------------------------------------------------------------------- */package com.dalsemi.onewire.container;// importsimport com.dalsemi.onewire.OneWireException;import com.dalsemi.onewire.adapter.OneWireIOException;import com.dalsemi.onewire.utils.*;import com.dalsemi.onewire.adapter.*;import com.dalsemi.onewire.container.OneWireContainer;import com.dalsemi.onewire.debug.Debug;import com.dalsemi.onewire.utils.Convert;/**  * Memory bank class for the DS1961S/DS2432.  *  *  @version 	0.00, 19 Dec 2000  *  @author 	DS  */public class MemoryBankSHAEE   implements PagedMemoryBank{   //--------   //--------Static Final Variables   //--------   /** turn on extra debugging output */   private static final boolean DEBUG = false;   /** Read Memory Command */   public static final byte READ_MEMORY = ( byte ) 0xF0;   /** Read Authenticate Page */   public static final byte READ_AUTH_PAGE = ( byte ) 0xA5;   //--------   //-------- Protected Variables for MemoryBank implementation   //--------   /**     * Check the status of the memory page.     */   protected boolean checked;   /**     * Size of memory bank in bytes     */   protected int size;   /**    * Memory bank descriptions    */   protected String bankDescription;   /**    * Memory bank usage flags    */   protected boolean generalPurposeMemory;   /**    * Flag if memory bank is read/write    */   protected boolean readWrite;   /**    * Flag if memory bank is write once (EPROM)    */   protected boolean writeOnce;   /**    * Flag if memory bank is read only    */   protected boolean readOnly;   /**    * Starting physical address in memory bank.  Needed for different    * types of memory in the same logical memory bank.  This can be    * used to seperate them into two virtual memory banks.  Example:    * DS2406 status page has mixed EPROM and Volatile RAM.    */   protected int startPhysicalAddress;   /**    * Flag if read back verification is enabled in 'write()'.    */   protected boolean writeVerification;  /**    * Number of pages in memory bank    */   protected int numberPages;   /**    *  page length in memory bank    */   protected int pageLength;   /**    * Flag if reading a page in memory bank provides optional    * extra information (counter, tamper protection, SHA-1...)    */   protected boolean extraInfo;   /**    * Extra information length in bytes    */   protected int extraInfoLength;   /**    * Max data length in page packet in memory bank    */   protected int maxPacketDataLength;   /**    * Flag if memory bank has page CRC.    */   protected boolean pageCRC;   //--------   //-------- Variables   //--------   /**    * Reference to the OneWireContainer this bank resides on.    */   protected OneWireContainer33 ib = null;   /**    * Reference to the adapter the OneWireContainer resides on.    */   protected DSPortAdapter adapter = null;   /**    * Flag to indicate that speed needs to be set    */   protected boolean doSetSpeed;   /**    * block of 0xFF's used for faster read pre-fill of 1-Wire blocks    * Comes from OneWireContainer33 that this MemoryBank references.    */   protected static final byte[] ffBlock = OneWireContainer33.ffBlock;   /**    * block of 0x00's used for faster read pre-fill of 1-Wire blocks    * Comes from OneWireContainer33 that this MemoryBank references.    */   protected static final byte[] zeroBlock = OneWireContainer33.zeroBlock;   protected MemoryBankScratchSHAEE scratchpad;   /**    * Memory bank constructor.  Requires reference to the OneWireContainer    * this memory bank resides on.    */   public MemoryBankSHAEE (OneWireContainer33 ibutton, MemoryBankScratchSHAEE scratch)   {      // keep reference to ibutton where memory bank is      ib = ibutton;      scratchpad = scratch;      // keep reference to adapter that button is on      adapter = ib.getAdapter();      // indicate speed has not been set      doSetSpeed = true;   }   //--------   //-------- Memory Bank methods   //--------   /**    * Query to see get a string description of the current memory bank.    *    * @return  String containing the memory bank description    */   public String getBankDescription ()   {      return bankDescription;   }   /**    * Query to see if the current memory bank is general purpose    * user memory.  If it is NOT then it is Memory-Mapped and writing    * values to this memory will affect the behavior of the 1-Wire    * device.    *    * @return  'true' if current memory bank is general purpose    */   public boolean isGeneralPurposeMemory ()   {      return generalPurposeMemory;   }  /**    * Query to see if current memory bank is read/write.    *    * @return  'true' if current memory bank is read/write    */   public boolean isReadWrite ()   {      return readWrite;   }   /**    * Query to see if current memory bank is write write once such    * as with EPROM technology.    *    * @return  'true' if current memory bank can only be written once    */   public boolean isWriteOnce ()   {      return writeOnce;   }   /**    * Query to see if current memory bank is read only.    *    * @return  'true' if current memory bank can only be read    */   public boolean isReadOnly ()   {      return readOnly;   }   /**    * Query to see if current memory bank non-volatile.  Memory is    * non-volatile if it retains its contents even when removed from    * the 1-Wire network.    *    * @return  'true' if current memory bank non volatile.    */   public boolean isNonVolatile ()   {      return true;   }  /**    * Query to see if current memory bank pages need the adapter to    * have a 'ProgramPulse' in order to write to the memory.    *    * @return  'true' if writing to the current memory bank pages    *                 requires a 'ProgramPulse'.    */   public boolean needsProgramPulse ()   {      return false;   }   /**    * Query to see if current memory bank pages need the adapter to    * have a 'PowerDelivery' feature in order to write to the memory.    *    * @return  'true' if writing to the current memory bank pages    *                 requires 'PowerDelivery'.    */   public boolean needsPowerDelivery ()   {      return true;   }   /**    * Query to get the starting physical address of this bank.  Physical    * banks are sometimes sub-divided into logical banks due to changes    * in attributes.    *    * @return  physical starting address of this logical bank.    */   public int getStartPhysicalAddress ()   {      return startPhysicalAddress;   }   /**    * Query to get the memory bank size in bytes.    *    * @return  memory bank size in bytes.    */   public int getSize ()   {      return size;   }   /**    * Set the write verification for the 'write()' method.    *    * @param  doReadVerf   true (default) verify write in 'write'    *                      false, don't verify write (used on    *                      Write-Once bit manipulation)    */   public void setWriteVerification (boolean doReadVerf)   {      writeVerification = doReadVerf;   }   /**    * Query to get the number of pages in current memory bank.    *    * @return  number of pages in current memory bank    */   public int getNumberPages ()   {      return numberPages;   }   /**    * Query to get  page length in bytes in current memory bank.    *    * @return   page length in bytes in current memory bank    */   public int getPageLength ()   {      return pageLength;   }   /**    * Query to see if current memory bank pages can be read with    * the contents being verified by a device generated CRC.    * This is used to see if the 'ReadPageCRC()' can be used.    *    * @return  'true' if current memory bank can be read with self    *          generated CRC.    */   public boolean hasPageAutoCRC ()   {      return pageCRC;   }   /**    * Query to see if current memory bank pages when read deliver    * extra information outside of the normal data space.  Examples    * of this may be a redirection byte, counter, tamper protection    * bytes, or SHA-1 result.  If this method returns true then the    * methods 'ReadPagePacket()' and 'readPageCRC()' with 'extraInfo'    * parameter can be used.    *    * @return  'true' if reading the current memory bank pages    *                 provides extra information.    *    * @deprecated  As of 1-Wire API 0.01, replaced by {@link #hasExtraInfo()}    */   public boolean haveExtraInfo ()   {      return extraInfo;   }   /**    * Checks to see if this memory bank's pages deliver extra    * information outside of the normal data space,  when read.  Examples    * of this may be a redirection byte, counter, tamper protection

⌨️ 快捷键说明

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