All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----javax.comm.CommPortIdentifier
CommPortIdentifier
is the central class for controlling access to communications ports.
It includes methods for:
An application first uses methods in CommPortIdentifier
to negotiate with the driver to discover which communication ports
are available and then select a port for opening. It then uses
methods in other classes like CommPort
, ParallelPort
and SerialPort
to communicate through the port.
portName
to the list of ports.
CommPortIdentifier
object corresponding
to a port that has already been opened by the application.
CommPortIdentifier
object by using a port name.
CommPortIdentifier
object for each port in the system.
FileDescriptor
object on platforms that support this technique.
CommPortOwnershipListener
registered using
addPortOwnershipListener
public static final int PORT_SERIAL
public static final int PORT_PARALLEL
public static Enumeration getPortIdentifiers()
CommPortIdentifier
object for each port in the system.
Enumeration
object that can be used to
enumerate all the ports known to the system
public static CommPortIdentifier getPortIdentifier(String portName) throws NoSuchPortException
CommPortIdentifier
object by using a port name.
The port name may have been stored in persistent storage by the application.
portName
- name of the port to open
CommPortIdentifier
object
public static CommPortIdentifier getPortIdentifier(CommPort port) throws NoSuchPortException
CommPortIdentifier
object corresponding
to a port that has already been opened by the application.
public static void addPortName(String portName, int portType, CommDriver driver)
portName
to the list of ports.
public String getName()
CommPortIdentifier
object using getPortIdentifier(String portName)
method.
public int getPortType()
public synchronized CommPort open(String appname, int timeout) throws PortInUseException
open
obtains
exclusive ownership of the port. If the port is owned by some
other application, a PORT_OWNERSHIP_REQUESTED
event
is propagated using the CommPortOwnershipListener
event mechanism. If the application that owns the port calls
close
during the event processing, then this
open
will succeed.
There is one InputStream
and one OutputStream
associated with each port. After a port is opened with
open
, then all calls to getInputStream
will return the same stream object until close
is called.
CommPort
object
public String getCurrentOwner()
public boolean isCurrentlyOwned()
true
if the port is owned by some application,
false
if the port is not owned.
public void addPortOwnershipListener(CommPortOwnershipListener listener)
PORT_OWNED
: Port became owned
PORT_UNOWNED
: Port became unowned
PORT_OWNERSHIP_REQUESTED
: If the application owns this port
and is willing to give up ownership, then it should call
close
now.
ownershipChange
method of the listener registered
using addPortOwnershipListener
will be called with one
of the above events.
CommPortOwnershipListener
callback object
public void removePortOwnershipListener(CommPortOwnershipListener lsnr)
CommPortOwnershipListener
registered using
addPortOwnershipListener
public CommPort open(FileDescriptor fd) throws UnsupportedCommOperationException
FileDescriptor
object on platforms that support this technique.
FileDescriptor
object used to build
a CommPort
.
CommPort
object.
All Packages Class Hierarchy This Package Previous Next Index