Atmel Software Framework

avr32/applications/evk1100-control-panel/sensors/sensor.h File Reference
#include "compiler.h"
#include "FreeRTOS.h"
#include "shell.h"
#include "datalog.h"

Macros

#define SENSOR_MSG_ALARM_OFF   "alarm=off"CRLF
 
#define SENSOR_MSG_ALARM_ON   "alarm=on"CRLF
 
#define SENSOR_MSG_CONFIG_SET   SHELL_MSG_CONFIG_SET
 

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 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. 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...
 

bool b_sensor_get_value ( xLogDef pxLog)

Get a current sensor value.

Parameters
pxLoga Log structure. The sensor id is in the id field of pxLog.
Returns
true upon success, false if error.

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().

bool bsensor_start ( void  )

Start the sensor module.

Returns
true upon success, else false.

References adc, adc_configure(), i, 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.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acInput. The argument counter. For this command, should be 1.
avInput. The argument vector.
ppcStringReplyInput/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.
Returns
the status of the command execution.

References acLogSourceName, DATALOG_ID_JS, DATALOG_ID_TEMP, i, 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 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.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acInput. The argument counter. For this command, should be 1 or 2.
avInput. The argument vector.
ppcStringReplyInput/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.
Returns
the status of the command execution.

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.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acInput. The argument counter. For this command, should be 2.
avInput. The argument vector.
ppcStringReplyInput/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.
Returns
the status of the command execution.

References acLogSourceName, DATALOG_ALLOC_DYNAMIC, DATALOG_ID_JS, DATALOG_ID_TEMP, DATALOG_LOG_MAXSIZE, end, i, 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.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acInput. The argument counter. For this command, should be 3.
avInput. The argument vector.
ppcStringReplyInput/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.
Returns
the status of the command execution.

References acLogSourceName, DATALOG_ID_JS, DATALOG_ID_TEMP, i, 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.

Note
This function must be of the type pfShellCmd defined by the shell module.
Parameters
xModIdInput. The module that is calling this function.
FsNavIdIgnored.
acIgnored.
avIgnored.
ppcStringReplyInput/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.
Returns
the status of the command execution.

References NULL, SENSOR_MSG_HELP, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK_NO_FREE.

Referenced by e_Shell_help().

void v_sensor_stop ( void  )

Stop the sensor module resources.

References i, NULL, SensorReg::pfStopSensor, and SENSOR_MAXNB_SENSORS.

Referenced by e_syscmds_reboot().