1-Wire API for .NET Version 4.00
Public Member Functions | Static Public Attributes | Protected Attributes

MemoryBankNV Class Reference

Memory bank class for the NVRAM section of iButtons and 1-Wire devices. More...

Inherits com::dalsemi::onewire::container::PagedMemoryBank.

Inherited by MemoryBankNVCRC.

List of all members.

Public Member Functions

 MemoryBankNV (OneWireContainer ibutton, ScratchPad scratch)
 Memory bank contstuctor.
String getBankDescription ()
 Query to see get a string description of the current memory bank.
boolean isGeneralPurposeMemory ()
 Query to see if the current memory bank is general purpose user memory.
boolean isReadWrite ()
 Query to see if current memory bank is read/write.
boolean isWriteOnce ()
 Query to see if current memory bank is write write once such as with EPROM technology.
boolean isReadOnly ()
 Query to see if current memory bank is read only.
boolean isNonVolatile ()
 Query to see if current memory bank non-volatile.
boolean needsProgramPulse ()
 Query to see if current memory bank pages need the adapter to have a 'ProgramPulse' in order to write to the memory.
boolean needsPowerDelivery ()
 Query to see if current memory bank pages need the adapter to have a 'PowerDelivery' feature in order to write to the memory.
int getStartPhysicalAddress ()
 Query to get the starting physical address of this bank.
int getSize ()
 Query to get the memory bank size in bytes.
void setWriteVerification (boolean doReadVerf)
 Set the write verification for the 'write()' method.
int getNumberPages ()
 Query to get the number of pages in current memory bank.
int getPageLength ()
 Query to get page length in bytes in 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.
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.
boolean hasExtraInfo ()
 Checks to see if this memory bank's pages deliver extra information outside of the normal data space, when read.
int getExtraInfoLength ()
 Query to get the length in bytes of extra information that is read when read a page in the current memory bank.
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.
void read (int startAddr, boolean readContinue, byte[] readBuf, int offset, int len) throws OneWireIOException, OneWireException
 Read memory in the current bank with no CRC checking (device or data).
void write (int startAddr, byte[] writeBuf, int offset, int len) throws OneWireIOException, OneWireException
 Write memory in the current bank.
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).
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).
int readPagePacket (int page, boolean readContinue, byte[] readBuf, int offset) throws OneWireIOException, OneWireException
 Read a Universal Data Packet.
int readPagePacket (int page, boolean readContinue, byte[] readBuf, int offset, byte[] extraInfo) throws OneWireIOException, OneWireException
 Read a Universal Data Packet and extra information.
void writePagePacket (int page, byte[] writeBuf, int offset, int len) throws OneWireIOException, OneWireException
 Write a Universal Data Packet.
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.
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.

Static Public Attributes

static final byte READ_MEMORY_COMMAND = ( byte ) 0xF0
 Read Memory Command.

Protected Attributes

ScratchPad sp
 ScratchPad memory bank.
OneWireContainer ib
 Reference to the OneWireContainer this bank resides on.
byte[] ffBlock
 block of 0xFF's used for faster read pre-fill of 1-Wire blocks
int size
 Size of memory bank in bytes.
String bankDescription
 Memory bank descriptions.
boolean generalPurposeMemory
 Memory bank usage flags.
boolean readWrite
 Flag if memory bank is read/write.
boolean writeOnce
 Flag if memory bank is write once (EPROM)
boolean readOnly
 Flag if memory bank is read only.
boolean nonVolatile
 Flag if memory bank is non volatile (will not erase when power removed)
boolean programPulse
 Flag if memory bank needs program Pulse to write.
boolean powerDelivery
 Flag if memory bank needs power delivery to write.
int startPhysicalAddress
 Starting physical address in memory bank.
boolean writeVerification
 Flag if read back verification is enabled in 'write()'.
int numberPages
 Number of pages in memory bank.
int pageLength
 page length in memory bank
int maxPacketDataLength
 Max data length in page packet in memory bank.
boolean pageAutoCRC
 Flag if memory bank has page auto-CRC generation.
boolean extraInfo
 Flag if reading a page in memory bank provides optional extra information (counter, tamper protection, SHA-1...)
int extraInfoLength
 Length of extra information when reading a page in memory bank.
String extraInfoDescription
 Extra information descriptoin when reading page in memory bank.

Detailed Description

Memory bank class for the NVRAM section of iButtons and 1-Wire devices.

Version:
0.01, 11 Dec 2000
Author:
DS

Constructor & Destructor Documentation

MemoryBankNV ( OneWireContainer  ibutton,
ScratchPad  scratch 
)

Memory bank contstuctor.

Requires reference to the OneWireContainer this memory bank resides on. DEFAULT: DS1993 main memory

Parameters:
ibuttonibutton container that this memory bank resides in
scratchPadmemory bank referece for scratchpad, used when writing

Member Function Documentation

String getBankDescription ( )

Query to see get a string description of the current memory bank.

Returns:
String containing the memory bank description

Implements MemoryBank.

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 'hasExtraInfo()'.

Returns:
string describing extra information.

Implements PagedMemoryBank.

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 'hasExtraInfo()'.

Returns:
number of bytes in Extra Information read when reading pages in the current memory bank.

Implements PagedMemoryBank.

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

Implements PagedMemoryBank.

int getNumberPages ( )

Query to get the number of pages in current memory bank.

Returns:
number of pages in current memory bank

Implements PagedMemoryBank.

int getPageLength ( )

Query to get page length in bytes in current memory bank.

Returns:
page length in bytes in current memory bank

Implements PagedMemoryBank.

int getSize ( )

Query to get the memory bank size in bytes.

Returns:
memory bank size in bytes.

Implements MemoryBank.

int getStartPhysicalAddress ( )

Query to get the starting physical address of this bank.

Physical banks are sometimes sub-divided into logical banks due to changes in attributes.

Returns:
physical starting address of this logical bank.

Implements MemoryBank.

boolean hasExtraInfo ( )

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 bytes, or SHA-1 result. If this method returns true then the methods with an 'extraInfo' parameter can be used: readPage, readPageCRC, and readPagePacket.

Returns:
true if reading the this memory bank's pages provides extra information
See also:
readPage(int,boolean,byte[],int,byte[]) readPage(extra)
readPageCRC(int,boolean,byte[],int,byte[]) readPageCRC(extra)
readPagePacket(int,boolean,byte[],int,byte[]) readPagePacket(extra)
Since:
1-Wire API 0.01

Implements PagedMemoryBank.

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.

Implements PagedMemoryBank.

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.
Deprecated:
As of 1-Wire API 0.01, replaced by hasExtraInfo()

Implements PagedMemoryBank.

boolean isGeneralPurposeMemory ( )

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.

Returns:
'true' if current memory bank is general purpose

Implements MemoryBank.

boolean isNonVolatile ( )

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.

Returns:
'true' if current memory bank non volatile.

Implements MemoryBank.

boolean isReadOnly ( )

Query to see if current memory bank is read only.

Returns:
'true' if current memory bank can only be read

Implements MemoryBank.

boolean isReadWrite ( )

Query to see if current memory bank is read/write.

Returns:
'true' if current memory bank is read/write

Implements MemoryBank.

boolean isWriteOnce ( )

Query to see if current memory bank is write write once such as with EPROM technology.

Returns:
'true' if current memory bank can only be written once

Implements MemoryBank.

boolean needsPowerDelivery ( )

Query to see if current memory bank pages need the adapter to have a 'PowerDelivery' feature in order to write to the memory.

Returns:
'true' if writing to the current memory bank pages requires 'PowerDelivery'.

Implements MemoryBank.

boolean needsProgramPulse ( )

Query to see if current memory bank pages need the adapter to have a 'ProgramPulse' in order to write to the memory.

Returns:
'true' if writing to the current memory bank pages requires a 'ProgramPulse'.

Implements MemoryBank.

void read ( int  startAddr,
boolean  readContinue,
byte[]  readBuf,
int  offset,
int  len 
) throws OneWireIOException, OneWireException

Read memory 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:
startAddrstarting physical address
readContinueif 'true' then device read is continued without re-selecting. This can only be used if the new read() continious where the last one led off and it is inside a 'beginExclusive/endExclusive' block.
readBufbyte array to place read data into
offsetoffset into readBuf to place data
lenlength in bytes to read
Exceptions:
OneWireIOException
OneWireException

Implements MemoryBank.

Reimplemented in MemoryBankNVCRCPW.

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:
pagepage number to read packet from
readContinueif '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.
readBufbyte array to place read data into
offsetoffset into readBuf to place data
Exceptions:
OneWireIOException
OneWireException

Implements PagedMemoryBank.

Reimplemented in MemoryBankNVCRC.

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 'hasExtraInfo()' for a description of the optional extra information some devices have.

Parameters:
pagepage number to read packet from
readContinueif '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.
readBufbyte array to place read data into
offsetoffset into readBuf to place data
extraInfobyte array to put extra info read into
Exceptions:
OneWireIOException
OneWireException

Implements PagedMemoryBank.

Reimplemented in MemoryBankNVCRC.

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 'hasExtraInfo()' for a description of the optional extra information.

Parameters:
pagepage number to read
readContinueif '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.
readBufbyte array to put data read. Must have at least 'getMaxPacketDataLength()' elements.
offsetoffset into readBuf to place data
extraInfobyte array to put extra info read into
Exceptions:
OneWireIOException
OneWireException

Implements PagedMemoryBank.

Reimplemented in MemoryBankNVCRC, and MemoryBankNVCRCPW.

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:
pagepage number to read
readContinueif '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.
readBufbyte array to put data read. Must have at least 'getMaxPacketDataLength()' elements.
offsetoffset into readBuf to place data
Exceptions:
OneWireIOException
OneWireException

Implements PagedMemoryBank.

Reimplemented in MemoryBankNVCRC.

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 'hasExtraInfo()' for a description of the optional extra information some devices have.

Parameters:
pagepage number to read packet from
readContinueif '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.
readBufbyte array to put data read. Must have at least 'getMaxPacketDataLength()' elements.
offsetoffset into readBuf to place data
extraInfobyte array to put extra info read into
Returns:
number of data bytes read from the device and written to readBuf at the offset.
Exceptions:
OneWireIOException
OneWireException

Implements PagedMemoryBank.

Reimplemented in MemoryBankNVCRC.

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:
pagepage number to read packet from
readContinueif '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.
readBufbyte array to put data read. Must have at least 'getMaxPacketDataLength()' elements.
offsetoffset into readBuf to place data
Returns:
number of data bytes read from the device and written to readBuf at the offset.
Exceptions:
OneWireIOException
OneWireException

Implements PagedMemoryBank.

void setWriteVerification ( boolean  doReadVerf)

Set the write verification for the 'write()' method.

Parameters:
doReadVerftrue (default) verify write in 'write' false, don't verify write (used on Write-Once bit manipulation)

Implements MemoryBank.

void write ( int  startAddr,
byte[]  writeBuf,
int  offset,
int  len 
) throws OneWireIOException, OneWireException

Write memory in the current bank.

It is recommended that when writing data that some structure in the data is created to provide error free reading back with read(). Or the method 'writePagePacket()' could be used which automatically wraps the data in a length and CRC.

When using on Write-Once devices care must be taken to write into into empty space. If write() is used to write over an unlocked page on a Write-Once device it will fail. If write verification is turned off with the method 'setWriteVerification(false)' then the result will be an 'AND' of the existing data and the new data.

Parameters:
startAddrstarting address
writeBufbyte array containing data to write
offsetoffset into writeBuf to get data
lenlength in bytes to write
Exceptions:
OneWireIOException
OneWireException

Implements MemoryBank.

Reimplemented in MemoryBankNVCRCPW.

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:
pagepage number to write packet to
writeBufdata byte array to write
offsetoffset into writeBuf where data to write is
lennumber of bytes to write
Exceptions:
OneWireIOException
OneWireException

Implements PagedMemoryBank.


Member Data Documentation

int startPhysicalAddress [protected]

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.


The documentation for this class was generated from the following file: