|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.onewire.container.OneWireContainer | +--com.dalsemi.onewire.container.OneWireContainer18
OneWire container for iButton family type 18 (hex), DS1963S.
This container makes use of several optimizations to help it run fast
on TINI. These optimizations do little for the PC, but they do not
slow down the PC. Most methods are synchronized because they all access
an instance byte array. This is less expensive than creating new byte
arrays for every method, because in virtually all cases there should
not be contention for the resources in this container between threads.
Threads should use the DSPortAdapter methods beginExclusive and
endExclusive to synchronize on the OneWire port.
This container provides the functionality to use the raw power of the
DS1963S. It does not immediately implement transactions and authentication.
The class com.dalsemi.onewire.container.SHAiButton does these. The SHAiButton
class exists on top of this class, making higher level calls to implement
transactions.
Notice that for maximum performance, you should call the method setSpeedCheck()
with an argument false
before any other methods that access the
OneWire. A program that calls this function is assumed to understand and
control the speed of communication. If not called, a call to the function
OneWireContainer.doSpeed() will occur in almost every function. While this should
guarantee that you never have the bus at an unknown speed, it will slow down your
throughput considerably.
SHAiButton
Field Summary | |
static byte |
AUTH_HOST
Field AUTH_HOST |
static byte |
COMPUTE_CHALLENGE
Field COMPUTE_CHALLENGE |
static byte |
COMPUTE_FIRST_SECRET
Field COMPUTE_FIRST_SECRET |
static byte |
COMPUTE_NEXT_SECRET
Field COMPUTE_NEXT_SECRET |
static byte |
COMPUTE_SHA
Field COMPUTE_SHA |
static byte |
COPY_SCRATCHPAD
Field COPY_SCRATCHPAD |
static byte |
ERASE_SCRATCHPAD
Field ERASE_SCRATCHPAD |
byte |
ES
Field TA1, TA2, ES |
static byte |
MATCH_SCRATCHPAD
Field MATCH_SCRATCHPAD |
static byte |
READ_AUTHENTICATED_PAGE
Field READ_AUTHENTICATED_PAGE |
static byte |
READ_MEMORY
Field READ_MEMORY |
static byte |
READ_SCRATCHPAD
Field READ_SCRATCHPAD |
static byte |
RESUME
Field RESUME |
static byte |
SIGN_DATA_PAGE
Field SIGN_DATA_PAGE |
byte |
TA1
Field TA1, TA2, ES |
byte |
TA2
Field TA1, TA2, ES |
static byte |
VALIDATE_DATA_PAGE
Field VALIDATE_DATA_PAGE |
static byte |
WRITE_SCRATCHPAD
Field WRITE_SCRATCHPAD |
Constructor Summary | |
OneWireContainer18()
Default constructor |
|
OneWireContainer18(DSPortAdapter sourceAdapter,
byte[] newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device. |
|
OneWireContainer18(DSPortAdapter sourceAdapter,
long newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device. |
|
OneWireContainer18(DSPortAdapter sourceAdapter,
java.lang.String newAddress)
Create a container with a provided adapter object and the address of the iButton or 1-Wire device. |
Method Summary | |
boolean |
bindSecretToiButton(int page,
byte[] bind_data,
byte[] bind_code,
int secret_number)
Binds an installed secret to a DS1963S byte using well-known binding data and the DS1963S's unique identification number. |
boolean |
copyScratchPad()
Copies the contents of the scratchpad to the target destination that was specified in a call to write scratchpad or erase scratchpad. |
boolean |
eraseScratchPad(int page)
Erases the scratchpad of the DS1963S. |
java.lang.String |
getAlternateNames()
Retrieve the alternate Dallas Semiconductor part numbers or names. |
java.lang.String |
getDescription()
Retrieve a short description of the function of the iButton type. |
int |
getMaxSpeed()
Returns the maximum speed this iButton can communicate at. |
java.util.Enumeration |
getMemoryBanks()
Return an enumeration of memory banks. |
java.lang.String |
getName()
Retrieve the Dallas Semiconductor part number of the iButton as a string. |
boolean |
installMasterSecret(int page,
byte[] secret,
int secret_number)
Installs a secret on a DS1963S. |
boolean |
matchScratchPad(byte[] mac)
After a Validate command, the scratchpad contains a signature that cannot be read, but must be checked against another signature. |
boolean |
readAuthenticatedPage(int pageNum,
byte[] data,
int start)
Reads and authenticates a page. |
void |
readMemoryPage(int pageNum,
byte[] data,
int start)
Reads a memory page from the DS1963S. |
int |
readScratchPad(byte[] data,
int start)
Read the contents of the scratchpad. |
void |
setSpeedCheck(boolean doSpeedCheck)
To ensure that all parts can talk to the onewire bus at their desired speed, each method contains a call to doSpeed(). |
void |
setupContainer(DSPortAdapter sourceAdapter,
byte[] newAddress)
Provide this container the adapter object used to access this device and provide the address of this iButton or 1-Wire device. |
boolean |
SHAFunction(byte function)
Performs one of the DS1963S's SHA functions (see the datasheet for more on these functions). |
boolean |
SHAFunction(byte function,
int T)
Performs one of the DS1963S's SHA functions (see the datasheet for more on these functions). |
void |
useResume(boolean set)
Tells the OneWireContainer18 whether it can use the resume command. |
boolean |
waitForSuccessfulFinish()
Waits for the DS1963S's output to alternate. |
boolean |
writeDataPage(int page_number,
byte[] page_data)
Writes a data page on the DS1963S. |
boolean |
writeScratchPad(int targetPage,
int targetPageOffset,
byte[] inputbuffer,
int start,
int length)
Write to the scratchpad. |
Methods inherited from class com.dalsemi.onewire.container.OneWireContainer |
doSpeed, getAdapter, getAddress, getAddressAsLong, getAddressAsString, isAlarming, isPresent, setSpeed, setupContainer, setupContainer |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public byte TA1
public byte TA2
public byte ES
public static final byte READ_MEMORY
public static final byte WRITE_SCRATCHPAD
public static final byte MATCH_SCRATCHPAD
public static final byte ERASE_SCRATCHPAD
public static final byte READ_SCRATCHPAD
public static final byte READ_AUTHENTICATED_PAGE
public static final byte COPY_SCRATCHPAD
public static final byte COMPUTE_SHA
public static final byte COMPUTE_FIRST_SECRET
public static final byte COMPUTE_NEXT_SECRET
public static final byte VALIDATE_DATA_PAGE
public static final byte SIGN_DATA_PAGE
public static final byte COMPUTE_CHALLENGE
public static final byte AUTH_HOST
public static final byte RESUME
Constructor Detail |
public OneWireContainer18()
public OneWireContainer18(DSPortAdapter sourceAdapter, byte[] newAddress)
sourceAdapter
- adapter object required to communicate with
this iButton.newAddress
- address of this 1-Wire devicepublic OneWireContainer18(DSPortAdapter sourceAdapter, long newAddress)
sourceAdapter
- adapter object required to communicate with
this iButton.newAddress
- address of this 1-Wire devicepublic OneWireContainer18(DSPortAdapter sourceAdapter, java.lang.String newAddress)
sourceAdapter
- adapter object required to communicate with
this iButton.newAddress
- address of this 1-Wire deviceMethod Detail |
public void setupContainer(DSPortAdapter sourceAdapter, byte[] newAddress)
setupContainer
in class OneWireContainer
sourceAdapter
- adapter object required to communicate with
this iButton.newAddress
- address of this 1-Wire devicepublic java.lang.String getName()
getName
in class OneWireContainer
public java.lang.String getAlternateNames()
getAlternateNames
in class OneWireContainer
public java.lang.String getDescription()
getDescription
in class OneWireContainer
public int getMaxSpeed()
getMaxSpeed
in class OneWireContainer
public java.util.Enumeration getMemoryBanks()
getMemoryBanks
in class OneWireContainer
com.dalsemi.onewire.container.OneWireContainer
public void setSpeedCheck(boolean doSpeedCheck)
doSpeedCheck
- True if you want doSpeed() called before every
onewire bus access. False to skip this expensive
call.public void useResume(boolean set)
set
- True means use the resume command instead of the select command.public boolean eraseScratchPad(int page) throws OneWireIOException, OneWireException
page
- The target page number. Normally this does not matter, but in cases
where you would like to erase a memory page, you would call this method
with the page number, then read scratchpad to read back the registers,
then copy scratchpad to erase the page.OneWireIOException
- OneWireException
- public boolean waitForSuccessfulFinish() throws OneWireIOException, OneWireException
OneWireIOException
- OneWireException
- public void readMemoryPage(int pageNum, byte[] data, int start) throws OneWireIOException, OneWireException
pageNum
- Page number to read.data
- Byte array for the return of the data. This array must be AT LEAST 32 bytes long.start
- Location in the byte array to start copying page data to.OneWireIOException
- OneWireException
- public boolean readAuthenticatedPage(int pageNum, byte[] data, int start) throws OneWireIOException, OneWireException
pageNum
- Page number to read and authenticate.data
- Byte array for the page data plus extra information (2 write cycle
coutnersof 4 bytes each, one 2 byte CRC, appended after 32 bytes of
the data page). This byte array must be AT LEAST 42 bytes long.start
- Offset to copy into the array data.OneWireIOException
- OneWireException
- public boolean writeScratchPad(int targetPage, int targetPageOffset, byte[] inputbuffer, int start, int length) throws OneWireIOException, OneWireException
targetPage
- The page number this data will eventually be copied to.targetPageOffset
- The offset on the page to copy this data to.inputbuffer
- The data that will be copied into the scratchpad.start
- Offset into the input buffer for the data to write.length
- The number of bytes to write.OneWireIOException
- OneWireException
- public boolean matchScratchPad(byte[] mac) throws OneWireIOException, OneWireException
mac
- Byte array containing the signature. Must be at least 20 bytes long,
and the signature must start at offset 0.OneWireIOException
- OneWireException
- public int readScratchPad(byte[] data, int start) throws OneWireIOException, OneWireException
data
- Byte array to hold the contents of the scratchpad.
Up to 32 bytes will be copied. Fewer bytes may be
copied if the target address stored inside the
DS1963S is not a multiple of 32.start
- Offset into the byte array to copy the scratchpad data.OneWireIOException
- OneWireException
- public boolean copyScratchPad() throws OneWireIOException, OneWireException
OneWireIOException
- OneWireException
- public boolean installMasterSecret(int page, byte[] secret, int secret_number) throws OneWireIOException, OneWireException
page
- The page number used to write the partial secrets to. In most cases, this
should be equal to secret_number or secret_number+8.secret
- A byte array containing the entire secret to be installed. This
method will be faster if this byte array's length is a multiple
of 47, however--installing master secrets should be a part of
initialization, so a slight speed increase is probably not very
important in most cases.secret_number
- The secret 'page' to use. Secrets are stored across pages 16
and 17, in 8 byte chunks (there are 8 secrets). This should be
a number between 0 and 8.OneWireIOException
- OneWireException
- public boolean bindSecretToiButton(int page, byte[] bind_data, byte[] bind_code, int secret_number) throws OneWireIOException, OneWireException
page
- The page number that has the master secret installed. In this case,
the page number does not need to be equivalent to the secret_number
modulo 8. The new secret (installed secret + binding secret) is generated
from this page but can be copied into another secret. User iButtons should
bind to the same page the secret was installed on. Coprocessor iButtons
must copy to a new secret to preserve the general system authentication
secret.bind_data
- 32 bytes of binding data used to bind the iButton to the system.bind_code
- This byte array can be of two lengths. A 15-length byte array is unaltered
and placed in the scratchpad for the binding. A 7-length byte array is
combined with the page number and DS1963S unique ID and then placed
in the scratchpad. Coprocessors should use a pre-formatted 15-length
byte array. User iButtons should let the method format for them (i.e.
use the 7-length byte array option)secret_number
- Secret number to copy the resulting secret to. See the discussion on page number.OneWireIOException
- OneWireException
- public boolean writeDataPage(int page_number, byte[] page_data) throws OneWireIOException, OneWireException
page_number
- Page number to write.page_data
- Byte array with the page data to write. This array must
be at least 32 bytes long.OneWireIOException
- OneWireException
- public boolean SHAFunction(byte function) throws OneWireIOException, OneWireException
function
- The function code to use (i.e. COMPUTE_NEXT_SECRET)OneWireIOException
- OneWireException
- public boolean SHAFunction(byte function, int T) throws OneWireIOException, OneWireException
function
- The function code to use (i.e. COMPUTE_NEXT_SECRET)T
- The address to use (page number).OneWireIOException
- OneWireException
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |