Menu

Java_Protocol_UserGuide

Thierry CHOMAUD

Overview

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

The Protocol API offers services to configure the radio settings, and to send/receive radio message/request/response to one are more radio device.

A more detailed information about Waveport implementation can be obtained from Protocol developer guide [WaveportProtocol_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 Protocol implementation

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

  1. Get the last Coronis Waveport protocol 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)
    • Protocol API (com.coronis.sdk.protocol.api.jar)
    • Coronis Waveport implementation (com.coronis.sdk.protocol.waveport.jar)
    • Coronis Domain module (com.coronis.sdk.domain.jar)
      • It includes the Payload and RadioAddress definition that must be used for Coronis Waveport implementation:
  3. Copy property files:

    • the csrs232driver.properties file to the root of the user project
      • This file contains the default rs232driver configuration and is loaded during initialization step.
    • the cswaveportprotocol.properties file to the root of the user project
      • This file contains the default waveport configuration and is loade during the initialization step.
  4. Add Protocol API, Waveport, SerialDriver API, RS232driver and Domain libraries into the Java build path (project properties)

  5. Execution reference to the Waveport and RS232driver C native libraries:

    • For native Java project, the Waveport and RS232driver C native libraries must be copy to the execution path of the user project (root of the user project)
      • cswaveportprotocol.dll and csrs232driver.dll for Windows platform
      • libcswaveportprotocol.so and libcsrs232driver.so for Linux platform
    • For OSGI module, specific fragments contains the C native libraries and must be added to the execution configuration.
      • com.coronis.sdk.protocol.waveport.win32.x86 and com.coronis.sdk.serialdriver.rs232driver.win32.x86 for Windows platform
      • com.coronis.sdk.protocol.waveport.linux.x86 and com.coronis.sdk.serialdriver.rs232driver.linux.x86 for Linux platform

3. Instanciate Protocol implementation

To use a protocol implementation user has 2 possibilities:

  1. Instanciate class that implements the IProtocolService (Waveport class in this example).
  2. Use the Protocol loader function provided by the domain module (Loader.loadProtocol(String protocolId))

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

Protocol implementation must use a SerialDriver implementation to send frame to the connected radio modem.
To indicate the serial driver implementation to use, many possibilities:

  1. Instanciate class that implements the ISerialDriverService and set this instance to the Protocol implementation using the service setSerialDriverInstance.
  2. Use the protocol service setSerialDriverId to let the protocol implementation automatically instanciate the correspondant SerialDriver instance. (csrs232driver id in this example)

4. Process a Send Request (main program)

In this tutorial, we suppose that user has connected a Waveport radio modem on Port COM4.
We will send the request payload 0x20 to distant device @11604A329237, which correspond to application request GET_TYPE. So we wait for a response that contains a payload which begins with 0xAO (RESPONSE_TO_GET_TYPE)

  1. Here are the main step that must be done before be able to process the request:

    • Instanciation the Waveport class
    • Instanciation the RS232Driver class and port ID setting
    • Configure the Waveport instance
      • serial driver setting
      • initialization (default configuration values)
    • Open the connection
  2. Process the request

  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 protocol 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 Protocol tutorial sources]

This example is available as an eclipse project (com.coronis.sdk.protocol.waveport.example.zip) inside the Coronis WaveportProtocol delivery package.

Going further

To have more details information about Protocol API, refer the documentation Java Protocol API


Related

Wiki: Home
Wiki: Java Protocol tutorial sources
Wiki: WaveportProtocol_DevelopperGuide

MongoDB Logo MongoDB