Microchip® Advanced Software Framework

datalog.h File Reference
#include <time.h>
#include "FreeRTOS.h"
#include "supervisor.h"

Data Structures

struct  LogDef
 

Macros

#define DATALOG_ALLOC_DYNAMIC   true
 
#define DATALOG_ALLOC_STATIC   false
 
#define DATALOG_LOG_MAXSIZE   64
 
#define pxdatalog_log_alloc_init_FromISR()   pxdatalog_log_alloc_init( DATALOG_ALLOC_STATIC )
 Allocate and init a xLogDef structure from an ISR. More...
 

Typedefs

typedef struct LogDef xLogDef
 

Enumerations

enum  eLogSourceId {
  DATALOG_ID_TEMP,
  DATALOG_ID_POT,
  DATALOG_ID_LIGHT,
  DATALOG_ID_PB1,
  DATALOG_ID_PB2,
  DATALOG_ID_PB3,
  DATALOG_ID_JS,
  DATALOG_ID_LEDB1,
  DATALOG_ID_LEDB2,
  DATALOG_ID_LEDM1,
  DATALOG_ID_LEDM2,
  DATALOG_ID_LCD
}
 

Functions

bool b_datalog_set_current_log_drive_toDF (void)
 Set the current logs to be stored to the DataFlash. More...
 
bool b_datalog_set_current_log_drive_toSDMMC (void)
 Set the current logs to be stored to the SDMMC card. More...
 
bool bdatalog_start (unsigned portBASE_TYPE uxPriority)
 
xLogDefpxdatalog_log_alloc_init (bool bAllocType)
 Allocate and init a xLogDef structure. More...
 
void vdatalog_log_free (xLogDef *pxLog)
 Free a data log structure and its content. More...
 
void vdatalog_make_logstring (xLogDef *pxLog, signed portCHAR *pcLogString)
 Build a log string from a xLogDef log structure. More...
 
portBASE_TYPE x_datalog_AddLogFromISR (xLogDef *pxLog)
 Add a log in the xLogsQueue, from within an ISR. More...
 
eStatus xDataLog_GetStatus (void)
 

Variables

char * acLogSourceName []
 

#define DATALOG_ALLOC_DYNAMIC   true
#define DATALOG_ALLOC_STATIC   false
#define DATALOG_LOG_MAXSIZE   64

A data log max size.

Referenced by e_actuator_cmd_get_value(), and e_sensor_cmd_get_value().

#define pxdatalog_log_alloc_init_FromISR ( )    pxdatalog_log_alloc_init( DATALOG_ALLOC_STATIC )

Allocate and init a xLogDef structure from an ISR.

Returns
Pointer on an xLogDef structure or NULL if the alloc failed.

Referenced by prvjoystick_ISR_NonNakedBehaviour(), and prvpushb_ISR_NonNakedBehaviour().

typedef struct LogDef xLogDef

A data log structure.

Logs Sources(sensors and actuators) id.

Enumerator
DATALOG_ID_TEMP 
DATALOG_ID_POT 
DATALOG_ID_LIGHT 
DATALOG_ID_PB1 
DATALOG_ID_PB2 
DATALOG_ID_PB3 
DATALOG_ID_JS 
DATALOG_ID_LEDB1 
DATALOG_ID_LEDB2 
DATALOG_ID_LEDM1 
DATALOG_ID_LEDM2 
DATALOG_ID_LCD 

bool b_datalog_set_current_log_drive_toDF ( void  )

Set the current logs to be stored to the DataFlash.

Returns
true

References acLogFileName, pcStringCurrentLogDirectoryName, pcStringLogDirectoryNameA, and pdTRUE.

bool b_datalog_set_current_log_drive_toSDMMC ( void  )

Set the current logs to be stored to the SDMMC card.

Returns
true

References acLogFileName, pcStringCurrentLogDirectoryName, pcStringLogDirectoryNameB, and pdTRUE.

bool bdatalog_start ( unsigned portBASE_TYPE  uxPriority)

Start the data logger module.

Parameters
uxPriorityThe base priority of the data logger tasks.
Returns
true upon success, else false.

References DATALOG_INVALID_LOGSRC_ID, DATALOG_LOGSQUEUE_HITHRESHOLD, DATALOG_LOGSQUEUE_SIZE, DATALOG_STACK_SIZE, LOGTOFILE_STACK_SIZE, NULL, pcStringCurrentLogDirectoryName, pcStringLogDirectoryNameA, pdPASS, SYS_STATUS_DOWN, vTaskDelete(), xDataLogHndl, xDataLogStatus, xLogToFileHndl, xQueueCreate(), and xTaskCreate.

Referenced by portTASK_FUNCTION().

xLogDef* pxdatalog_log_alloc_init ( bool  bAllocType)

Allocate and init a xLogDef structure.

Parameters
bAllocTypeAllocation type (dynamic or static)
Returns
Pointer on an xLogDef structure or NULL if the alloc failed.
Parameters
bAllocTypeAllocation type (dynamic or static(FromISR))
Returns
Pointer on an xLogDef structure or NULL if the alloc failed.

References DATALOG_ALLOC_DYNAMIC, DATALOG_INVALID_LOGSRC_ID, DATALOG_LOGSQUEUE_HITHRESHOLD, NULL, LogDef::pcStringLog, LogDef::pfFreeLogStruct, LogDef::pfFreeStringLog, prv_vdatalog_pool_log_free(), pvPortMalloc(), LogDef::rawdate, u8FreeLogIdx, void, vPortFree(), and xcptime_LocalTime.

Referenced by e_actuator_cmd_get_value(), e_sensor_cmd_get_value(), and v_datalog_AddSensorLog().

void vdatalog_log_free ( xLogDef pxLog)

Free a data log structure and its content.

Parameters
pxLogpointer on the data log structure to free.

References NULL, LogDef::pcStringLog, LogDef::pfFreeLogStruct, and LogDef::pfFreeStringLog.

Referenced by e_actuator_cmd_get_value(), e_sensor_cmd_get_value(), prv_vsave_logs(), v_datalog_AddSensorLog(), and x_datalog_AddLogFromISR().

void vdatalog_make_logstring ( xLogDef pxLog,
signed portCHAR *  pcLogString 
)

Build a log string from a xLogDef log structure.

Parameters
pxLogPointer on a data log structure
pcLogStringAllocated DATALOG_LOG_MAXSIZE string to fill.

References acLogSourceName, LogDef::id, LogDef::pcStringLog, LogDef::rawdate, and sprintf().

Referenced by e_actuator_cmd_get_value(), e_sensor_cmd_get_value(), and prv_vsave_logs().

portBASE_TYPE x_datalog_AddLogFromISR ( xLogDef pxLog)

Add a log in the xLogsQueue, from within an ISR.

Parameters
pxLogThe log to add to the xLogsQueue.
Note
This function must be called last by an ISR (Interrupt Service Routine) associated with an event-based sensor.

References DATALOG_LOGSQUEUE_SIZE, NULL, pdFALSE, uxNbMsgsInLogsQueue, vdatalog_log_free(), and xQueueSendFromISR.

Referenced by prvjoystick_ISR_NonNakedBehaviour(), and prvpushb_ISR_NonNakedBehaviour().

eStatus xDataLog_GetStatus ( void  )

Return the status of the datalog module.

Returns
one of the eStatus enum value.

References xDataLogStatus.