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>Go to the source code of this file.
Functions | |
| static SPP_RetVal_t | SPP_SERVICES_DATALOGGER_init (void) |
| Initializes the SD card storage and resets the logging indices. | |
| static SPP_RetVal_t | SPP_SERVICES_DATALOGGER_deliverToMailbox (const SPP_Packet_t packet) |
| Copies a received packet into the internal logging buffer. | |
| static SPP_RetVal_t | SPP_SERVICES_DATALOGGER_consumeData (void *p_data) |
| Writes the buffered packets to consecutive SD card sectors when full. | |
| const SPP_SERVICE_ConsumerContract_t * | SPP_SERVICES_DATALOGGER_getConsumerContract (void) |
| Returns the datalogger consumer contract. | |
| SPP_RetVal_t | SPP_SERVICES_DATALOGGER_getInitStatus (void) |
| Returns the stored SD card initialization status. | |
Variables | |
| static SPP_Packet_t | s_packetBuffer [K_DATALOGGER_BUFFER_PACKETS] |
| static spp_uint8_t | s_packetIndex = 0 |
| static spp_uint32_t | s_currentDataSector = 0 |
| static spp_uint16_t | s_blocksWritten |
| static SPP_RetVal_t | s_initStatus = K_SPP_ERROR_NOT_INITIALIZED |
| static const SPP_SERVICE_ConsumerContract_t | g_dataloggerConsumerContract |
SD card packet logger — SPP consumer service implementation.
Definition in file datalogger.c.
|
static |
Initializes the SD card storage and resets the logging indices.
Definition at line 68 of file datalogger.c.
References K_DATALOGGER_FIRST_SECTOR, K_SPP_OK, s_currentDataSector, s_initStatus, s_packetIndex, SPP_HAL_STORAGE_init(), and SPP_SERVICES_DATALOGGER_init().
Referenced by SPP_SERVICES_DATALOGGER_init().
|
static |
Copies a received packet into the internal logging buffer.
| packet | Packet dispatched by PUBSUB. |
Definition at line 88 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().
|
static |
Writes the buffered packets to consecutive SD card sectors when full.
On successful writing, advances the sector index and resets the buffer. On failure, retains the buffered packets for a later attempt.
| p_data | Unused. |
Definition at line 105 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().
| const SPP_SERVICE_ConsumerContract_t * SPP_SERVICES_DATALOGGER_getConsumerContract | ( | void | ) |
Returns the datalogger consumer contract.
Definition at line 50 of file datalogger.c.
References g_dataloggerConsumerContract, and SPP_SERVICES_DATALOGGER_getConsumerContract().
Referenced by CUSTOM_registerConsumerProducer(), guard_startInitializationOfModules(), and SPP_SERVICES_DATALOGGER_getConsumerContract().
| SPP_RetVal_t SPP_SERVICES_DATALOGGER_getInitStatus | ( | void | ) |
Returns the stored SD card initialization status.
Definition at line 55 of file datalogger.c.
References s_initStatus, and SPP_SERVICES_DATALOGGER_getInitStatus().
Referenced by SPP_SERVICES_DATALOGGER_getInitStatus().
|
static |
Definition at line 20 of file datalogger.c.
|
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().
|
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().
|
static |
Number of blocks written to the current sector.
Definition at line 23 of file datalogger.c.
Referenced by SPP_SERVICES_DATALOGGER_consumeData().
|
static |
Definition at line 25 of file datalogger.c.
|
static |
Definition at line 38 of file datalogger.c.
Referenced by SPP_SERVICES_DATALOGGER_getConsumerContract().