public interface GenericDevice extends Peripheral
GenericDevice interface defines methods for setting and getting peripheral device-specific configuration
and access (I/O) controls as well as registering event listeners.
An application can set and get configuration and access (I/O) controls. A control is identified by a numerical ID and
can be set or gotten using the setControl(int, java.lang.Object) and getControl(int) methods.
Controls can be used to configured a peripheral device a well as performing basic input/output operations. The list
of controls supported by a peripheral device is peripheral-device-specific.
An application can also register an GenericEventListener instance to monitor native events of the designated
type fired by the peripheral device. To register a GenericEventListener instance, the application must call
the setEventListener(int, GenericEventListener) method. The registered listener can later on be removed by
calling the same method with a null listener parameter. Asynchronous notification may not be supported by all
devices. An attempt to set a listener on a device which does not supports it will result in an
InvalidOperationException being thrown.
A platform implementer may allow through this interface access and control of peripheral devices which do not require
byte stream or buffer I/O (read, write) and for which there exist no other more specific API such as GPIOPin
or GPIOPort.GenericEventListenerBIG_ENDIAN, LITTLE_ENDIAN, MIXED_ENDIAN, UNDEFINED_ID| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
getControl(int id)
Gets the value of the specified control.
|
void |
setControl(int id,
java.lang.Object value)
Sets the value of the specified control.
|
void |
setEventListener(int eventId,
GenericEventListener listener)
Registers a
GenericEventListener instance to monitor native events of the designated type fired by the
peripheral device associated to this GenericDevice object. |
close, getID, getName, getProperties, isOpenjava.lang.Object getControl(int id)
throws java.io.IOException,
PeripheralNotAvailableException
id - the ID of the control to get.java.lang.IllegalArgumentException - if control is not recognized or invalid.java.io.IOException - if an I/O error occurs.PeripheralNotAvailableException - if the peripheral is not currently available (has been closed).void setControl(int id,
java.lang.Object value)
throws java.io.IOException,
PeripheralNotAvailableException
id - the ID of the control to set.value - the value to set.java.lang.IllegalArgumentException - if control is not recognized or invalid.java.io.IOException - if an I/O error occurs.PeripheralNotAvailableException - if the peripheral is not currently available (has been closed).void setEventListener(int eventId,
GenericEventListener listener)
throws java.io.IOException,
PeripheralNotAvailableException
GenericEventListener instance to monitor native events of the designated type fired by the
peripheral device associated to this GenericDevice object. While the listener can be triggered by
hardware interrupts, there are no real-time guarantees of when the listener will be called.
A list of event type IDs is defined in GenericEvent. This list can be extended with peripheral-specific
IDs.
If listener is null then listener previously registered for the specified event type will be
removed.
Only one listener can be registered at a particular time for a particular event type.eventId - ID of the native event to listen to.listener - the GenericEventListener instance to be notified upon occurrence of the designated event.java.io.IOException - if an I/O error occurs.java.lang.IllegalArgumentException - if eventId does not correspond to any supported event.com.oracle.deviceaccess.InvalidOperationException - if this GenericDevice object does not support asynchronous event notification.InvalidStateException - if listener is not null and a listener is already registered for the specified event
type.PeripheralNotAvailableException - if the peripheral is not currently available (has been closed).Copyright (c) 1990, 2013, Oracle and/or its affiliates. All rights reserved.