|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Paged Memory bank interface for iButtons (or 1-Wire devices) with page
based memory. This interface extents the base functionality of
the super-interface MemoryBank
by providing paged based services.
This interface has methods to read and write a packet structure called the UDP (Universal Data Packet). This structure has a length byte, data, and an inverted CRC16. See Dallas Semiconductor Application Note 114 for details: http://dbserv.maxim-ic.com/appnotes.cfm?appnote_number=114
The MemoryBank methods can be organized into the following categories:
System.out.print("PagedMemoryBank has: " + pmb.getNumberPages() + " pages of length ");
System.out.print(pbank.getPageLength() + " bytes ");
if (bank.isGeneralPurposeMemory())
System.out.print("giving " + pbank.getMaxPacketDataLength() + " bytes Packet data payload");
System.out.println();
if (pbank.hasPageAutoCRC())
System.out.print("PagedMemoryBank has device generated CRC");
byte[] write_buf = new byte[pmb.getMaxPacketDataLength()];
for (int i = 0; i < write_buf.length; i++)
write_buf[i] = (byte)0;
mb.writePagePacket(0, write_buf, 0, write_buf.length);
byte[] read_buf = new byte[pmb.getPageLength()];
if (pmb.hasAutoCRC())
{
// loop to read each page with CRC
for (int pg = 0; pg < pmb.getNumberPages(); pg++)
{
// use 'readContinue' arguement to only access device on first page
pmb.readPageCRC(pg, (pg == 0), read_buf, 0);
// do something with data in read_buf ...
}
}
else
System.out.println("PagedMemoryBank does not support device generated CRC");
MemoryBank
,
OTPMemoryBank
,
OneWireContainer04
,
OneWireContainer06
,
OneWireContainer08
,
OneWireContainer09
,
OneWireContainer0A
,
OneWireContainer0B
,
OneWireContainer0C
,
OneWireContainer0F
,
OneWireContainer12
,
OneWireContainer13
,
OneWireContainer14
,
OneWireContainer18
,
OneWireContainer1A
,
OneWireContainer1D
,
OneWireContainer20
,
OneWireContainer21
,
OneWireContainer23
Method Summary | |
String |
getExtraInfoDescription()
Gets a string description of what is contained in the Extra Information returned when reading pages in this memory bank. |
int |
getExtraInfoLength()
Gets the length in bytes of extra information that is read when reading a page in this memory bank. |
int |
getMaxPacketDataLength()
Gets Maximum data page length in bytes for a packet read or written in this memory bank. |
int |
getNumberPages()
Gets the number of pages in this memory bank. |
int |
getPageLength()
Gets raw page length in bytes in this memory bank. |
boolean |
hasExtraInfo()
Checks to see if this memory bank's pages deliver extra information outside of the normal data space, when read. |
boolean |
hasPageAutoCRC()
Checks to see if this memory bank's pages can be read with the contents being verified by a device generated CRC. |
boolean |
haveExtraInfo()
Deprecated. As of 1-Wire API 0.01, replaced by hasExtraInfo() |
void |
readPage(int page,
boolean readContinue,
byte[] readBuf,
int offset)
Reads a page in this memory bank with no CRC checking (device or data). |
void |
readPage(int page,
boolean readContinue,
byte[] readBuf,
int offset,
byte[] extraInfo)
Reads a page in this memory bank with extra information with no CRC checking (device or data). |
void |
readPageCRC(int page,
boolean readContinue,
byte[] readBuf,
int offset)
Reads a complete memory page with CRC verification provided by the device. |
void |
readPageCRC(int page,
boolean readContinue,
byte[] readBuf,
int offset,
byte[] extraInfo)
Reads a complete memory page with CRC verification provided by the device with extra information. |
int |
readPagePacket(int page,
boolean readContinue,
byte[] readBuf,
int offset)
Reads a Universal Data Packet. |
int |
readPagePacket(int page,
boolean readContinue,
byte[] readBuf,
int offset,
byte[] extraInfo)
Reads a Universal Data Packet and extra information. |
void |
writePagePacket(int page,
byte[] writeBuf,
int offset,
int len)
Writes 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 |
public int getNumberPages()
public int getPageLength()
public int getMaxPacketDataLength()
readPagePacket
and
writePagePacket
methods. This method is only usefull
if this memory bank is general purpose memory.readPagePacket
,
readPagePacket(extra)
,
writePagePacket
public boolean hasPageAutoCRC()
readPageCRC
method can be used. true
if this memory bank can be
read with self generated CRCreadPageCRC
,
readPageCRC(extra)
public boolean haveExtraInfo()
hasExtraInfo()
readPage
,
readPageCRC
, and
readPagePacket
. true
if reading the this memory bank's
pages provides extra informationreadPage(extra)
,
readPageCRC(extra)
,
readPagePacket(extra)
public boolean hasExtraInfo()
readPage
,
readPageCRC
, and
readPagePacket
. true
if reading the this memory bank's
pages provides extra informationreadPage(extra)
,
readPageCRC(extra)
,
readPagePacket(extra)
public int getExtraInfoLength()
hasExtraInfo
public String getExtraInfoDescription()
hasExtraInfo
public void readPage(int page, boolean readContinue, byte[] readBuf, int offset) throws OneWireIOException, OneWireException
readPagePacket
method or have the 1-Wire device provide the
CRC as in
readPageCRC
.
However device CRC generation 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 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 continues where the last one left off and it is inside a 'beginExclusive/endExclusive' block.
page
- page number to read packet fromreadContinue
- true
then device read
is continued without re-selectingreadBuf
- location for data readoffset
- offset into readBuf to place dataOneWireIOException
- on a 1-Wire communication error such as
no 1-Wire 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 readPage(int page, boolean readContinue, byte[] readBuf, int offset, byte[] extraInfo) throws OneWireIOException, OneWireException
readPagePacket
method or have the 1-Wire device provide the
CRC as in
readPageCRC
.
However device CRC generation 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 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 continues where the last one left off and it is inside a 'beginExclusive/endExclusive' block.
page
- page number to read packet fromreadContinue
- true
then device read
is continued without re-selectingreadBuf
- location for data readoffset
- offset into readBuf to place dataextraInfo
- location for extra info readOneWireIOException
- on a 1-Wire communication error such as
no 1-Wire 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
adapterhasExtraInfo
,
getExtraInfoLength
public int readPagePacket(int page, boolean readContinue, byte[] readBuf, int offset) throws OneWireIOException, OneWireException
See Dallas Semiconductor Application Note 114 for details: http://dbserv.maxim-ic.com/appnotes.cfm?appnote_number=114
Note: Using readContinue = true can only be used if the new read continues where the last one left off and it is inside a 'beginExclusive/endExclusive' block.
page
- page number to read packet fromreadContinue
- true
true then device read
is continued without re-selectingreadBuf
- location for data readoffset
- offset into readBuf to place dataOneWireIOException
- on a 1-Wire communication error such as
an invalid CRC16 or length found in the packet. 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'.
It could also be caused due to the device page not containing a
valid packet.OneWireException
- on a communication or setup error with the 1-Wire
adaptergetMaxPacketDataLength
public int readPagePacket(int page, boolean readContinue, byte[] readBuf, int offset, byte[] extraInfo) throws OneWireIOException, OneWireException
readPagePacket
for a description of the packet structure. 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 continues where the last one left off and it is inside a 'beginExclusive/endExclusive' block.
page
- page number to read packet fromreadContinue
- true
then device read
is continued without re-selectingreadBuf
- location for data readoffset
- offset into readBuf to place dataextraInfo
- location for extra info readOneWireIOException
- on a 1-Wire communication error such as
an invalid CRC16 or length found in the packet. 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'.
It could also be caused due to the device page not containing a
valid packet.OneWireException
- on a communication or setup error with the 1-Wire
adapterhasExtraInfo
,
getExtraInfoLength
,
getMaxPacketDataLength
public void writePagePacket(int page, byte[] writeBuf, int offset, int len) throws OneWireIOException, OneWireException
readPagePacket
for a description of the packet structure.page
- page number to write packet towriteBuf
- data to writeoffset
- offset into writeBuf where data to write islen
- number of bytes to write with a max of
getMaxPacketDataLength
elementsOneWireIOException
- on a 1-Wire communication error such as
read verification error on write. 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'.
It could also be caused due to the device page being write protected.OneWireException
- on a communication or setup error with the 1-Wire
adaptergetMaxPacketDataLength
public void readPageCRC(int page, boolean readContinue, byte[] readBuf, int offset) throws OneWireIOException, OneWireException
Note: Using readContinue = true can only be used if the new read continues where the last one left off and it is inside a 'beginExclusive/endExclusive' block.
page
- page number to readreadContinue
- true
true then device read
is continued without re-selectingreadBuf
- location for data readoffset
- offset into readBuf to place dataOneWireIOException
- on a 1-Wire communication error such as
an invalid CRC read from device. 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
adapterhasPageAutoCRC
,
getPageLength
public void readPageCRC(int page, boolean readContinue, byte[] readBuf, int offset, byte[] extraInfo) throws OneWireIOException, OneWireException
Note: Using readContinue = true can only be used if the new read continues where the last one left off and it is inside a 'beginExclusive/endExclusive' block.
page
- page number to readreadContinue
- true
true then device read
is issued without continued without re-selectingreadBuf
- location for data readoffset
- offset into readBuf to place dataextraInfo
- location for extra info readOneWireIOException
- on a 1-Wire communication error such as
an invalid CRC read from device. 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
adapterhasExtraInfo
,
getExtraInfoLength
,
hasPageAutoCRC
,
getPageLength
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |