Skip to content

Using the C SDK Samples

This section describes how to use the sample C program to send the data from the sample.csv file to the sdk_sample_assembly inside the KX Insights Platform, which can be downloaded using the instructions here.

Downloading

The C SDK samples-${VERSION}.zip, downloaded from the KX Insights Nexus registry), contains the following files:

  • csvupload.c - csv upload source code.
  • CMakeLists.txt - cmake file.
  • sample.csv - sample data based on the sdk_sample_assembly which can be downloaded using the instructions here.

Note

Before using the sample program you need to download and extract the C SDK as described here.

The source code for the sample program can be taken and edited for use inside your applications.

Building

The sample program can be built as follows:

$ cmake .. -DRT_HELPER_INCLUDE_DIR:PATH=../rt_helper/include -DRT_HELPER_LINK_DIR:PATH=../rt_helper && cmake --build .
This should generate an executable csv-upload (extensions will vary depending on the platform).

Application parameters

parameter required default description
-u str Mandatory none Information Service URL - see note below.
-s str Mandatory none Schema - see note below.
-t str Mandatory none Table (for example: "trace")
-r str Optional) /tmp/rt RT directory
-f int Optional) 5000 Time in ms to sleep between fetches of the configuration details from the Information Service.
-c int Optional) 300000 Maximum age of configuration details in ms. After this amount of time, if still unable to fetch a new configuration, the connection is considered to be broken and any subsequent attempts to send data to the KX Insights Platform will fail with Not connected error.
-l int Optional) 600000 Local persistence period (in milliseconds)
-g str Optional) info Log level (example: "info")
-w num Optional) 8 Seconds to wait for the connection to establish.

Notes

  • u str: Information Service URL will be in the following form: 'https://{INSIGHTS_HOSTNAME}/informationservice/details/{KC_CLIENT_ID}'.

  • s str: The schema must match that defined in the pipeline assembly. For schema in the table matches the one in the sdk_sample_assembly, described here, the schema definition is as follows: sensorID:int,captureTS:ts,readTS:ts,valFloat:float,qual:int,alarm:int

Publishing data

The example below runs the csvupload program from the command line just setting the mandatory parameters and using the defaults for the rest:

url="https://{INSIGHTS_HOSTNAME}/informationservice/details/{KC_CLIENT_ID}"
schema="sensorID:int,captureTS:ts,readTS:ts,valFloat:float,qual:byte,alarm:byte"
table="trace"
./csvupload -u $url -s $schema -t $table < ../sample.csv

Supported data types

The following data types are supported by the sample application:

type schema notation example
string string name
symbol symbol LLOY
int int 1
byte byte 0
long long 200000
float float 1.2345
timestamp ts 2000.01.01D00:00:00.000000000