Package com.dalsemi.onewire.container
Class MemoryBankScratchSHAEE
- java.lang.Object
-
- com.dalsemi.onewire.container.MemoryBankScratchSHAEE
-
- All Implemented Interfaces:
MemoryBank
,PagedMemoryBank
public class MemoryBankScratchSHAEE extends java.lang.Object
Memory bank class for the Scratchpad section of SHA EEPROM iButtons and 1-Wire devices with SHA write-protected memory pages.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
bankDescription
Memory bank descriptionsstatic byte
COMPUTE_NEXT_SECRET
Compute next Secret commandprotected byte
COPY_SCRATCHPAD_COMMAND
Copy Scratchpad Commandprotected boolean
doSetSpeed
Flag to indicate that speed needs to be setprotected boolean
extraInfo
Flag if reading a page in memory bank provides optional extra information (counter, tamper protection, SHA-1...)protected java.lang.String
extraInfoDescription
Extra information description when reading page in memory bankprotected int
extraInfoLength
Length of extra information when reading a page in memory bankprotected static byte[]
ffBlock
block of 0xFF's used for faster read pre-fill of 1-Wire blocks Comes from OneWireContainer33 that this MemoryBank references.protected boolean
generalPurposeMemory
Memory bank usage flagsprotected OneWireContainer
ib
Reference to the OneWireContainer this bank resides on.static byte
LOAD_FIRST_SECRET
Load First Secretprotected int
maxPacketDataLength
Max data length in page packet in memory bankprotected boolean
nonVolatile
Flag if memory bank is non volatile (will not erase when power removed)protected int
numberPages
Number of pages in memory bankprotected OneWireContainer33
owc33
The Password container to access the 8 byte passwordsprotected boolean
pageAutoCRC
Flag if memory bank has page auto-CRC generationprotected int
pageLength
page length in memory bankprotected boolean
powerDelivery
Flag if memory bank needs power delivery to writeprotected boolean
programPulse
Flag if memory bank needs program Pulse to writestatic byte
READ_SCRATCHPAD_COMMAND
Read Scratchpad Commandprotected boolean
readOnly
Flag if memory bank is read onlyprotected boolean
readWrite
Flag if memory bank is read/writestatic byte
REFRESH_SCRATCHPAD
Refresh Scratchpad commandprotected int
size
Size of memory bank in bytesprotected int
startPhysicalAddress
Starting physical address in memory bank.static byte
WRITE_SCRATCHPAD_COMMAND
Write Scratchpad Commandprotected boolean
writeOnce
Flag if memory bank is write once (EPROM)protected boolean
writeVerification
Flag if read back verification is enabled in 'write()'.protected static byte[]
zeroBlock
block of 0x00's used for faster read pre-fill of 1-Wire blocks Comes from OneWireContainer33 that this MemoryBank references.
-
Constructor Summary
Constructors Constructor Description MemoryBankScratchSHAEE(OneWireContainer33 ibutton)
Memory bank contstuctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkSpeed()
Check the device speed if has not been done before or if an error was detected.void
computeNextSecret(int addr)
Computes the next secret.void
computeNextSecret(int addr, byte[] partialsecret, int offset)
Computes the next secret.void
copyScratchpad(int addr, byte[] scratchpad, int offset)
Copy the scratchpad page to memory.void
copyScratchpad(int addr, byte[] scratchpad, int scratchpadOffset, byte[] pageData, int pageDataOffset)
Copy the scratchpad page to memory.void
copyScratchpad(int addr, int len)
Copy the scratchpad page to memory.void
copyScratchpad(int startAddr, int len, boolean WriteProtect)
Copy the scratchpad page to memory.void
copyScratchpadWithMAC(int addr, byte[] authMAC, int authOffset)
Copy all 8 bytes of the Sratch Pad to a certain address in memory using the provided authorization MACvoid
forceVerify()
Set the flag to indicate the next 'checkSpeed()' will force a speed set and verify 'doSpeed()'.java.lang.String
getBankDescription()
Query to see get a string description of the current memory bank.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 page length in bytes in current memory bank.int
getSize()
Query to get the memory bank size in bytes.int
getStartPhysicalAddress()
Query to get the starting physical address of this 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()
Query to see if current memory bank pages can be read with the contents being verified by a device generated CRC.boolean
isGeneralPurposeMemory()
Query to see if the current memory bank is general purpose user memory.boolean
isNonVolatile()
Query to see if current memory bank non-volatile.boolean
isReadOnly()
Query to see if current memory bank is read only.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.void
loadFirstSecret(int addr)
Load First Secret for the DS2432.void
loadFirstSecret(int addr, byte[] data, int offset)
Load First Secret for the DS2432.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.boolean
needsProgramPulse()
Query to see if current memory bank pages need the adapter to have a 'ProgramPulse' in order to write to the memory.void
read(int startAddr, boolean readContinue, byte[] readBuf, int offset, int len)
Read memory in the current bank with no CRC checking (device or data).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
readScratchpad(byte[] readBuf, int offset, int len, byte[] extraInfo)
Read the scratchpad page of memory from a NVRAM device This method reads and returns the entire scratchpad after the byte offset regardless of the actual ending offsetvoid
refreshScratchpad(int addr)
Refreshes the scratchpad for DS1961S.void
setWriteVerification(boolean doReadVerf)
Set the write verification for the 'write()' method.void
write(int addr, byte[] writeBuf, int offset, int len)
Write memory in the current bank.void
writePagePacket(int page, byte[] writeBuf, int offset, int len)
Write a Universal Data Packet.void
writeScratchpad(int addr, byte[] writeBuf, int offset, int len)
Write to the scratchpad page of memory a NVRAM device.
-
-
-
Field Detail
-
LOAD_FIRST_SECRET
public static final byte LOAD_FIRST_SECRET
Load First Secret- See Also:
- Constant Field Values
-
COMPUTE_NEXT_SECRET
public static final byte COMPUTE_NEXT_SECRET
Compute next Secret command- See Also:
- Constant Field Values
-
REFRESH_SCRATCHPAD
public static final byte REFRESH_SCRATCHPAD
Refresh Scratchpad command- See Also:
- Constant Field Values
-
ffBlock
protected static final byte[] ffBlock
block of 0xFF's used for faster read pre-fill of 1-Wire blocks Comes from OneWireContainer33 that this MemoryBank references.
-
zeroBlock
protected static final byte[] zeroBlock
block of 0x00's used for faster read pre-fill of 1-Wire blocks Comes from OneWireContainer33 that this MemoryBank references.
-
owc33
protected OneWireContainer33 owc33
The Password container to access the 8 byte passwords
-
WRITE_SCRATCHPAD_COMMAND
public static final byte WRITE_SCRATCHPAD_COMMAND
Write Scratchpad Command- See Also:
- Constant Field Values
-
READ_SCRATCHPAD_COMMAND
public static final byte READ_SCRATCHPAD_COMMAND
Read Scratchpad Command- See Also:
- Constant Field Values
-
ib
protected OneWireContainer ib
Reference to the OneWireContainer this bank resides on.
-
COPY_SCRATCHPAD_COMMAND
protected byte COPY_SCRATCHPAD_COMMAND
Copy Scratchpad Command
-
doSetSpeed
protected boolean doSetSpeed
Flag to indicate that speed needs to be set
-
size
protected int size
Size of memory bank in bytes
-
bankDescription
protected java.lang.String bankDescription
Memory bank descriptions
-
generalPurposeMemory
protected boolean generalPurposeMemory
Memory bank usage flags
-
readWrite
protected boolean readWrite
Flag if memory bank is read/write
-
writeOnce
protected boolean writeOnce
Flag if memory bank is write once (EPROM)
-
readOnly
protected boolean readOnly
Flag if memory bank is read only
-
nonVolatile
protected boolean nonVolatile
Flag if memory bank is non volatile (will not erase when power removed)
-
programPulse
protected boolean programPulse
Flag if memory bank needs program Pulse to write
-
powerDelivery
protected boolean powerDelivery
Flag if memory bank needs power delivery to write
-
startPhysicalAddress
protected int startPhysicalAddress
Starting physical address in memory bank. Needed for different types of memory in the same logical memory bank. This can be used to separate them into two virtual memory banks. Example: DS2406 status page has mixed EPROM and Volatile RAM.
-
writeVerification
protected boolean writeVerification
Flag if read back verification is enabled in 'write()'.
-
numberPages
protected int numberPages
Number of pages in memory bank
-
pageLength
protected int pageLength
page length in memory bank
-
maxPacketDataLength
protected int maxPacketDataLength
Max data length in page packet in memory bank
-
pageAutoCRC
protected boolean pageAutoCRC
Flag if memory bank has page auto-CRC generation
-
extraInfo
protected boolean extraInfo
Flag if reading a page in memory bank provides optional extra information (counter, tamper protection, SHA-1...)
-
extraInfoLength
protected int extraInfoLength
Length of extra information when reading a page in memory bank
-
extraInfoDescription
protected java.lang.String extraInfoDescription
Extra information description when reading page in memory bank
-
-
Constructor Detail
-
MemoryBankScratchSHAEE
public MemoryBankScratchSHAEE(OneWireContainer33 ibutton)
Memory bank contstuctor. Requires reference to the OneWireContainer this memory bank resides on.
-
-
Method Detail
-
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()'.- Specified by:
readPageCRC
in interfacePagedMemoryBank
- Parameters:
page
- page number to readreadContinue
- if 'true' then device read is continued without re-selecting. This can only be used if the new readPagePacket() continuous 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
- See Also:
hasPageAutoCRC
,getPageLength
-
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 'hasExtraInfo()' for a description of the optional extra information.- Specified by:
readPageCRC
in interfacePagedMemoryBank
- Parameters:
page
- page number to readreadContinue
- if 'true' then device read is continued without re-selecting. This can only be used if the new readPagePacket() continuous 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 dataextraInfo
- byte array to put extra info read into- Throws:
OneWireIOException
OneWireException
- See Also:
hasExtraInfo
,getExtraInfoLength
,hasPageAutoCRC
,getPageLength
-
readScratchpad
public void readScratchpad(byte[] readBuf, int offset, int len, byte[] extraInfo) throws OneWireIOException, OneWireException
Read the scratchpad page of memory from a NVRAM device This method reads and returns the entire scratchpad after the byte offset regardless of the actual ending offset- Parameters:
readBuf
- byte array to place read data into length of array is always pageLength.offset
- offset into readBuf to pug datalen
- length in bytes to readextraInfo
- byte array to put extra info read into (TA1, TA2, e/s byte) length of array is always extraInfoLength. Can be 'null' if extra info is not needed.- Throws:
OneWireIOException
OneWireException
-
copyScratchpad
public void copyScratchpad(int addr, int len) throws OneWireIOException, OneWireException
Copy the scratchpad page to memory.- Parameters:
addr
- the address to copy the data tolen
- length byte is ignored, must always be 8.- Throws:
OneWireIOException
OneWireException
-
copyScratchpad
public void copyScratchpad(int addr, byte[] scratchpad, int offset) throws OneWireIOException, OneWireException
Copy the scratchpad page to memory.- Parameters:
addr
- the address to copy toscratchpad
- the scratchpad contents that will be copiedoffset
- the offset into scratchpad byte[] where scratchpad data begins- Throws:
OneWireIOException
OneWireException
-
copyScratchpad
public void copyScratchpad(int addr, byte[] scratchpad, int scratchpadOffset, byte[] pageData, int pageDataOffset) throws OneWireIOException, OneWireException
Copy the scratchpad page to memory.- Parameters:
addr
- the address to copy toscratchpad
- the scratchpad contents that will be copiedscratchpadOffset
- the offset into scratchpad byte[] where scratchpad data beginspageData
- the data on the page of memory to be written topageDataOffset
- the offset into pageData byte[] where pageData begins- Throws:
OneWireIOException
OneWireException
-
copyScratchpadWithMAC
public void copyScratchpadWithMAC(int addr, byte[] authMAC, int authOffset) throws OneWireIOException, OneWireException
Copy all 8 bytes of the Sratch Pad to a certain address in memory using the provided authorization MAC- Parameters:
addr
- the address to copy the data toauthMAC
- byte[] containing write authorization MACauthOffset
- offset into authMAC where authorization MAC begins- Throws:
OneWireIOException
OneWireException
-
writeScratchpad
public void writeScratchpad(int addr, byte[] writeBuf, int offset, int len) throws OneWireIOException, OneWireException
Write to the scratchpad page of memory a NVRAM device.- Parameters:
addr
- physical address to copy data towriteBuf
- byte array containing data to writeoffset
- offset into readBuf to place datalen
- length in bytes to write- Throws:
OneWireIOException
OneWireException
-
write
public void write(int addr, 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.- Specified by:
write
in interfaceMemoryBank
- Parameters:
addr
- the address to write towriteBuf
- byte array containing data to writeoffset
- offset into writeBuf to get datalen
- length in bytes to write- Throws:
OneWireIOException
OneWireException
-
loadFirstSecret
public void loadFirstSecret(int addr, byte[] data, int offset) throws OneWireIOException, OneWireException
Load First Secret for the DS2432. Loads the specified data to the specified location. If the address is data memory (instead of secret memory), this command must have been preceded by a Refresh Scratchpad command for it to be successful.- Parameters:
addr
- the address to write the data todata
- the data to 'load' with the Load First Secret commandoffset
- the offset to use for reading the data byte[]- Throws:
OneWireIOException
OneWireException
-
loadFirstSecret
public void loadFirstSecret(int addr) throws OneWireIOException, OneWireException
Load First Secret for the DS2432. Loads current contents of the scratchpad to the specified location. If the address is data memory (instead of secret memory), this command must have been preceded by a Refresh Scratchpad command for it to be successful.- Parameters:
addr
- the address to write the data to- Throws:
OneWireIOException
OneWireException
-
computeNextSecret
public void computeNextSecret(int addr) throws OneWireIOException, OneWireException
Computes the next secret.- Parameters:
addr
- the physical address of the page to use for secret computation- Throws:
OneWireIOException
OneWireException
-
computeNextSecret
public void computeNextSecret(int addr, byte[] partialsecret, int offset) throws OneWireIOException, OneWireException
Computes the next secret.- Parameters:
addr
- the physical address of the page to use for secret computationpartialsecret
- byte array containing next partial secret for writing to the scratchpadoffset
- into partialsecret byte array to start reading- Throws:
OneWireIOException
OneWireException
-
refreshScratchpad
public void refreshScratchpad(int addr) throws OneWireIOException, OneWireException
Refreshes the scratchpad for DS1961S. Command has no effect on DS2432 devices. After this command is executed, the data at the address specified will be loaded into the scratchpad. The Load First Secret command can then be used to re-write the data back to the page, correcting any weakly-programmed EEPROM bits.- Parameters:
addr
- the address to load the data from into the scratchpad- Throws:
OneWireIOException
OneWireException
-
getBankDescription
public java.lang.String getBankDescription()
Query to see get a string description of the current memory bank.- Specified by:
getBankDescription
in interfaceMemoryBank
- Returns:
- String containing the memory bank description
-
isGeneralPurposeMemory
public 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.- Specified by:
isGeneralPurposeMemory
in interfaceMemoryBank
- Returns:
- 'true' if current memory bank is general purpose
-
isReadWrite
public boolean isReadWrite()
Query to see if current memory bank is read/write.- Specified by:
isReadWrite
in interfaceMemoryBank
- Returns:
- 'true' if current memory bank is read/write
-
isWriteOnce
public boolean isWriteOnce()
Query to see if current memory bank is write write once such as with EPROM technology.- Specified by:
isWriteOnce
in interfaceMemoryBank
- Returns:
- 'true' if current memory bank can only be written once
-
isReadOnly
public boolean isReadOnly()
Query to see if current memory bank is read only.- Specified by:
isReadOnly
in interfaceMemoryBank
- Returns:
- 'true' if current memory bank can only be read
-
isNonVolatile
public 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.- Specified by:
isNonVolatile
in interfaceMemoryBank
- Returns:
- 'true' if current memory bank non volatile.
-
needsProgramPulse
public boolean needsProgramPulse()
Query to see if current memory bank pages need the adapter to have a 'ProgramPulse' in order to write to the memory.- Specified by:
needsProgramPulse
in interfaceMemoryBank
- Returns:
- 'true' if writing to the current memory bank pages requires a 'ProgramPulse'.
- See Also:
DSPortAdapter
-
needsPowerDelivery
public 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.- Specified by:
needsPowerDelivery
in interfaceMemoryBank
- Returns:
- 'true' if writing to the current memory bank pages requires 'PowerDelivery'.
- See Also:
DSPortAdapter
-
getStartPhysicalAddress
public 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.- Specified by:
getStartPhysicalAddress
in interfaceMemoryBank
- Returns:
- physical starting address of this logical bank.
-
getSize
public int getSize()
Query to get the memory bank size in bytes.- Specified by:
getSize
in interfaceMemoryBank
- Returns:
- memory bank size in bytes.
-
getNumberPages
public int getNumberPages()
Query to get the number of pages in current memory bank.- Specified by:
getNumberPages
in interfacePagedMemoryBank
- Returns:
- number of pages in current memory bank
-
getPageLength
public int getPageLength()
Query to get page length in bytes in current memory bank.- Specified by:
getPageLength
in interfacePagedMemoryBank
- 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 useful if the current memory bank is general purpose memory.- Specified by:
getMaxPacketDataLength
in interfacePagedMemoryBank
- Returns:
- max packet page length in bytes in current memory bank
- See Also:
readPagePacket
,readPagePacket(extra)
,writePagePacket
-
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.- Specified by:
hasPageAutoCRC
in interfacePagedMemoryBank
- Returns:
- 'true' if current memory bank can be read with self generated CRC.
- See Also:
readPageCRC
,readPageCRC(extra)
-
hasExtraInfo
public 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
, andreadPagePacket
.- Specified by:
hasExtraInfo
in interfacePagedMemoryBank
- Returns:
true
if reading the this memory bank's pages provides extra information- Since:
- 1-Wire API 0.01
- See Also:
readPage(extra)
,readPageCRC(extra)
,readPagePacket(extra)
-
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 'hasExtraInfo()'.- Specified by:
getExtraInfoLength
in interfacePagedMemoryBank
- Returns:
- number of bytes in Extra Information read when reading pages in the current memory bank.
- See Also:
hasExtraInfo
-
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 'hasExtraInfo()'.- Specified by:
getExtraInfoDescription
in interfacePagedMemoryBank
- Returns:
- string describing extra information.
- See Also:
hasExtraInfo
-
setWriteVerification
public void setWriteVerification(boolean doReadVerf)
Set the write verification for the 'write()' method.- Specified by:
setWriteVerification
in interfaceMemoryBank
- Parameters:
doReadVerf
- true (default) verify write in 'write' false, don't verify write (used on Write-Once bit manipulation)- See Also:
OTPMemoryBank
-
read
public 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 consistently.- Specified by:
read
in interfaceMemoryBank
- Parameters:
startAddr
- starting addressreadContinue
- if 'true' then device read is continued without re-selecting. This can only be used if the new read() continuous where the last one led off and it is inside a 'beginExclusive/endExclusive' block.readBuf
- byte array to place read data intooffset
- offset into readBuf to place datalen
- length in bytes to read- Throws:
OneWireIOException
OneWireException
-
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 consistently.- Specified by:
readPage
in interfacePagedMemoryBank
- Parameters:
page
- page number to read packet fromreadContinue
- if 'true' then device read is continued without re-selecting. This can only be used if the new readPage() continuous where the last one led off and it is inside a 'beginExclusive/endExclusive' block.readBuf
- byte array to place read data intooffset
- 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 consistently. See the method 'hasExtraInfo()' for a description of the optional extra information some devices have.- Specified by:
readPage
in interfacePagedMemoryBank
- Parameters:
page
- page number to read packet fromreadContinue
- if 'true' then device read is continued without re-selecting. This can only be used if the new readPage() continuous where the last one led off and it is inside a 'beginExclusive/endExclusive' block.readBuf
- byte array to place read data intooffset
- offset into readBuf to place dataextraInfo
- byte array to put extra info read into- Throws:
OneWireIOException
OneWireException
- See Also:
hasExtraInfo
,getExtraInfoLength
-
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.- Specified by:
readPagePacket
in interfacePagedMemoryBank
- Parameters:
page
- page number to read packet fromreadContinue
- if 'true' then device read is continued without re-selecting. This can only be used if the new readPagePacket() continuous 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
- See Also:
getMaxPacketDataLength
-
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 'hasExtraInfo()' for a description of the optional extra information some devices have.- Specified by:
readPagePacket
in interfacePagedMemoryBank
- Parameters:
page
- page number to read packet fromreadContinue
- if 'true' then device read is continued without re-selecting. This can only be used if the new readPagePacket() continuous 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 dataextraInfo
- 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
- See Also:
hasExtraInfo
,getExtraInfoLength
,getMaxPacketDataLength
-
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.- Specified by:
writePagePacket
in interfacePagedMemoryBank
- Parameters:
page
- page number to write packet towriteBuf
- data byte array to writeoffset
- offset into writeBuf where data to write islen
- number of bytes to write- Throws:
OneWireIOException
OneWireException
- See Also:
getMaxPacketDataLength
-
copyScratchpad
public void copyScratchpad(int startAddr, int len, boolean WriteProtect) throws OneWireIOException, OneWireException
Copy the scratchpad page to memory.- Parameters:
startAddr
- starting addresslen
- length in bytes that was written already- Throws:
OneWireIOException
OneWireException
-
checkSpeed
public void checkSpeed() throws OneWireIOException, OneWireException
Check the device speed if has not been done before or if an error was detected.- Throws:
OneWireIOException
OneWireException
-
forceVerify
public void forceVerify()
Set the flag to indicate the next 'checkSpeed()' will force a speed set and verify 'doSpeed()'.
-
-