Overview
This service publishes the org.osgi.service.io.ConnectionFactory interface representing a connection factory for creation of connections based on the comm scheme. It is used by the IO Connector Service, which is exported by the OSGi Connector Bundle.
The Comm Connection Factory handles connection requests for the comm scheme. The created connections are based on javax.microedition.io.StreamConnection and allow read and/or write operations on serial ports. The read operation remains locked until some data is available at the port.
If the provider is unregistered, all created connections are closed.
Registering Bundle
The service is registered by COMM Connection Bundle.
Comm Uniform Resource Identifiers (URIs)
All URIs processed by the Comm Connection Factory start with "comm://". A valid comm URI has the following form:
comm://<port_number>[;<param>=<value>;<param>=<value>...]
where <port_number> stands for the number of the serial port to be used for communication (e.g. 0, 1,...; 0 stands for COM1, 1 for COM2, etc.). The [..] brackets show an optional part, they are not part of the URI itself. They show that a comm URI can optionally have one or more parameters separated by semi-colon. <param> is the name of the parameter, <value> is its value. The following parameters are allowed:
Parameter |
Description |
|---|---|
baudrate |
The baud rate to be set (default value is 115200). |
databits |
The databits to be set. Note that the only valid values are 5, 6, 7 and 8, corresponding to the constants defined in javax.comm.SerialPort (default value is 8). |
stopbits |
The stopbits to be set. Note that the only valid values are 1, 2 and 3, corresponding to the constants defined in javax.comm.SerialPort (default value is 1). |
parity |
The parity scheme to be set, note that the only valid values are 0, 1, 2, 3 and 4, corresponding to the constants defined in javax.comm.SerialPort (default value is 0). |
flowcontrol |
The flow control to be set. Allowed values and descriptions: 0 (FLOWCONTROL_NONE): no flow control 1 (FLOWCONTROL_RTSCTS_IN): RTS/CTS flow control (hardware) 2 (FLOWCONTROL_RTSCTS_OUT): RTS/CTS flow control (hardware) 3 (FLOWCONTROL_XONXOFF_IN): XON/XOFF flow control (software) 4 (FLOWCONTROL_XONXOFF_OUT): XON/XOFF flow control (software) Note that the value can also be a bitmask combination of the above values. The default is 0 (FLOWCONTROL_NONE). |
timeout |
The time in milliseconds to block waiting for available data |
Examples for valid comm URIs:
Note: Some parts of the URI are case sensitive! For details, refer to RFC 2396.
Using the Service
If you want to use the ConnectionFactory Service as an underlying transport implementation for your serial connections, you need the IO Connector Service, exported by the OSGi Connector Bundle . After getting the IO Connector Service, call its method open passing to it the URI for the serial (COM) port you want to connect to. For more information you can also refer to the OSGi IO Connector Service Specification (distributed as part of the OSGi Service Platform Specification, Release 4.2).