|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.dalsemi.onewire.OneWireAccessProvider
The OneWireAccessProvider class manages the Dallas Semiconductor
adapter class derivatives of DSPortAdapter
. An enumeration of all
available adapters can be accessed through the
member function EnumerateAllAdapters
. This enables an
application to be adapter independent. There are also facilities to get a system
appropriate default adapter/port combination.
try
{
DSPortAdapter adapter = OneWireAccessProvider.getDefaultAdapter();
System.out.println("Adapter: " + adapter.getAdapterName() + " Port: " + adapter.getPortName());
// use the adapter ...
}
catch(Exception e)
{
System.out.println("Default adapter not present: " + e);
}
DSPortAdapter adapter;
String port;
// get the adapters
for (Enumeration adapter_enum = OneWireAccessProvider.enumerateAllAdapters();
adapter_enum.hasMoreElements(); )
{
// cast the enum as a DSPortAdapter
adapter = ( DSPortAdapter ) adapter_enum.nextElement();
System.out.print("Adapter: " + adapter.getAdapterName() + " with ports: ");
// get the ports
for (Enumeration port_enum = adapter.getPortNames();
port_enum.hasMoreElements(); )
{
// cast the enum as a String
port = ( String ) port_enum.nextElement();
System.out.print(port + " ");
}
System.out.println();
}
System.out.println("Default Adapter: " +
OneWireAccessProvider.getProperty("onewire.adapter.default"));
System.out.println("Default Port: " +
OneWireAccessProvider.getProperty("onewire.port.default"));
DSPortAdapter
Method Summary | |
static Enumeration |
enumerateAllAdapters()
Gets an Enumeration of all 1-Wire
adapter types supported. |
static DSPortAdapter |
getAdapter(String adapterName,
String portName)
Finds, opens, and verifies the specified adapter on the indicated port. |
static DSPortAdapter |
getDefaultAdapter()
Finds, opens, and verifies the default adapter and port. |
static String |
getProperty(String propName)
Gets the specfied onewire property. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Method Detail |
public static Enumeration enumerateAllAdapters()
Enumeration
of all 1-Wire
adapter types supported. Using this enumeration with the port enumeration for
each adapter, a search can be done to find all available hardware adapters.Enumeration
of DSPortAdapters
in the systempublic static DSPortAdapter getAdapter(String adapterName, String portName) throws OneWireIOException, OneWireException
adapterName
- string name of the adapter (match to result
of call to getAdapterName() method in DSPortAdapter)portName
- string name of the port used in the method
selectPort() in DSPortAdapterDSPortAdapter
if adapter presentpublic static DSPortAdapter getDefaultAdapter() throws OneWireIOException, OneWireException
DSPortAdapter
if default adapter presentpublic static String getProperty(String propName)
propName
- string name of the property to readString
representing the property value or null
if
it could not be found (onewire.adapter.default
and
onewire.port.default
may
return a 'smart' default even if property not present)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |