|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Memory bank interface class for basic memory communication with
iButtons (or 1-Wire devices). The method getMemoryBanks
in all 1-Wire Containers (OneWireContainer
)
returns an Enumeration of this interface to be used to read or write it's
memory. If the 1-Wire device does not have memory or the memory is non-standard,
then this enumeration may be empty.
A MemoryBank returned from this method may also implement the
PagedMemoryBank
,
or OTPMemoryBank
interfaces,
to provide additional functionality.
The MemoryBank methods can be organized into the following categories:
if (mb.isWriteOnce())
System.out.println("MemoryBank is write-once");
if (mb.needsProgramPulse())
System.out.println("MemoryBank requires program-pulse to write");
byte[] write_buf = new byte[mb.getSize()];
for (int i = 0; i < write_buf.length; i++)
write_buf[i] = (byte)0;
mb.write(0, write_buf, 0, write_buf.length);
byte[] read_buf = new byte[mb.getSize()];
mb.read(0, false, read_buf, 0, read_buf.length);
PagedMemoryBank
,
OTPMemoryBank
,
OneWireContainer04
,
OneWireContainer06
,
OneWireContainer08
,
OneWireContainer09
,
OneWireContainer0A
,
OneWireContainer0B
,
OneWireContainer0C
,
OneWireContainer0F
,
OneWireContainer12
,
OneWireContainer13
,
OneWireContainer14
,
OneWireContainer18
,
OneWireContainer1A
,
OneWireContainer1D
,
OneWireContainer20
,
OneWireContainer21
,
OneWireContainer23
Method Summary | |
String |
getBankDescription()
Gets a string description of this memory bank. |
int |
getSize()
Gets the size of this memory bank in bytes. |
int |
getStartPhysicalAddress()
Gets the starting physical address of this bank. |
boolean |
isGeneralPurposeMemory()
Checks to see if this memory bank is general purpose user memory. |
boolean |
isNonVolatile()
Checks to see if this memory bank is non-volatile. |
boolean |
isReadOnly()
Checks to see if this memory bank is read only. |
boolean |
isReadWrite()
Checks to see if this memory bank is read/write. |
boolean |
isWriteOnce()
Checks to see if this memory bank is write once such as with EPROM technology. |
boolean |
needsPowerDelivery()
Checks to see if this memory bank requires 'PowerDelivery' in order to write. |
boolean |
needsProgramPulse()
Checks to see if this memory bank requires a 'ProgramPulse' in order to write. |
void |
read(int startAddr,
boolean readContinue,
byte[] readBuf,
int offset,
int len)
Reads memory in this bank with no CRC checking (device or data). |
void |
setWriteVerification(boolean doReadVerf)
Sets or clears write verification for the write method. |
void |
write(int startAddr,
byte[] writeBuf,
int offset,
int len)
Writes memory in this bank. |
Method Detail |
public String getBankDescription()
public boolean isGeneralPurposeMemory()
true
if this memory bank is general purposepublic int getSize()
public boolean isReadWrite()
true
if this memory bank is read/writepublic boolean isWriteOnce()
true
if this memory bank can only be written oncepublic boolean isReadOnly()
true
if this memory bank can only be readpublic boolean isNonVolatile()
true
if this memory bank is non volatilepublic boolean needsProgramPulse()
true
if writing to this memory bank
requires a 'ProgramPulse' from the 1-Wire Adapter.DSPortAdapter
public boolean needsPowerDelivery()
true
if writing to this memory bank
requires 'PowerDelivery' from the 1-Wire AdapterDSPortAdapter
public int getStartPhysicalAddress()
public void setWriteVerification(boolean doReadVerf)
write
method.doReadVerf
- true
(default)
verify write in 'write',
false
don't verify write (used on
Write-Once bit manipulation)OTPMemoryBank
public void read(int startAddr, boolean readContinue, byte[] readBuf, int offset, int len) throws OneWireIOException, OneWireException
readPagePacket
method in
the
PagedMemoryBank
interface. Some 1-Wire devices provide thier own CRC as in
readPageCRC
also found in the
PagedMemoryBank
interface. The readPageCRC
method
is not supported on all memory types, see hasPageAutoCRC
in the same interface.
If neither is an option then this method could be called more
then once to at least verify that the same data is read consistently. The
readContinue parameter is used to eliminate the overhead in re-accessing
a part already being read from. For example, if pages 0 - 4 are to
be read, readContinue would be set to false for page 0 and would be set
to true for the next four calls.
Note: Using readContinue = true can only be used if the new read continuous where the last one led off and it is inside a 'beginExclusive/endExclusive' block.
startAddr
- starting addressreadContinue
- true
then device read is
continued without re-selectingreadBuf
- location for data readoffset
- offset into readBuf to place datalen
- length in bytes to readOneWireIOException
- on a 1-Wire communication error such as
no device present. 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
adapterpublic void write(int startAddr, byte[] writeBuf, int offset, int len) throws OneWireIOException, OneWireException
writePagePacket
found in the
PagedMemoryBank
interface, which automatically wraps the data in a length and CRC, could
be used for this purpose.
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 addresswriteBuf
- data to writeoffset
- offset into writeBuf to get datalen
- length in bytes to writeOneWireIOException
- on a 1-Wire communication error such as
no device present or a read back verification fails. 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |