Module de.ibapl.spsw.jniprovider
Package de.ibapl.spsw.jniprovider
Class SerialPortSocketFactoryImpl
- java.lang.Object
-
- de.ibapl.spsw.jniprovider.SerialPortSocketFactoryImpl
-
- All Implemented Interfaces:
SerialPortSocketFactory
public class SerialPortSocketFactoryImpl extends Object implements SerialPortSocketFactory
Impements the SerialPortSocketFactory.- Author:
- Arne Plöse
-
-
Field Summary
Fields Modifier and Type Field Description protected static LoggerLOG-
Fields inherited from interface de.ibapl.spsw.api.SerialPortSocketFactory
DEFAULT_DARWIN_DEVICE_PATH, DEFAULT_DARWIN_PORTNAME_PATTERN, DEFAULT_FREE_BSD_DEVICE_PATH, DEFAULT_FREE_BSD_PORTNAME_PATTERN, DEFAULT_LINUX_DEVICE_PATH, DEFAULT_LINUX_PORTNAME_PATTERN, DEFAULT_OPEN_BSD_DEVICE_PATH, DEFAULT_OPEN_BSD_PORTNAME_PATTERN, DEFAULT_SUNOS_DEVICE_PATH, DEFAULT_SUNOS_PORTNAME_PATTERN, DEFAULT_WINDOWS_DEVICE_PATH, DEFAULT_WINDOWS_PORTNAME_PATTERN
-
-
Constructor Summary
Constructors Constructor Description SerialPortSocketFactoryImpl()Do not load the native library here on failure it may throw up the running framework (OSGi, JEE, Spring...)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate()Load the native library in the right lifecycle for the running framework (OSGi, JEE, Spring).voiddeActivate()protected static voiddoSystemLoad(String absoluteLibName)static StringgetLibName()List<String>getPortNames(boolean hideBusyPorts)Get sorted List of serial ports in the system using default settings:List<String>getPortNames(String portToInclude, boolean hideBusyPorts)voidgetPortNames(BiConsumer<String,Boolean> portNameConsumer)protected StringgetPortnamesPath()protected PatterngetPortnamesRegExp()protected List<String>getUnixBasedPortNames(String portToInclude, boolean hideBusyPorts)Universal method for getting port names of _nix based systemsprotected LinkedList<String>getWindowsBasedPortNames()protected List<String>getWindowsPortNames(String portToInclude, boolean hideBusyPorts)Get serial port names in WindowsSerialPortSocketopen(String portName)SerialPortSocketopen(String portName, Speed speed, DataBits dataBits, StopBits stopBits, Parity parity, Set<FlowControl> flowControls)AsyncSerialPortSocketopenAsync(String portName, Speed speed, DataBits dataBits, StopBits stopBits, Parity parity, Set<FlowControl> flowControls, ExecutorService executor)AsyncSerialPortSocketopenAsync(String portName, ExecutorService executor)static booleantouchNativeLib()
-
-
-
Field Detail
-
LOG
protected static final Logger LOG
-
-
Method Detail
-
doSystemLoad
protected static void doSystemLoad(String absoluteLibName)
-
touchNativeLib
public static boolean touchNativeLib()
-
getLibName
public static String getLibName()
-
getWindowsBasedPortNames
protected LinkedList<String> getWindowsBasedPortNames()
-
open
public SerialPortSocket open(String portName) throws IOException
- Specified by:
openin interfaceSerialPortSocketFactory- Throws:
IOException
-
getPortnamesPath
protected String getPortnamesPath()
-
getPortnamesRegExp
protected Pattern getPortnamesRegExp()
-
getPortNames
public List<String> getPortNames(boolean hideBusyPorts)
Get sorted List of serial ports in the system using default settings:- Specified by:
getPortNamesin interfaceSerialPortSocketFactory
-
getPortNames
public List<String> getPortNames(String portToInclude, boolean hideBusyPorts)
- Specified by:
getPortNamesin interfaceSerialPortSocketFactory
-
getWindowsPortNames
protected List<String> getWindowsPortNames(String portToInclude, boolean hideBusyPorts)
Get serial port names in Windows- Since:
- 2.3.0
-
getUnixBasedPortNames
protected List<String> getUnixBasedPortNames(String portToInclude, boolean hideBusyPorts)
Universal method for getting port names of _nix based systems
-
activate
public void activate()
Load the native library in the right lifecycle for the running framework (OSGi, JEE, Spring).
-
deActivate
public void deActivate()
-
open
public SerialPortSocket open(String portName, Speed speed, DataBits dataBits, StopBits stopBits, Parity parity, Set<FlowControl> flowControls) throws IOException, IllegalStateException
- Specified by:
openin interfaceSerialPortSocketFactory- Throws:
IOExceptionIllegalStateException
-
getPortNames
public void getPortNames(BiConsumer<String,Boolean> portNameConsumer)
- Specified by:
getPortNamesin interfaceSerialPortSocketFactory
-
openAsync
public AsyncSerialPortSocket openAsync(String portName, ExecutorService executor) throws IOException, IllegalStateException
- Specified by:
openAsyncin interfaceSerialPortSocketFactory- Throws:
IOExceptionIllegalStateException
-
openAsync
public AsyncSerialPortSocket openAsync(String portName, Speed speed, DataBits dataBits, StopBits stopBits, Parity parity, Set<FlowControl> flowControls, ExecutorService executor) throws IOException
- Specified by:
openAsyncin interfaceSerialPortSocketFactory- Throws:
IOException
-
-