P - the peripheral type the descriptor is defined for.public interface Peripheral<P extends Peripheral<? super P>>
extends java.nio.channels.Channel
Peripheral interface represents peripheral devices in the system. This interface provides generic methods
for handling peripherals. Peripheral interface.
When a peripheral device is open in shared mode then access synchronization may be performed by invoking tryLock(int) and
unlock(). Peripheral locks are held on a per Peripheral instance basis. When the same peripheral device
is open twice in shared access mode by the same application, locking one of the Peripheral instances will prevent
the other form being accessed/used.| Modifier and Type | Field and Description |
|---|---|
static int |
BIG_ENDIAN
Big-endian byte or bit ordering.
|
static int |
LITTLE_ENDIAN
Little-endian byte or bit ordering.
|
static int |
MIXED_ENDIAN
Mixed-endian (non-standard) byte ordering.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this peripheral device, relinquishing the underlying peripheral device resource and making it available to other
applications.
|
<U extends P> |
getDescriptor()
Retrieves the identifying and descriptive information of this peripheral device.
|
boolean |
isOpen()
Indicates whether or not this peripheral is open/available to the calling application.
|
void |
tryLock(int timeout)
Attempts to lock for (platform-wide) exclusive access the underlying peripheral device resource.
|
void |
unlock()
Releases from (platform-wide) exclusive access the underlying peripheral device resource.
|
static final int BIG_ENDIAN
static final int LITTLE_ENDIAN
static final int MIXED_ENDIAN
void tryLock(int timeout)
throws UnavailablePeripheralException,
ClosedPeripheralException,
java.io.IOException
Peripheral instance or the specified
amount of real time has elapsed. A timeout of 0 means to wait forever.
This method returns silently if the underlying peripheral device resource is open in exclusive access mode
or is already acquired for exclusive access (locked).timeout - the timeout in milliseconds.java.lang.IllegalArgumentException - if timeout is negative.UnavailablePeripheralException - if this peripheral is not currently available.ClosedPeripheralException - if this peripheral has been closed.java.io.IOException - if any other I/O error occurred.void close()
throws java.io.IOException
Peripheral instance will result in a
ClosedPeripheralException being thrown.
This method has no effects if the peripheral device has already been closed.close in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channelclose in interface java.io.Closeablejava.io.IOException - if an I/O error occurs.boolean isOpen()
isOpen in interface java.nio.channels.Channeltrue if, and only if, this peripheral is open; false otherwise.void unlock()
throws java.io.IOException
java.io.IOException - if any other I/O error occurred.<U extends P> PeripheralDescriptor<U> getDescriptor()
Copyright © 2012, 2013, Oracle and/or its affiliates. All rights reserved.
Legal Notices