|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.onewire.utils.Address
Utilities to translate and verify the 1-Wire Network address.
Q: What is a 1-Wire Network Address?
A: A 1-Wire address is 64 bits consisting of an eight bit family code, forty eight bits of serialized data and an eight bit CRC8 of the first 56 bits.
For example given the following address in hexadecimal:
10 28 E9 14 00 00 00 F3
The above is a family code 10 device with a serialized data of 28 E9 14 00 00 00, and a CRC8 of F3.
The address can be stored in several ways:
byte[] address = { 0x10, (byte)0xE9, 0x14, 0x00, 0x00, 0x00, (byte)0xF3 };
long address = (long)0xF300000014E92810;
String address = "F300000014E92810";
Method Summary | |
static boolean |
isValid(byte[] address)
Checks the CRC8 calculation of this 1-Wire Network address. |
static boolean |
isValid(long address)
Checks the CRC8 calculation of this 1-Wire Network address. |
static boolean |
isValid(String address)
Checks the CRC8 calculation of this 1-Wire Network address. |
static byte[] |
toByteArray(long address)
Convert an iButton or 1-Wire device address as a long (little endian) into an array of bytes. |
static byte[] |
toByteArray(String address)
Converts a 1-Wire Network Address string (big endian) to a byte array (little endian). |
static long |
toLong(byte[] address)
Converts a 1-Wire Network Address to a long (little endian). |
static long |
toLong(String address)
Converts a 1-Wire Network Address to a long (little endian). |
static String |
toString(byte[] address)
Converts a 1-Wire Network address byte array (little endian) to a hex string representation (big endian). |
static String |
toString(long address)
Converts a 1-Wire Network address long (little endian) to a hex string representation (big endian). |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean isValid(byte[] address)
The address is valid if the CRC8 of the first seven bytes of the address gives a result equal to the eighth byte.
address
- iButton or 1-Wire Network address to verifytrue
if the family code is non-zero and the
CRC8 calculation is correct.CRC8
public static boolean isValid(String address)
The address is valid if the CRC8 of the first seven bytes of the address gives a result equal to the eighth byte.
address
- iButton or 1-Wire Network address to verifytrue
if the family code is non-zero and the
CRC8 calculation is correct.CRC8
public static boolean isValid(long address)
The address is valid if the CRC8 of the first seven bytes of the address gives a result equal to the eighth byte.
address
- iButton or 1-Wire Network address to verifytrue
if the family code is non-zero and the
CRC8 calculation is correct.CRC8
public static String toString(byte[] address)
address,
- family code first.public static String toString(long address)
address,
- family code first.public static byte[] toByteArray(String address)
address,
- family code last.public static byte[] toByteArray(long address)
public static long toLong(byte[] address)
public static long toLong(String address)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |