/** * Reads the account data off the SHAiButton using a standard READ command. First, this function * asserts that the account page number is known as well as the length of the account file. The 32 * byte account data page is copied into dataBuffer starting at the given offset. * * @param dataBuffer the buffer to copy the account data into * @param offset the index into the buffer where copying should begin * @return whether or not the read was successful * @throws OneWireIOException on a 1-Wire communication error such as reading an incorrect CRC * from a 1-Wire 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'. * @throws OneWireException on a communication or setup error with the 1-Wire adapter */ public synchronized boolean readAccountData(byte[] dataBuffer, int offset) throws OneWireException, OneWireIOException { // init local vars OneWireContainer18 ibcL = this.ibc; // make sure account info is properly setup if (!checkAccountPageInfo(ibcL)) { return false; } // if the cache is empty if (this.accountData[0] == 0) { // read directly into local cache ibcL.readMemoryPage(this.accountPageNumber, this.accountData, 0); } // copy cached data into user's buffer System.arraycopy(this.accountData, 0, dataBuffer, offset, 32); // had to work, right? return true; }