com.dalsemi.onewire.container
Interface PagedMemoryBank

All Superinterfaces:
MemoryBank
All Known Subinterfaces:
OTPMemoryBank

public interface PagedMemoryBank
extends MemoryBank

Paged Memory bank interface for iButtons (or 1-Wire devices) with page based memory. This class should be implemented for each applicable memory bank.

Version:
0.00, 28 Aug 2000

Method Summary
 java.lang.String getExtraInfoDescription()
          Query to get a string description of what is contained in the Extra Informationed return when reading pages in the current memory bank.
 int getExtraInfoLength()
          Query to get the length in bytes of extra information that is read when read a page in the current memory bank.
 int getMaxPacketDataLength()
          Query to get Maximum data page length in bytes for a packet read or written in the current memory bank.
 int getNumberPages()
          Query to get the number of pages in current memory bank.
 int getPageLength()
          Query to get raw page length in bytes in current memory bank.
 boolean hasPageAutoCRC()
          Query to see if current memory bank pages can be read with the contents being verified by a device generated CRC.
 boolean haveExtraInfo()
          Query to see if current memory bank pages when read deliver extra information outside of the normal data space.
 void readPage(int page, boolean readContinue, byte[] readBuf, int offset)
          Read page in the current bank with no CRC checking (device or data).
 void readPage(int page, boolean readContinue, byte[] readBuf, int offset, byte[] extraInfo)
          Read page with extra information in the current bank with no CRC checking (device or data).
 void readPageCRC(int page, boolean readContinue, byte[] readBuf, int offset)
          Read a complete memory page with CRC verification provided by the device.
 void readPageCRC(int page, boolean readContinue, byte[] readBuf, int offset, byte[] extraInfo)
          Read a complete memory page with CRC verification provided by the device with extra information.
 int readPagePacket(int page, boolean readContinue, byte[] readBuf, int offset)
          Read a Universal Data Packet.
 int readPagePacket(int page, boolean readContinue, byte[] readBuf, int offset, byte[] extraInfo)
          Read a Universal Data Packet and extra information.
 void writePagePacket(int page, byte[] writeBuf, int offset, int len)
          Write a Universal Data Packet.
 
Methods inherited from interface com.dalsemi.onewire.container.MemoryBank
getBankDescription, getSize, getStartPhysicalAddress, isGeneralPurposeMemory, isNonVolatile, isReadOnly, isReadWrite, isWriteOnce, needsPowerDelivery, needsProgramPulse, read, setWriteVerification, write
 

Method Detail

getNumberPages

public int getNumberPages()
Query to get the number of pages in current memory bank.
Returns:
number of pages in current memory bank

getPageLength

public int getPageLength()
Query to get raw page length in bytes in current memory bank.
Returns:
page length in bytes in current memory bank

getMaxPacketDataLength

public int getMaxPacketDataLength()
Query to get Maximum data page length in bytes for a packet read or written in the current memory bank. See the 'ReadPagePacket()' and 'WritePagePacket()' methods. This method is only usefull if the current memory bank is general purpose memory.
Returns:
max packet page length in bytes in current memory bank

hasPageAutoCRC

public boolean hasPageAutoCRC()
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.
Returns:
'true' if current memory bank can be read with self generated CRC.

haveExtraInfo

public boolean haveExtraInfo()
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.
Returns:
'true' if reading the current memory bank pages provides extra information.

getExtraInfoLength

public int getExtraInfoLength()
Query to get the length in bytes of extra information that is read when read a page in the current memory bank. See 'haveExtraInfo()'.
Returns:
number of bytes in Extra Information read when reading pages in the current memory bank.

getExtraInfoDescription

public java.lang.String getExtraInfoDescription()
Query to get a string description of what is contained in the Extra Informationed return when reading pages in the current memory bank. See 'haveExtraInfo()'.
Returns:
string describing extra information.

readPage

public void readPage(int page,
                     boolean readContinue,
                     byte[] readBuf,
                     int offset)
              throws OneWireIOException,
                     OneWireException
Read page in the current bank with no CRC checking (device or data). The resulting data from this API may or may not be what is on the 1-Wire device. It is recommends that the data contain some kind of checking (CRC) like in the readPagePacket() method or have the 1-Wire device provide the CRC as in readPageCRC(). readPageCRC() however is not supported on all memory types, see 'hasPageAutoCRC()'. If neither is an option then this method could be called more then once to at least verify that the same thing is read consistantly.
Parameters:
page - page number to read packet from
readContinue - if 'true' then device read is continued without re-selecting. This can only be used if the new readPage() continious where the last one led off and it is inside a 'beginExclusive/endExclusive' block.
readBuf - byte array to place read data into
offset - offset into readBuf to place data
Throws:
OneWireIOException -  
OneWireException -  

readPage

public void readPage(int page,
                     boolean readContinue,
                     byte[] readBuf,
                     int offset,
                     byte[] extraInfo)
              throws OneWireIOException,
                     OneWireException
Read page with extra information in the current bank with no CRC checking (device or data). The resulting data from this API may or may not be what is on the 1-Wire device. It is recommends that the data contain some kind of checking (CRC) like in the readPagePacket() method or have the 1-Wire device provide the CRC as in readPageCRC(). readPageCRC() however is not supported on all memory types, see 'hasPageAutoCRC()'. If neither is an option then this method could be called more then once to at least verify that the same thing is read consistantly. See the method 'haveExtraInfo()' for a description of the optional extra information some devices have.
Parameters:
page - page number to read packet from
readContinue - if 'true' then device read is continued without re-selecting. This can only be used if the new readPage() continious where the last one led off and it is inside a 'beginExclusive/endExclusive' block.
readBuf - byte array to place read data into
offset - offset into readBuf to place data
extraInfo - byte array to put extra info read into
Throws:
OneWireIOException -  
OneWireException -  

readPagePacket

public int readPagePacket(int page,
                          boolean readContinue,
                          byte[] readBuf,
                          int offset)
                   throws OneWireIOException,
                          OneWireException
Read a Universal Data Packet. The Universal Data Packet always starts on page boundaries but can end anywhere in the page. The structure specifies the length of data bytes not including the length byte and the CRC16 bytes. There is one length byte. The CRC16 is first initialized to the page number. This provides a check to verify the page that was intended is being read. The CRC16 is then calculated over the length and data bytes. The CRC16 is then inverted and stored low byte first followed by the high byte. This is structure is used by this method to verify the data but is not returned, only the data payload is returned.
Parameters:
page - page number to read packet from
readContinue - if 'true' then device read is continued without re-selecting. This can only be used if the new readPagePacket() continious where the last one stopped and it is inside a 'beginExclusive/endExclusive' block.
readBuf - byte array to put data read. Must have at least 'getMaxPacketDataLength()' elements.
offset - offset into readBuf to place data
Returns:
number of data bytes read from the device and written to readBuf at the offset.
Throws:
OneWireIOException -  
OneWireException -  

readPagePacket

public int readPagePacket(int page,
                          boolean readContinue,
                          byte[] readBuf,
                          int offset,
                          byte[] extraInfo)
                   throws OneWireIOException,
                          OneWireException
Read a Universal Data Packet and extra information. See the method 'readPagePacket()' for a description of the packet structure. See the method 'haveExtraInfo()' for a description of the optional extra information some devices have.
Parameters:
page - page number to read packet from
readContinue - if 'true' then device read is continued without re-selecting. This can only be used if the new readPagePacket() continious where the last one stopped and it is inside a 'beginExclusive/endExclusive' block.
readBuf - byte array to put data read. Must have at least 'getMaxPacketDataLength()' elements.
offset - offset into readBuf to place data
extraInfo - byte array to put extra info read into
Returns:
number of data bytes read from the device and written to readBuf at the offset.
Throws:
OneWireIOException -  
OneWireException -  

writePagePacket

public void writePagePacket(int page,
                            byte[] writeBuf,
                            int offset,
                            int len)
                     throws OneWireIOException,
                            OneWireException
Write a Universal Data Packet. See the method 'readPagePacket()' for a description of the packet structure.
Parameters:
page - page number to write packet to
writeBuf - data byte array to write
offset - offset into writeBuf where data to write is
len - number of bytes to write
Throws:
OneWireIOException -  
OneWireException -  

readPageCRC

public void readPageCRC(int page,
                        boolean readContinue,
                        byte[] readBuf,
                        int offset)
                 throws OneWireIOException,
                        OneWireException
Read a complete memory page with CRC verification provided by the device. Not supported by all devices. See the method 'hasPageAutoCRC()'.
Parameters:
page - page number to read
readContinue - if 'true' then device read is continued without re-selecting. This can only be used if the new readPagePacket() continious where the last one stopped and it is inside a 'beginExclusive/endExclusive' block.
readBuf - byte array to put data read. Must have at least 'getMaxPacketDataLength()' elements.
offset - offset into readBuf to place data
Throws:
OneWireIOException -  
OneWireException -  

readPageCRC

public void readPageCRC(int page,
                        boolean readContinue,
                        byte[] readBuf,
                        int offset,
                        byte[] extraInfo)
                 throws OneWireIOException,
                        OneWireException
Read a complete memory page with CRC verification provided by the device with extra information. Not supported by all devices. See the method 'hasPageAutoCRC()'. See the method 'haveExtraInfo()' for a description of the optional extra information.
Parameters:
page - page number to read
readContinue - if 'true' then device read is continued without re-selecting. This can only be used if the new readPagePacket() continious where the last one stopped and it is inside a 'beginExclusive/endExclusive' block.
readBuf - byte array to put data read. Must have at least 'getMaxPacketDataLength()' elements.
offset - offset into readBuf to place data
extraInfo - byte array to put extra info read into
Throws:
OneWireIOException -  
OneWireException -