Menu

Java_SerialDriver_UserGuide

Thierry CHOMAUD

Overview

The Coronis SDK - SerialDriver API allows connecting your modem through a serial driver low level protocol.
Only the Coronis rs232Driver implementation is available in the current version.

The Serial Driver API offer service to manage the dataflow on the serial port and ensures to the upper layer that provided data are correct and correspond to those sent by the RF Modem:
open, close, send, receive, etc.

A more detailed information about RS232Driver implementation can be obtained from Serial Driver developer guide [RS232Driver_DevelopperGuide]

Getting started

1. Create user Java project

First, you have to create a new Java project into eclipse environment.
Coronis SDK has been design with JDK1.5.

2. Import SerialDriver implementation

In this tutorial, we will use the Coronis RS232Driver implementation of SerialDriver API.
The Java implementation is based on the C native implementation.

  1. Get the last Coronis RS232Driver delivery package

  2. Copy the following java libraries into a subfolder lib of the user project:

    • SerialDriver API (com.coronis.sdk.serialdriver.api.jar)
    • Coronis RS232driver implementation (com.coronis.sdk.serialdriver.rs232driver.jar)
    • Coronis Domain module (com.coronis.sdk.domain.jar)
      • It includes the SerialFrame definition that must be used for Coronis RS232Driver implementation:
  3. Copy the csrs232driver.properties file to the root of the user project

    • This file contains the default rs232driver configuration and is loaded during the initialization step.
  4. Add SerialDriver API, RS232driver and Domain libraries into the Java build path (project properties)

  5. Execution reference to the RS232driver C native library:

    • For native Java project, the RS232driver C native library must be copy to the execution path of the user project (root of the user project)
      • csrs232driver.dll for Windows platform
      • libcsrs232driver.so for Linux platform
    • For OSGI module, the specific fragment, which contains the C native library must be added to the execution configuration.
      • com.coronis.sdk.serialdriver.rs232driver.win32.x86 for Windows platform
      • com.coronis.sdk.serialdriver.rs232driver.linux.x86 for Linux platform

3. Instanciate SerialDriver implementation

To use a serial driver implementation user has 2 possibilities:

  1. Instanciate class that implements the ISerialDriverService (RS232Driver class in this example).
  2. Use the SerialDriver loader function provided by the domain module (Loader.loadSerialDriver(String serialDriverId))

The second possibility is recommended for usage in OSGI context (dynamic module system for java).

4. Send frame (main program)

In this tutorial, we suppose that user has connected a Waveport radio modem on Port COM4.
We will send the frame 0x5005, which correspond to the local service request READ_RADIO_ADDRESS. So we must receive spontaneously after the sending, a frame which begins with 0x51

  1. Here are the main step that must be done before be able to send the frame:

    • Instanciation the RS232Driver class
    • Configure the instance
      • port ID setting
      • initialization (default configuration values)
    • Register a listener to receive spontaneous frame
    • Open the connection
  2. Send the frame

  3. At the end, following steps must be done before quit the program:

    • Close the current connection

5. Activate the Coronis Domain logger (optional)

Coronis Domain module offers a logging feature, that is used by the rs232driver implementation to give internal process information.
The Java implementation of the logger feature is based on the C native implementation, thus a reference to the Domain C native library must be done in the execution context.

To activate it, user has to follow these steps:

  1. Make the execution reference to the Domain C native library:
    • For native Java project, the Domain C native library must be copy to the execution path of the user project (root of the user project)
      • csdomain.dll for Windows platform
      • libcsdomain.so for Linux platform
    • For OSGI module, the specific fragment, which contains the C native library must be added to the execution configuration.
      • com.coronis.sdk.domain.win32.x86 for Windows platform
      • com.coronis.sdk.domain.linux.x86 for Linux platform
  2. Copy the cslogger.properties file to the root of your project
    • Edit the logger properties if needed (log level, destination file)

Resources

Source of main program can be found here : [Java Serial Driver tutorial sources]

This example is available as an eclipse project (com.coronis.sdk.serialdriver.rs232driver.example.zip) inside the Coronis RS232Driver delivery package.

Going further

To have more details information about Serial Driver API, refer the documentation Java SerialDriver API


Related

Wiki: Home
Wiki: Java Serial Driver tutorial sources
Wiki: RS232Driver_DevelopperGuide

MongoDB Logo MongoDB