#include <string.h>
#include "compiler.h"
#include "FreeRTOS.h"
#include "tracedump.h"
#include "supervisor.h"
#include "shell.h"
#include "sensor.h"
#include "temperature.h"
#include "potentiometer.h"
#include "light.h"
#include "pushb.h"
#include "joystick.h"
#include "adc.h"
Data Structures | |
struct | SensorReg |
Macros | |
#define | SENSOR_LIST "{temp,pot,light,pb1,pb2,pb3,js,all}" |
#define | SENSOR_MAXNB_SENSORS (DATALOG_ID_JS - DATALOG_ID_TEMP +1) |
Typedefs | |
typedef struct SensorReg | xSensorReg |
Functions | |
bool | b_sensor_get_value (xLogDef *pxLog) |
Get a current sensor value. More... | |
bool | bsensor_start (void) |
eExecStatus | e_sensor_cmd_get_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The get sensor config command: get the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: get_sensor_config sensorname. More... | |
eExecStatus | e_sensor_cmd_get_value (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The get sensor value command: get current value from a sensor. Format: get_sensor_value sensor=sensorname. More... | |
eExecStatus | e_sensor_cmd_set_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The set sensor config command: set the value of a config field of a sensor. Takes three parameters. The first parameter is the sensor's name, the second parameter is the config field name, the third parameter is the value. Format: set_sensor_config sensorname field=value. More... | |
eExecStatus | e_sensor_help (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The sensor help command: display the sensors available shell commands. Format: help. More... | |
void | v_sensor_stop (void) |
Stop the sensor module resources. More... | |
Variables | |
xSensorReg | axSensorsRegistry [SENSOR_MAXNB_SENSORS] |
const signed portCHAR *const | SENSOR_ERRMSG_GETCFG_SYNTAXERROR = (signed portCHAR *)"Error"CRLF"Usage: get_sensor_config sensor=sensorname"CRLF |
const signed portCHAR *const | SENSOR_ERRMSG_GETVAL_FAIL = (signed portCHAR *)"Error"CRLF"Sensor failed to deliver a value."CRLF |
const signed portCHAR *const | SENSOR_ERRMSG_GETVAL_SYNTAXERROR = (signed portCHAR *)"Error"CRLF"Usage: get_sensor_value sensor=sensorname"CRLF |
const signed portCHAR *const | SENSOR_ERRMSG_SETCFG_SYNTAXERROR = (signed portCHAR *)"Error"CRLF"Usage: set_sensor_config sensor=sensorname param=value"CRLF |
const signed portCHAR *const | SENSOR_ERRMSG_UNREFSENSOR = (signed portCHAR *)"Error"CRLF"Unreferenced sensor name"CRLF |
const signed portCHAR *const | SENSOR_MSG_HELP |
xSemaphoreHandle | xCFGMutex |
#define SENSOR_LIST "{temp,pot,light,pb1,pb2,pb3,js,all}" |
#define SENSOR_MAXNB_SENSORS (DATALOG_ID_JS - DATALOG_ID_TEMP +1) |
Max number of sensors.
Referenced by bsensor_start(), e_sensor_cmd_get_config(), e_sensor_cmd_get_value(), e_sensor_cmd_set_config(), and v_sensor_stop().
typedef struct SensorReg xSensorReg |
A sensor register cell structure.
Get a current sensor value.
pxLog | a Log structure. The sensor id is in the id field of pxLog. |
References b_joystick_get_value(), b_light_get_value(), b_potentiometer_get_value(), b_pushb1_get_value(), b_pushb2_get_value(), b_pushb3_get_value(), b_temperature_get_value(), DATALOG_ID_JS, DATALOG_ID_LIGHT, DATALOG_ID_PB1, DATALOG_ID_PB2, DATALOG_ID_PB3, DATALOG_ID_POT, DATALOG_ID_TEMP, LogDef::id, and TRACE_COM2.
Referenced by v_datalog_AddSensorLog().
Start the sensor module.
References adc, adc_configure(), NAKED_TRACE_COM2, and SENSOR_MAXNB_SENSORS.
Referenced by portTASK_FUNCTION().
eExecStatus e_sensor_cmd_get_config | ( | eModId | xModId, |
signed short | FsNavId, | ||
int | ac, | ||
signed portCHAR * | av[], | ||
signed portCHAR ** | ppcStringReply | ||
) |
The get sensor config command: get the config fields value of a sensor. Takes one parameter, that is the sensor's name. Format: get_sensor_config sensorname.
xModId | Input. The module that is calling this function. |
FsNavId | Ignored. |
ac | Input. The argument counter. For this command, should be 1. |
av | Input. The argument vector. |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
References acLogSourceName, DATALOG_ID_JS, DATALOG_ID_TEMP, NULL, SENSOR_ERRMSG_GETCFG_SYNTAXERROR, SENSOR_ERRMSG_UNREFSENSOR, SENSOR_MAXNB_SENSORS, and SHELL_EXECSTATUS_KO.
eExecStatus e_sensor_cmd_get_value | ( | eModId | xModId, |
signed short | FsNavId, | ||
int | ac, | ||
signed portCHAR * | av[], | ||
signed portCHAR ** | ppcStringReply | ||
) |
The get sensor value command: get current value from a sensor. Format: get_sensor_value sensor=sensorname.
The get sensor value command: get value(s) from a sensor. Takes two parameters, one of which is optional. The first parameter is the sensor's name, the optional parameter is the number of samples requested. Format: get_sensor_value sensorname [nbsamples], when nbsamples is given, the command should give an history of nbsamples-1 logs + the last value.
xModId | Input. The module that is calling this function. |
FsNavId | Ignored. |
ac | Input. The argument counter. For this command, should be 2. |
av | Input. The argument vector. |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
References acLogSourceName, DATALOG_ALLOC_DYNAMIC, DATALOG_ID_JS, DATALOG_ID_TEMP, DATALOG_LOG_MAXSIZE, LogDef::id, NULL, LogDef::pcStringLog, LogDef::pfFreeStringLog, pvPortMalloc(), pxdatalog_log_alloc_init(), SENSOR_ERRMSG_GETVAL_FAIL, SENSOR_ERRMSG_GETVAL_SYNTAXERROR, SENSOR_ERRMSG_UNREFSENSOR, SENSOR_MAXNB_SENSORS, SHELL_ERRMSG_MEMALLOC, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, vdatalog_log_free(), vdatalog_make_logstring(), and vPortFree().
eExecStatus e_sensor_cmd_set_config | ( | eModId | xModId, |
signed short | FsNavId, | ||
int | ac, | ||
signed portCHAR * | av[], | ||
signed portCHAR ** | ppcStringReply | ||
) |
The set sensor config command: set the value of a config field of a sensor. Takes three parameters. The first parameter is the sensor's name, the second parameter is the config field name, the third parameter is the value. Format: set_sensor_config sensorname field=value.
xModId | Input. The module that is calling this function. |
FsNavId | Ignored. |
ac | Input. The argument counter. For this command, should be 3. |
av | Input. The argument vector. |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
References acLogSourceName, DATALOG_ID_JS, DATALOG_ID_TEMP, NULL, pdFALSE, SensorReg::pfSetSensorConfig, SENSOR_ERRMSG_SETCFG_SYNTAXERROR, SENSOR_ERRMSG_UNREFSENSOR, SENSOR_MAXNB_SENSORS, SHELL_ERRMSG_MAINTENANCEMODE, SHELL_EXECSTATUS_KO, x_supervisor_SemaphoreGive(), and x_supervisor_SemaphoreTake().
eExecStatus e_sensor_help | ( | eModId | xModId, |
signed short | FsNavId, | ||
int | ac, | ||
signed portCHAR * | av[], | ||
signed portCHAR ** | ppcStringReply | ||
) |
The sensor help command: display the sensors available shell commands. Format: help.
xModId | Input. The module that is calling this function. |
FsNavId | Ignored. |
ac | Ignored. |
av | Ignored. |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
References NULL, SENSOR_MSG_HELP, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK_NO_FREE.
Referenced by e_Shell_help().
Stop the sensor module resources.
References NULL, SensorReg::pfStopSensor, and SENSOR_MAXNB_SENSORS.
Referenced by e_syscmds_reboot().
xSensorReg axSensorsRegistry[SENSOR_MAXNB_SENSORS] |
const signed portCHAR* const SENSOR_ERRMSG_GETCFG_SYNTAXERROR = (signed portCHAR *)"Error"CRLF"Usage: get_sensor_config sensor=sensorname"CRLF |
Error msg upon get_sensor_config syntax error.
Referenced by e_sensor_cmd_get_config().
const signed portCHAR* const SENSOR_ERRMSG_GETVAL_FAIL = (signed portCHAR *)"Error"CRLF"Sensor failed to deliver a value."CRLF |
Error msg upon get_sensor_value sensor error.
Referenced by e_sensor_cmd_get_value().
const signed portCHAR* const SENSOR_ERRMSG_GETVAL_SYNTAXERROR = (signed portCHAR *)"Error"CRLF"Usage: get_sensor_value sensor=sensorname"CRLF |
Error msg upon get_sensor_value syntax error.
Referenced by e_sensor_cmd_get_value().
const signed portCHAR* const SENSOR_ERRMSG_SETCFG_SYNTAXERROR = (signed portCHAR *)"Error"CRLF"Usage: set_sensor_config sensor=sensorname param=value"CRLF |
Error msg upon get_sensor_config syntax error.
Referenced by e_sensor_cmd_set_config().
const signed portCHAR* const SENSOR_ERRMSG_UNREFSENSOR = (signed portCHAR *)"Error"CRLF"Unreferenced sensor name"CRLF |
Error msg upon unreferenced sensor error.
Referenced by e_sensor_cmd_get_config(), e_sensor_cmd_get_value(), and e_sensor_cmd_set_config().
const signed portCHAR* const SENSOR_MSG_HELP |
Referenced by e_sensor_help().
xSemaphoreHandle xCFGMutex |
The CFG system mutex.