Solaris Software
Loading...
Searching...
No Matches
datalogger.c File Reference

SD card packet logger — SPP consumer service implementation. More...

#include "spp/services/datalogger/datalogger.h"
#include "spp/hal/storage/storage.h"
#include "spp/hal/spi/spi.h"
#include "spp/core/packet.h"
#include "spp/services/log/log.h"
#include "spp/core/types.h"
#include "spp/services/fsm/fsm.h"
#include <string.h>
Include dependency graph for datalogger.c:

Go to the source code of this file.

Functions

static SPP_RetVal_t SPP_SERVICES_DATALOGGER_init (void)
 Initialise the SD card and open the log file for writing.
static SPP_RetVal_t SPP_SERVICES_DATALOGGER_deliverToMailbox (const SPP_Packet_t packet)
 Receive a packet from the pub/sub router into the consumer mailbox.
static SPP_RetVal_t SPP_SERVICES_DATALOGGER_consumeData (void *p_data)
 Consume a packet from the mailbox and write it to the SD card log file.
const SPP_SERVICE_ConsumerContract_t * SPP_SERVICES_DATALOGGER_getConsumerContract (void)
SPP_RetVal_t SPP_SERVICES_DATALOGGER_getInitStatus (void)

Variables

static SPP_Packet_t s_packetBuffer [K_DATALOGGER_BUFFER_SIZE]
static spp_uint8_t s_packetIndex = 0
static spp_uint32_t s_currentDataSector = 0
static spp_uint16_t s_blocksWritten = 0
static SPP_RetVal_t s_initStatus = K_SPP_ERROR_NOT_INITIALIZED
static const SPP_SERVICE_ConsumerContract_t g_dataloggerConsumerContract

Detailed Description

SD card packet logger — SPP consumer service implementation.

Definition in file datalogger.c.

Function Documentation

◆ SPP_SERVICES_DATALOGGER_init()

SPP_RetVal_t SPP_SERVICES_DATALOGGER_init ( void )
static

Initialise the SD card and open the log file for writing.

Returns
K_SPP_OK on success, K_SPP_ERROR on mount or file-open failure.

Definition at line 67 of file datalogger.c.

References K_DATALOGGER_FIRST_SECTOR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, s_blocksWritten, s_currentDataSector, s_initStatus, s_packetIndex, SPP_CORE_FSM_getErrorsBit(), SPP_HAL_STORAGE_init(), and SPP_SERVICES_DATALOGGER_init().

Referenced by SPP_SERVICES_DATALOGGER_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_DATALOGGER_deliverToMailbox()

SPP_RetVal_t SPP_SERVICES_DATALOGGER_deliverToMailbox ( const SPP_Packet_t packet)
static

Receive a packet from the pub/sub router into the consumer mailbox.

Parameters
p_pktPacket dispatched by the router.
Returns
K_SPP_OK on success, K_SPP_ERROR_NULL_POINTER if p_pkt is NULL.

Definition at line 94 of file datalogger.c.

References K_SPP_OK, s_packetBuffer, s_packetIndex, SPP_Packet_t, and SPP_SERVICES_DATALOGGER_deliverToMailbox().

Referenced by SPP_SERVICES_DATALOGGER_deliverToMailbox().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_DATALOGGER_consumeData()

SPP_RetVal_t SPP_SERVICES_DATALOGGER_consumeData ( void * p_data)
static

Consume a packet from the mailbox and write it to the SD card log file.

Parameters
p_dataUnused (context pointer reserved for future use).
Returns
K_SPP_OK on success, K_SPP_ERROR if the file is not open or write fails.

Definition at line 107 of file datalogger.c.

References K_DATALOGGER_BUFFER_SIZE, K_SPP_OK, K_SPP_TOTAL_PACKET_SIZE, s_blocksWritten, s_currentDataSector, s_packetBuffer, s_packetIndex, SPP_HAL_STORAGE_write(), and SPP_SERVICES_DATALOGGER_consumeData().

Referenced by SPP_SERVICES_DATALOGGER_consumeData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_DATALOGGER_getConsumerContract()

const SPP_SERVICE_ConsumerContract_t * SPP_SERVICES_DATALOGGER_getConsumerContract ( void )

Definition at line 50 of file datalogger.c.

References g_dataloggerConsumerContract, and SPP_SERVICES_DATALOGGER_getConsumerContract().

Referenced by SPP_SERVICES_DATALOGGER_getConsumerContract().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_DATALOGGER_getInitStatus()

SPP_RetVal_t SPP_SERVICES_DATALOGGER_getInitStatus ( void )

Definition at line 55 of file datalogger.c.

References s_initStatus, and SPP_SERVICES_DATALOGGER_getInitStatus().

Referenced by SPP_SERVICES_DATALOGGER_getInitStatus().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ s_packetBuffer

SPP_Packet_t s_packetBuffer[K_DATALOGGER_BUFFER_SIZE]
static

Definition at line 20 of file datalogger.c.

◆ s_packetIndex

spp_uint8_t s_packetIndex = 0
static

Index of the next packet to be written to the buffer.

Definition at line 21 of file datalogger.c.

Referenced by SPP_SERVICES_DATALOGGER_consumeData(), SPP_SERVICES_DATALOGGER_deliverToMailbox(), and SPP_SERVICES_DATALOGGER_init().

◆ s_currentDataSector

spp_uint32_t s_currentDataSector = 0
static

Current sector of the data log.

Definition at line 22 of file datalogger.c.

Referenced by SPP_SERVICES_DATALOGGER_consumeData(), and SPP_SERVICES_DATALOGGER_init().

◆ s_blocksWritten

spp_uint16_t s_blocksWritten = 0
static

Number of blocks written to the current sector.

Definition at line 23 of file datalogger.c.

Referenced by SPP_SERVICES_DATALOGGER_consumeData(), and SPP_SERVICES_DATALOGGER_init().

◆ s_initStatus

◆ g_dataloggerConsumerContract

const SPP_SERVICE_ConsumerContract_t g_dataloggerConsumerContract
static
Initial value:
= {
.p_nameConsumer = "datalogger",
.suscribeToApid = 0U,
}
static SPP_RetVal_t SPP_SERVICES_DATALOGGER_consumeData(void *p_data)
Consume a packet from the mailbox and write it to the SD card log file.
Definition datalogger.c:107
static SPP_RetVal_t SPP_SERVICES_DATALOGGER_init(void)
Initialise the SD card and open the log file for writing.
Definition datalogger.c:67
static SPP_RetVal_t SPP_SERVICES_DATALOGGER_deliverToMailbox(const SPP_Packet_t packet)
Receive a packet from the pub/sub router into the consumer mailbox.
Definition datalogger.c:94
#define K_DATALOGGER_CONSUMER_PRIO
Definition datalogger.h:17
#define K_DATALOGGER_TIMEOUT_MS
Definition datalogger.h:18

Definition at line 37 of file datalogger.c.

Referenced by SPP_SERVICES_DATALOGGER_getConsumerContract().