com.engidea.comm
Class CommPortIdentifier
java.lang.Object
com.engidea.comm.CommPortIdentifier
- Direct Known Subclasses:
- WinjcomIdentifier
public abstract class CommPortIdentifier
- extends java.lang.Object
Devices are obtained from concrete instance of this class.
A real device driver provides you with a class that extends/implements this abstract that provides with a
means to obtain a port. As an example a concrete class for this abstrac class can be WinjcomIdentifier,
other driver writes may create WinparallelIdentifier and so on so forth.
Of course you end up with many differnt Class names, but this would have happened anyway since the development
of this is not centralized. SOmeone could always end up with a GlobalportIdentifier that is able to
scan all ports and do automagic things, then good, we will use that, then :-)
When you new this class the native library is loaded and initialized.
Method Summary |
abstract CommPort |
getCommPort(java.lang.String portName)
Given a port name will return the CommPort that you can use to do IO. |
abstract java.util.List |
getCommPortList()
Each time you call this one the driver will try to scan the system again for the
ports that are attached. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CommPortIdentifier
public CommPortIdentifier()
getCommPort
public abstract CommPort getCommPort(java.lang.String portName)
- Given a port name will return the CommPort that you can use to do IO.
Note that the given CommPort is NOT open, yet, and only when you try to open it
you can discover if it is really present or if somebody else has it already opened.
NOTE: This must NOT rely on the fact that Java has "discovered" the list of ports since
the discovery mechanism may fail and there should be a way for the user to open the port anyway !
This is the preferred way to get a CommPort, but you may be able to get it in other ways
if the implementation allows you.
NOTE: The returned CommPort is most likely always a new port, in other words do NOT rely
on the fact that you get the same object given the same name.
- Parameters:
portName
-
- Returns:
- a CommPort that you can then try to open
getCommPortList
public abstract java.util.List getCommPortList()
- Each time you call this one the driver will try to scan the system again for the
ports that are attached. This is so you can rediscover ports that have been attached
at runtime. Note however that the discovery mechanism may as well fail (not find an available port)
and you can always use the getCommPort to get such " hidden" ports.
- Returns:
- a List of CommPort objects present in the system.