2021-02-09 04:43:58 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/sensors/fakesensor.c
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
2021-07-15 09:44:37 +02:00
|
|
|
#include <string.h>
|
2021-02-09 04:43:58 +01:00
|
|
|
|
|
|
|
#include <nuttx/fs/fs.h>
|
|
|
|
#include <nuttx/kmalloc.h>
|
|
|
|
#include <nuttx/kthread.h>
|
|
|
|
#include <nuttx/nuttx.h>
|
|
|
|
#include <nuttx/semaphore.h>
|
|
|
|
#include <nuttx/sensors/fakesensor.h>
|
|
|
|
#include <nuttx/sensors/sensor.h>
|
2021-03-08 09:52:44 +01:00
|
|
|
#include <nuttx/signal.h>
|
2021-06-30 10:14:13 +02:00
|
|
|
#include <debug.h>
|
2021-02-09 04:43:58 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct fakesensor_s
|
|
|
|
{
|
|
|
|
struct sensor_lowerhalf_s lower;
|
|
|
|
struct file data;
|
2022-03-11 04:03:02 +01:00
|
|
|
unsigned long interval;
|
|
|
|
unsigned long batch;
|
2021-02-09 04:43:58 +01:00
|
|
|
int raw_start;
|
|
|
|
FAR const char *file_path;
|
2021-06-30 10:14:13 +02:00
|
|
|
sem_t wakeup;
|
|
|
|
volatile bool running;
|
2021-02-09 04:43:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int fakesensor_activate(FAR struct sensor_lowerhalf_s *lower,
|
2022-04-14 05:58:35 +02:00
|
|
|
FAR struct file *filep, bool sw);
|
2021-02-09 04:43:58 +01:00
|
|
|
static int fakesensor_set_interval(FAR struct sensor_lowerhalf_s *lower,
|
2022-04-14 05:58:35 +02:00
|
|
|
FAR struct file *filep,
|
2022-03-11 04:03:02 +01:00
|
|
|
FAR unsigned long *period_us);
|
2021-03-08 09:52:44 +01:00
|
|
|
static int fakesensor_batch(FAR struct sensor_lowerhalf_s *lower,
|
2022-04-14 05:58:35 +02:00
|
|
|
FAR struct file *filep,
|
2022-03-11 04:03:02 +01:00
|
|
|
FAR unsigned long *latency_us);
|
2022-05-27 14:40:12 +02:00
|
|
|
static void fakesensor_push_event(FAR struct sensor_lowerhalf_s *lower,
|
|
|
|
uint64_t event_timestamp);
|
2021-02-09 04:43:58 +01:00
|
|
|
static int fakesensor_thread(int argc, char** argv);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static struct sensor_ops_s g_fakesensor_ops =
|
|
|
|
{
|
|
|
|
.activate = fakesensor_activate,
|
|
|
|
.set_interval = fakesensor_set_interval,
|
2021-03-08 09:52:44 +01:00
|
|
|
.batch = fakesensor_batch,
|
2021-02-09 04:43:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int fakesensor_read_csv_line(FAR struct file *file,
|
|
|
|
char *buffer, int len, int start)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
len = file_read(file, buffer, len);
|
|
|
|
if (len == 0)
|
|
|
|
{
|
|
|
|
/* Loop reads */
|
|
|
|
|
|
|
|
file_seek(file, start, SEEK_SET);
|
|
|
|
len = file_read(file, buffer, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
if (buffer[i] == '\n')
|
|
|
|
{
|
|
|
|
file_seek(file, i - len + 1, SEEK_CUR);
|
2021-07-15 09:44:37 +02:00
|
|
|
buffer[i + 1] = '\0';
|
2021-02-09 04:43:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return i + 1;
|
|
|
|
}
|
|
|
|
|
2021-07-15 09:44:37 +02:00
|
|
|
static int fakesensor_read_csv_header(FAR struct fakesensor_s *sensor)
|
2021-02-09 04:43:58 +01:00
|
|
|
{
|
|
|
|
char buffer[40];
|
|
|
|
|
|
|
|
/* Set interval */
|
|
|
|
|
|
|
|
sensor->raw_start =
|
|
|
|
fakesensor_read_csv_line(&sensor->data, buffer, sizeof(buffer), 0);
|
2021-06-30 10:14:13 +02:00
|
|
|
if (sensor->interval == 0)
|
|
|
|
{
|
2022-03-11 04:03:02 +01:00
|
|
|
sscanf(buffer, "interval:%lu\n", &sensor->interval);
|
2021-06-30 10:14:13 +02:00
|
|
|
sensor->interval *= 1000;
|
|
|
|
}
|
2021-02-09 04:43:58 +01:00
|
|
|
|
|
|
|
/* Skip the CSV header */
|
|
|
|
|
|
|
|
sensor->raw_start +=
|
|
|
|
fakesensor_read_csv_line(&sensor->data, buffer, sizeof(buffer), 0);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2022-05-27 14:40:12 +02:00
|
|
|
static inline void fakesensor_read_accel(FAR struct fakesensor_s *sensor,
|
|
|
|
uint64_t event_timestamp)
|
2021-07-15 09:44:37 +02:00
|
|
|
{
|
2022-03-25 11:10:24 +01:00
|
|
|
struct sensor_accel accel;
|
2021-07-15 09:44:37 +02:00
|
|
|
char raw[50];
|
|
|
|
fakesensor_read_csv_line(
|
|
|
|
&sensor->data, raw, sizeof(raw), sensor->raw_start);
|
|
|
|
sscanf(raw, "%f,%f,%f\n", &accel.x, &accel.y, &accel.z);
|
|
|
|
accel.temperature = NAN;
|
2022-05-27 14:40:12 +02:00
|
|
|
accel.timestamp = event_timestamp;
|
2021-07-15 09:44:37 +02:00
|
|
|
sensor->lower.push_event(sensor->lower.priv, &accel,
|
2022-03-25 11:10:24 +01:00
|
|
|
sizeof(struct sensor_accel));
|
2021-07-15 09:44:37 +02:00
|
|
|
}
|
|
|
|
|
2022-05-27 14:40:12 +02:00
|
|
|
static inline void fakesensor_read_mag(FAR struct fakesensor_s *sensor,
|
|
|
|
uint64_t event_timestamp)
|
2021-07-15 09:44:37 +02:00
|
|
|
{
|
2022-03-25 11:10:24 +01:00
|
|
|
struct sensor_mag mag;
|
2021-07-15 09:44:37 +02:00
|
|
|
char raw[50];
|
|
|
|
fakesensor_read_csv_line(
|
|
|
|
&sensor->data, raw, sizeof(raw), sensor->raw_start);
|
|
|
|
sscanf(raw, "%f,%f,%f\n", &mag.x, &mag.y, &mag.z);
|
|
|
|
mag.temperature = NAN;
|
2022-05-27 14:40:12 +02:00
|
|
|
mag.timestamp = event_timestamp;
|
2021-07-15 09:44:37 +02:00
|
|
|
sensor->lower.push_event(sensor->lower.priv, &mag,
|
2022-03-25 11:10:24 +01:00
|
|
|
sizeof(struct sensor_mag));
|
2021-07-15 09:44:37 +02:00
|
|
|
}
|
|
|
|
|
2022-05-27 14:40:12 +02:00
|
|
|
static inline void fakesensor_read_gyro(FAR struct fakesensor_s *sensor,
|
|
|
|
uint64_t event_timestamp)
|
2021-07-15 09:44:37 +02:00
|
|
|
{
|
2022-03-25 11:10:24 +01:00
|
|
|
struct sensor_gyro gyro;
|
2021-07-15 09:44:37 +02:00
|
|
|
char raw[50];
|
|
|
|
fakesensor_read_csv_line(
|
|
|
|
&sensor->data, raw, sizeof(raw), sensor->raw_start);
|
|
|
|
sscanf(raw, "%f,%f,%f\n", &gyro.x, &gyro.y, &gyro.z);
|
|
|
|
gyro.temperature = NAN;
|
2022-05-27 14:40:12 +02:00
|
|
|
gyro.timestamp = event_timestamp;
|
2021-07-15 09:44:37 +02:00
|
|
|
sensor->lower.push_event(sensor->lower.priv, &gyro,
|
2022-03-25 11:10:24 +01:00
|
|
|
sizeof(struct sensor_gyro));
|
2021-07-15 09:44:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void fakesensor_read_gps(FAR struct fakesensor_s *sensor)
|
|
|
|
{
|
2022-03-25 11:10:24 +01:00
|
|
|
struct sensor_gps gps;
|
2021-07-15 09:44:37 +02:00
|
|
|
float time;
|
|
|
|
char latitude;
|
|
|
|
char longitude;
|
|
|
|
int status;
|
|
|
|
int sate_num;
|
|
|
|
float hoop;
|
|
|
|
float altitude;
|
|
|
|
char raw[150];
|
2022-09-06 08:18:45 +02:00
|
|
|
|
2022-03-25 11:10:24 +01:00
|
|
|
memset(&gps, 0, sizeof(struct sensor_gps));
|
2022-09-26 06:56:25 +02:00
|
|
|
|
|
|
|
read:
|
2021-07-15 09:44:37 +02:00
|
|
|
fakesensor_read_csv_line(
|
|
|
|
&sensor->data, raw, sizeof(raw), sensor->raw_start);
|
|
|
|
FAR char *pos = strstr(raw, "GGA");
|
|
|
|
if (pos == NULL)
|
|
|
|
{
|
|
|
|
goto read;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos += 4;
|
|
|
|
sscanf(pos, "%f,%f,%c,%f,%c,%d,%d,%f,%f,", &time, &gps.latitude, &latitude,
|
|
|
|
&gps.longitude, &longitude, &status, &sate_num, &hoop, &altitude);
|
|
|
|
if (latitude == 'S')
|
|
|
|
{
|
|
|
|
gps.latitude = -gps.latitude;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (longitude == 'W')
|
|
|
|
{
|
|
|
|
gps.longitude = -gps.longitude;
|
|
|
|
}
|
|
|
|
|
2021-07-21 13:30:58 +02:00
|
|
|
gps.latitude /= 100.0f;
|
|
|
|
gps.longitude /= 100.0f;
|
|
|
|
|
2021-11-17 03:04:50 +01:00
|
|
|
gps.altitude = altitude;
|
2021-07-15 09:44:37 +02:00
|
|
|
|
|
|
|
sensor->lower.push_event(sensor->lower.priv, &gps,
|
2022-03-25 11:10:24 +01:00
|
|
|
sizeof(struct sensor_gps));
|
2021-07-15 09:44:37 +02:00
|
|
|
}
|
|
|
|
|
2022-04-14 05:58:35 +02:00
|
|
|
static int fakesensor_activate(FAR struct sensor_lowerhalf_s *lower,
|
|
|
|
FAR struct file *filep, bool sw)
|
2021-02-09 04:43:58 +01:00
|
|
|
{
|
|
|
|
FAR struct fakesensor_s *sensor = container_of(lower,
|
|
|
|
struct fakesensor_s, lower);
|
|
|
|
if (sw)
|
|
|
|
{
|
2021-06-30 10:14:13 +02:00
|
|
|
sensor->running = true;
|
2021-02-09 04:43:58 +01:00
|
|
|
|
|
|
|
/* Wake up the thread */
|
|
|
|
|
2021-06-30 10:14:13 +02:00
|
|
|
nxsem_post(&sensor->wakeup);
|
2021-02-09 04:43:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-30 10:14:13 +02:00
|
|
|
sensor->running = false;
|
2021-02-09 04:43:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fakesensor_set_interval(FAR struct sensor_lowerhalf_s *lower,
|
2022-04-14 05:58:35 +02:00
|
|
|
FAR struct file *filep,
|
2022-03-11 04:03:02 +01:00
|
|
|
FAR unsigned long *period_us)
|
2021-02-09 04:43:58 +01:00
|
|
|
{
|
|
|
|
FAR struct fakesensor_s *sensor = container_of(lower,
|
|
|
|
struct fakesensor_s, lower);
|
|
|
|
sensor->interval = *period_us;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2021-03-08 09:52:44 +01:00
|
|
|
static int fakesensor_batch(FAR struct sensor_lowerhalf_s *lower,
|
2022-04-14 05:58:35 +02:00
|
|
|
FAR struct file *filep,
|
2022-03-11 04:03:02 +01:00
|
|
|
FAR unsigned long *latency_us)
|
2021-03-08 09:52:44 +01:00
|
|
|
{
|
|
|
|
FAR struct fakesensor_s *sensor = container_of(lower,
|
|
|
|
struct fakesensor_s, lower);
|
2022-03-25 11:10:24 +01:00
|
|
|
unsigned long max_latency = sensor->lower.nbuffer * sensor->interval;
|
2021-03-08 09:52:44 +01:00
|
|
|
if (*latency_us > max_latency)
|
|
|
|
{
|
|
|
|
*latency_us = max_latency;
|
|
|
|
}
|
|
|
|
else if (*latency_us < sensor->interval && *latency_us > 0)
|
|
|
|
{
|
|
|
|
*latency_us = sensor->interval;
|
|
|
|
}
|
|
|
|
|
|
|
|
sensor->batch = *latency_us;
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2022-05-27 14:40:12 +02:00
|
|
|
void fakesensor_push_event(FAR struct sensor_lowerhalf_s *lower,
|
|
|
|
uint64_t event_timestamp)
|
2021-02-09 04:43:58 +01:00
|
|
|
{
|
|
|
|
FAR struct fakesensor_s *sensor = container_of(lower,
|
|
|
|
struct fakesensor_s, lower);
|
2021-07-15 09:44:37 +02:00
|
|
|
switch (lower->type)
|
|
|
|
{
|
|
|
|
case SENSOR_TYPE_ACCELEROMETER:
|
2022-05-27 14:40:12 +02:00
|
|
|
fakesensor_read_accel(sensor, event_timestamp);
|
2021-07-15 09:44:37 +02:00
|
|
|
break;
|
2021-02-09 04:43:58 +01:00
|
|
|
|
2021-07-15 09:44:37 +02:00
|
|
|
case SENSOR_TYPE_MAGNETIC_FIELD:
|
2022-05-27 14:40:12 +02:00
|
|
|
fakesensor_read_mag(sensor, event_timestamp);
|
2021-07-15 09:44:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SENSOR_TYPE_GYROSCOPE:
|
2022-05-27 14:40:12 +02:00
|
|
|
fakesensor_read_gyro(sensor, event_timestamp);
|
2021-07-15 09:44:37 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SENSOR_TYPE_GPS:
|
|
|
|
fakesensor_read_gps(sensor);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-03-08 09:52:44 +01:00
|
|
|
snerr("fakesensor: unsupported type sensor type\n");
|
2021-07-15 09:44:37 +02:00
|
|
|
break;
|
|
|
|
}
|
2021-02-09 04:43:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int fakesensor_thread(int argc, char** argv)
|
|
|
|
{
|
|
|
|
FAR struct fakesensor_s *sensor = (FAR struct fakesensor_s *)
|
|
|
|
((uintptr_t)strtoul(argv[1], NULL, 0));
|
2021-06-30 10:14:13 +02:00
|
|
|
int ret;
|
2021-02-09 04:43:58 +01:00
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
2021-06-30 10:14:13 +02:00
|
|
|
/* Waiting to be woken up */
|
|
|
|
|
|
|
|
nxsem_wait_uninterruptible(&sensor->wakeup);
|
|
|
|
|
|
|
|
/* Open csv file and init file handle */
|
|
|
|
|
|
|
|
ret = file_open(&sensor->data, sensor->file_path, O_RDONLY);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
snerr("Failed to open file:%s, err:%d", sensor->file_path, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
fakesensor_read_csv_header(sensor);
|
|
|
|
|
|
|
|
while (sensor->running)
|
2021-02-09 04:43:58 +01:00
|
|
|
{
|
2021-03-08 09:52:44 +01:00
|
|
|
/* Sleeping thread for interval */
|
2021-02-09 04:43:58 +01:00
|
|
|
|
2021-03-08 09:52:44 +01:00
|
|
|
nxsig_usleep(sensor->batch ? sensor->batch : sensor->interval);
|
2021-02-09 04:43:58 +01:00
|
|
|
|
2021-03-08 09:52:44 +01:00
|
|
|
/* Notify upper */
|
2021-02-09 04:43:58 +01:00
|
|
|
|
2021-03-08 09:52:44 +01:00
|
|
|
if (sensor->batch)
|
|
|
|
{
|
|
|
|
uint32_t batch_num = sensor->batch / sensor->interval;
|
2022-05-27 14:40:12 +02:00
|
|
|
uint64_t event_timestamp =
|
|
|
|
sensor_get_timestamp() - sensor->interval * batch_num;
|
2023-05-17 22:23:58 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < batch_num; i++)
|
2021-03-08 09:52:44 +01:00
|
|
|
{
|
2022-05-27 14:40:12 +02:00
|
|
|
fakesensor_push_event(&sensor->lower, event_timestamp);
|
|
|
|
event_timestamp += sensor->interval;
|
2021-03-08 09:52:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-27 14:40:12 +02:00
|
|
|
fakesensor_push_event(&sensor->lower, sensor_get_timestamp());
|
2021-03-08 09:52:44 +01:00
|
|
|
}
|
2021-02-09 04:43:58 +01:00
|
|
|
}
|
|
|
|
|
2021-06-30 10:14:13 +02:00
|
|
|
/* Close csv file handle when running change true to false */
|
|
|
|
|
|
|
|
ret = file_close(&sensor->data);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
snerr("Failed to close file:%s, err:%d", sensor->file_path, ret);
|
|
|
|
return ret;
|
2021-02-09 04:43:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: fakesensor_init
|
|
|
|
*
|
|
|
|
* Description:
|
2022-08-08 07:42:03 +02:00
|
|
|
* This function generates a sensor node under /dev/uorb/. And then
|
2021-02-09 04:43:58 +01:00
|
|
|
* report the data from csv file.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
2021-03-08 09:52:44 +01:00
|
|
|
* type - The type of sensor and defined in <nuttx/sensors/sensor.h>
|
|
|
|
* file_name - The name of csv name and the file structure is as follows:
|
|
|
|
* First row : set interval, unit millisecond
|
|
|
|
* Second row: csv file header
|
|
|
|
* third row : data
|
|
|
|
* (Each line should not exceed 50 characters)
|
|
|
|
* For example:
|
|
|
|
* interval:12
|
|
|
|
* x,y,z
|
|
|
|
* 2.1234,3.23443,2.23456
|
|
|
|
* ...
|
|
|
|
* devno - The user specifies which device of this type, from 0.
|
|
|
|
* batch_number- The maximum number of batch
|
2021-02-09 04:43:58 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
2021-03-08 09:52:44 +01:00
|
|
|
int fakesensor_init(int type, FAR const char *file_name,
|
|
|
|
int devno, uint32_t batch_number)
|
2021-02-09 04:43:58 +01:00
|
|
|
{
|
|
|
|
FAR struct fakesensor_s *sensor;
|
|
|
|
FAR char *argv[2];
|
|
|
|
char arg1[32];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Alloc memory for sensor */
|
|
|
|
|
|
|
|
sensor = kmm_zalloc(sizeof(struct fakesensor_s));
|
|
|
|
if (!sensor)
|
|
|
|
{
|
|
|
|
snerr("Memory cannot be allocated for fakesensor\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
sensor->lower.type = type;
|
|
|
|
sensor->lower.ops = &g_fakesensor_ops;
|
2022-03-25 11:10:24 +01:00
|
|
|
sensor->lower.nbuffer = batch_number;
|
2021-02-09 04:43:58 +01:00
|
|
|
sensor->file_path = file_name;
|
|
|
|
|
2021-06-30 10:14:13 +02:00
|
|
|
nxsem_init(&sensor->wakeup, 0, 0);
|
2021-02-09 04:43:58 +01:00
|
|
|
|
|
|
|
/* Create thread for sensor */
|
|
|
|
|
|
|
|
snprintf(arg1, 32, "%p", sensor);
|
|
|
|
argv[0] = arg1;
|
|
|
|
argv[1] = NULL;
|
|
|
|
ret = kthread_create("fakesensor_thread", SCHED_PRIORITY_DEFAULT,
|
2022-03-21 23:47:09 +01:00
|
|
|
CONFIG_DEFAULT_TASK_STACKSIZE,
|
|
|
|
fakesensor_thread, argv);
|
2021-02-09 04:43:58 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
kmm_free(sensor);
|
|
|
|
return ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Register sensor */
|
|
|
|
|
|
|
|
sensor_register(&sensor->lower, devno);
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
2021-07-15 09:44:37 +02:00
|
|
|
|