summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore8
-rw-r--r--README.md21
-rw-r--r--binding/iiodevices-binding.c29
-rw-r--r--conf.d/cmake/config.cmake3
4 files changed, 36 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..23c5802
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+build*
+nbproject/private
+.vscode
+.stfolder
+.*.sw*
+*.tar.gz
+__*
+htdocs/node_modules
diff --git a/README.md b/README.md
index 7193461..e712116 100644
--- a/README.md
+++ b/README.md
@@ -2,14 +2,14 @@
## Overview
-iiodevices service allows getting data from iiodevices. For now it allows to
-to get data from acceleration, gyroscope and electronic compass.
+The iiodevices service provides access to data from industrial i/o devices.
+For now it permits to get data from acceleration, gyroscope and electronic compass.
## General Scheme
As soon as a client subscribes to the agl-service-iiodevices binding,
-the binding gets values from sensors and send it to subscribers as events.
-Subscribers can choose their frequency and indicates what values they wants at
+the binding reads values from the sensors and sends it to subscribers as events.
+Subscribers can choose their frequency and indicate what values they want at
subscription.
## Verbs
@@ -29,18 +29,17 @@ For now, there are 3 different events matching with the different available sens
## Frequency
-Frequency is in Hertz, if the frequency is not filled, events are triggered via file descriptor.
+The frequency is in Hertz, if the frequency is not set, events are triggered via a file descriptor.
## Remaining issues
-- Provide a json config file so that configures the device name and the channel name.
-- Handle several values simultaneously, see trigger
-- Update it to other iiodevices
-- channel static infos: add suffix in json for each different static infos between channels
-- read channel values only for the maximum frequency
+- Provide a json config file so that it configures the device name and the channel name.
+- Handle several values simultaneously, see triggers.
+- Update it to other iiodevices.
+- only read channel values at the maximum frequency.
## M3ULCB Kingfisher
M3ULCB Kingfisher is equipped with a 9 axis sensor device (LSM9DS0) and the R-Car Starter
-Kit can read sensor value via I2C interface and iiodevices is provided for
+Kit can read sensor values via I2C interface and iiodevices are provided for
these sensors.
diff --git a/binding/iiodevices-binding.c b/binding/iiodevices-binding.c
index a7cb3d6..8e18fd0 100644
--- a/binding/iiodevices-binding.c
+++ b/binding/iiodevices-binding.c
@@ -9,6 +9,7 @@
#include <sys/ioctl.h>
#include <systemd/sd-event.h>
#include <time.h>
+#include <limits.h>
#include <json-c/json.h>
#define AFB_BINDING_VERSION 2
@@ -22,7 +23,7 @@
struct channels {
struct iio_channel *chn;
enum iio_elements iioelts;
- char name[100];
+ char name[PATH_MAX];
struct channels *next;
};
@@ -45,7 +46,7 @@ struct event
{
struct event *next;
struct afb_event event;
- char tag[100];
+ char tag[PATH_MAX];
};
/*events*/
@@ -88,7 +89,7 @@ static struct afb_event* event_add(const char *tag)
/* creation */
e = malloc(strlen(tag) + sizeof *e);
if (!e) return NULL;
- strcpy(e->tag, tag);
+ strncpy(e->tag, tag, PATH_MAX);
/* make the event */
e->event = afb_daemon_make_event(tag);
@@ -120,7 +121,7 @@ static int event_del(struct afb_event *event)
return 0;
}
-/*initialse iio context*/
+/*initialise iio context*/
int init_context()
{
ctx = iio_create_local_context();
@@ -158,8 +159,9 @@ static int read_infos(struct client_sub* client)
return -1;
}
json_object *jobject = NULL;
- char val[100];
- char keyfirst[100];
+ size_t size = 1000;
+ char val[size];
+ char keyfirst[size];
struct channels *channel = client->channels;
//read all infos
@@ -182,7 +184,7 @@ static int read_infos(struct client_sub* client)
/*no id_attr: looking for an already changed id*/
if(!json_object_object_get_ex(client->jobject, id_attr, &jobject))
{
- strcpy(keyfirst, id_attr);
+ strncpy(keyfirst, id_attr, size);
set_channel_name(keyfirst, client->channels->iioelts);
if(!json_object_object_get_ex(client->jobject, keyfirst, &jobject)) {
AFB_WARNING("cannot find %s keyfirst in json object",
@@ -192,14 +194,14 @@ static int read_infos(struct client_sub* client)
const char * valfisrt = json_object_get_string(jobject); //get first value channel
if(strcasecmp(val, valfisrt)) { //different value store it
- char key[100];
- strcpy(key, id_attr);
+ char key[size];
+ strncpy(key, id_attr, size);
set_channel_name(key, channel->iioelts); //add channel suffix
json_object *value = json_object_new_string(val);
json_object_object_add(client->jobject, key, value);
//remove previous non unique key and replace it with suffix
- strcpy(keyfirst, id_attr);
+ strncpy(keyfirst, id_attr, size);
set_channel_name(keyfirst, client->channels->iioelts);
json_object *valuefirst = json_object_new_string(valfisrt);
json_object_object_add(client->jobject, keyfirst, valuefirst);
@@ -363,8 +365,9 @@ static void init_event_io(struct client_sub *client)
read_infos(client); //get unchanged infos
sd_event_source *source = NULL;
if(client->u_period <= 0) { //no given frequency
- char filename[100];
- sprintf(filename, IIODEVICE"%s/%s", iio_device_get_id(client->dev),
+ char filename[PATH_MAX];
+ snprintf(filename, PATH_MAX,
+ IIODEVICE"%s/%s", iio_device_get_id(client->dev),
iio_channel_attr_get_filename(client->channels->chn, "raw"));
if((client->fd = open(filename, O_RDONLY)) < 0) {
AFB_ERROR("cannot open %s file", filename);
@@ -394,7 +397,7 @@ static struct channels* set_channel(
chn->iioelts = i;
/*set channel name with iio_elements*/
- strcpy(chn->name, client->infos->id);
+ strncpy(chn->name, client->infos->id, PATH_MAX);
set_channel_name(chn->name, i);
if(!(chn->chn = iio_device_find_channel(client->dev, chn->name, false))) {
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index 548d3c4..8d2433f 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -70,7 +70,8 @@ set (PKG_REQUIRED_LIST
libsystemd>=222
glib-2.0
gobject-2.0
- libiio
+ libiio
+ afb-daemon>=4.0
)
# Static constante definition