1-Wire API for .NET Version 4.00
|
Memory bank class for the EPROM section of iButtons and 1-Wire devices. More...
Inherits com::dalsemi::onewire::container::OTPMemoryBank.
Public Member Functions | |
MemoryBankAppReg (OneWireContainer ibutton) | |
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. | |
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 | setWriteVerification (boolean doReadVerf) |
Set the write verification for the 'write()' method. | |
boolean | canRedirectPage () |
Query to see if current memory bank pages can be redirected to another pages. | |
boolean | canLockPage () |
Query to see if current memory bank pages can be locked. | |
boolean | canLockRedirectPage () |
Query to see if current memory bank pages can be locked from being redirected. | |
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, byte[] extraInfo) throws OneWireIOException, OneWireException |
Read a Universal Data Packet and extra information. | |
int | readPagePacket (int page, boolean readContinue, byte[] readBuf, int offset) 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. | |
void | lockPage (int page) throws OneWireIOException, OneWireException |
Lock the specifed page in the current memory bank. | |
boolean | isPageLocked (int page) throws OneWireIOException, OneWireException |
Query to see if the specified page is locked. | |
void | redirectPage (int page, int newPage) throws OneWireIOException, OneWireException |
Redirect the specifed page in the current memory bank to a new page. | |
int | isPageRedirected (int page) throws OneWireIOException, OneWireException |
Query to see if the specified page is redirected. | |
int | getRedirectedPage (int page) throws OneWireIOException, OneWireException |
Gets the page redirection of the specified page. | |
void | lockRedirectPage (int page) throws OneWireIOException, OneWireException |
Lock the redirection option for the specifed page in the current memory bank. | |
boolean | isRedirectPageLocked (int page) throws OneWireIOException, OneWireException |
Query to see if the specified page has redirection locked. | |
Static Public Attributes | |
static final int | PAGE_SIZE = 8 |
Memory page size. | |
static final int | COPY_DELAY_LEN = 10 |
Copy Scratchpad Delay length. | |
static final byte | READ_MEMORY_COMMAND = ( byte ) 0xC3 |
Read Memory Command. | |
static final byte | WRITE_MEMORY_COMMAND = ( byte ) 0x99 |
Main memory write command. | |
static final byte | COPY_LOCK_COMMAND = ( byte ) 0x5A |
Copy/Lock command. | |
static final byte | READ_STATUS_COMMAND = ( byte ) 0x66 |
Copy/Lock command. | |
static final byte | VALIDATION_KEY = ( byte ) 0xA5 |
Copy/Lock validation key. | |
static final byte | LOCKED_FLAG = ( byte ) 0xFC |
Flag in status register indicated the page is locked. | |
Protected Member Functions | |
void | readStatus (byte[] readBuf) throws OneWireIOException, OneWireException |
Read the status register for this memory bank. | |
byte | readStatus () throws OneWireIOException, OneWireException |
Read the status register for this memory bank. | |
Protected Attributes | |
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. | |
boolean | writeVerification |
Flag if read back verification is enabled in 'write()'. | |
int | extraInfoLength |
Length of extra information when reading a page in memory bank. | |
Static Protected Attributes | |
static String | bankDescription = "Application register, non-volatile when locked" |
Memory bank descriptions. | |
static String | extraInfoDescription = "Page Locked flag" |
Extra information descriptoin when reading page in memory bank. |
Memory bank class for the EPROM section of iButtons and 1-Wire devices.
MemoryBankAppReg | ( | OneWireContainer | ibutton | ) |
Memory bank contstuctor.
Requires reference to the OneWireContainer this memory bank resides on. Requires reference to memory banks used in OTP operations.
boolean canLockPage | ( | ) |
Query to see if current memory bank pages can be locked.
A locked page would prevent any changes to the memory.
Implements OTPMemoryBank.
boolean canLockRedirectPage | ( | ) |
Query to see if current memory bank pages can be locked from being redirected.
This would prevent a Write-Once memory from being updated.
Implements OTPMemoryBank.
boolean canRedirectPage | ( | ) |
Query to see if current memory bank pages can be redirected to another pages.
This is mostly used in Write-Once memory to provide a means to update.
Implements OTPMemoryBank.
String getBankDescription | ( | ) |
Query to see get a string description of the current memory bank.
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()'.
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()'.
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.
Implements PagedMemoryBank.
int getNumberPages | ( | ) |
Query to get the number of pages in current memory bank.
Implements PagedMemoryBank.
int getPageLength | ( | ) |
Query to get page length in bytes in current memory bank.
Implements PagedMemoryBank.
int getRedirectedPage | ( | int | page | ) | throws OneWireIOException, OneWireException |
Gets the page redirection of the specified page.
Not supported by all devices.
page | page to check for redirection |
OneWireIOException | on a 1-Wire communication error such as no device present or a CRC read from the device is incorrect. 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'. |
OneWireException | on a communication or setup error with the 1-Wire adapter. |
Implements OTPMemoryBank.
int getSize | ( | ) |
Query to get the 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.
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.
true
if reading the this memory bank's pages provides extra informationImplements 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.
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.
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.
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.
Implements MemoryBank.
boolean isPageLocked | ( | int | page | ) | throws OneWireIOException, OneWireException |
Query to see if the specified page is locked.
See the method 'canLockPage()'.
page | number of page to see if locked |
OneWireIOException | |
OneWireException |
Implements OTPMemoryBank.
int isPageRedirected | ( | int | page | ) | throws OneWireIOException, OneWireException |
Query to see if the specified page is redirected.
Not supported by all devices. See the method 'canRedirectPage()'.
page | number of page check for redirection |
OneWireIOException | |
OneWireException |
Implements OTPMemoryBank.
boolean isReadOnly | ( | ) |
Query to see if current memory bank is read only.
Implements MemoryBank.
boolean isReadWrite | ( | ) |
Query to see if current memory bank is read/write.
Implements MemoryBank.
boolean isRedirectPageLocked | ( | int | page | ) | throws OneWireIOException, OneWireException |
Query to see if the specified page has redirection locked.
Not supported by all devices. See the method 'canRedirectPage()'.
page | number of page check for locked redirection |
OneWireIOException | |
OneWireException |
Implements OTPMemoryBank.
boolean isWriteOnce | ( | ) |
Query to see if current memory bank is write write once such as with EPROM technology.
Implements MemoryBank.
void lockPage | ( | int | page | ) | throws OneWireIOException, OneWireException |
Lock the specifed page in the current memory bank.
Not supported by all devices. See the method 'canLockPage()'.
page | number of page to lock |
OneWireIOException | |
OneWireException |
Implements OTPMemoryBank.
void lockRedirectPage | ( | int | page | ) | throws OneWireIOException, OneWireException |
Lock the redirection option for the specifed page in the current memory bank.
Not supported by all devices. See the method 'canLockRedirectPage()'.
page | number of page to redirect |
OneWireIOException | |
OneWireException |
Implements OTPMemoryBank.
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.
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.
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.
startAddr | starting physical address |
readContinue | if '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. |
readBuf | byte array to place read data into |
offset | offset into readBuf to place data |
len | length in bytes to read |
OneWireIOException | |
OneWireException |
Implements MemoryBank.
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.
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 |
OneWireIOException | |
OneWireException |
Implements PagedMemoryBank.
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.
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 |
OneWireIOException | |
OneWireException |
Implements PagedMemoryBank.
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()'.
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 |
OneWireIOException | |
OneWireException |
Implements PagedMemoryBank.
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.
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 |
OneWireIOException | |
OneWireException |
Implements PagedMemoryBank.
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.
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 |
OneWireIOException | |
OneWireException |
Implements PagedMemoryBank.
int readPagePacket | ( | int | page, |
boolean | readContinue, | ||
byte[] | readBuf, | ||
int | offset | ||
) | 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.
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 |
OneWireIOException | |
OneWireException |
Implements PagedMemoryBank.
void readStatus | ( | byte[] | readBuf | ) | throws OneWireIOException, OneWireException [protected] |
Read the status register for this memory bank.
readBuf | byte array to put data read. Must have at least 'getExtraInfoLength()' elements. |
OneWireIOException | |
OneWireException |
byte readStatus | ( | ) | throws OneWireIOException, OneWireException [protected] |
Read the status register for this memory bank.
OneWireIOException | |
OneWireException |
void redirectPage | ( | int | page, |
int | newPage | ||
) | throws OneWireIOException, OneWireException |
Redirect the specifed page in the current memory bank to a new page.
Not supported by all devices. See the method 'canRedirectPage()'.
page | number of page to redirect |
newPage | new page number to redirect to |
OneWireIOException | |
OneWireException |
Implements OTPMemoryBank.
void setWriteVerification | ( | boolean | doReadVerf | ) |
Set the write verification for the 'write()' method.
doReadVerf | true (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.
startAddr | starting address |
writeBuf | byte array containing data to write |
offset | offset into writeBuf to get data |
len | length in bytes to write |
OneWireIOException | |
OneWireException |
Implements MemoryBank.
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.
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 |
OneWireIOException | |
OneWireException |
Implements PagedMemoryBank.