GCC Code Coverage Report


Directory: ./
File: BufferLogger.cpp
Date: 2026-09-23 22:12:31
Exec Total Coverage
Lines: 0 43 0.0%
Functions: 0 10 0.0%
Branches: 0 20 0.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title BufferLogger.cpp
3 // \author bocchino, dinkel, mereweth
4 // \brief Svc BufferLogger implementation
5 //
6 // \copyright
7 // Copyright (C) 2015-2017 California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12
13 #include "Svc/BufferLogger/BufferLogger.hpp"
14
15 namespace Svc {
16
17 typedef BufferLogger_LogState LogState;
18 // ----------------------------------------------------------------------
19 // Construction, initialization, and destruction
20 // ----------------------------------------------------------------------
21
22 ✗ BufferLogger ::BufferLogger(const char* const compName)
23 ✗ : BufferLoggerComponentBase(compName), m_state(LogState::LOGGING_ON), m_file(*this) {}
24
25 // ----------------------------------------------------------------------
26 // Public methods
27 // ----------------------------------------------------------------------
28
29 // TODO(mereweth) - only allow calling this once?
30 ✗ void BufferLogger ::initLog(const char* const logFilePrefix,
31 const char* const logFileSuffix,
32 const FwSizeType maxFileSize,
33 const U8 sizeOfSize) {
34 ✗ m_file.init(logFilePrefix, logFileSuffix, maxFileSize, sizeOfSize);
35 ✗ }
36
37 // ----------------------------------------------------------------------
38 // Handler implementations for user-defined typed input ports
39 // ----------------------------------------------------------------------
40
41 ✗ void BufferLogger ::bufferSendIn_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {
42 ✗ if (m_state == LogState::LOGGING_ON) {
43 ✗ const U8* const addr = fwBuffer.getData();
44 ✗ const FwSizeType size = fwBuffer.getSize();
45 ✗ m_file.logBuffer(addr, size);
46 }
47 ✗ this->bufferSendOut_out(0, fwBuffer);
48 ✗ }
49
50 ✗ void BufferLogger ::comIn_handler(FwIndexType portNum, Fw::ComBuffer& data, U32 context) {
51 ✗ if (m_state == LogState::LOGGING_ON) {
52 ✗ const U8* const addr = data.getBuffAddr();
53 ✗ const FwSizeType size = data.getSize();
54 ✗ m_file.logBuffer(addr, size);
55 }
56 ✗ }
57
58 ✗ void BufferLogger ::pingIn_handler(FwIndexType portNum, U32 key) {
59 ✗ this->pingOut_out(0, key);
60 ✗ }
61
62 ✗ void BufferLogger ::schedIn_handler(const FwIndexType portNum, U32 context) {
63 // TODO
64 ✗ }
65
66 // ----------------------------------------------------------------------
67 // Command handler implementations
68 // ----------------------------------------------------------------------
69
70 // TODO(mereweth) - should this command only set the base name?
71 ✗ void BufferLogger ::BL_OpenFile_cmdHandler(const FwOpcodeType opCode, const U32 cmdSeq, const Fw::CmdStringArg& file) {
72 ✗ m_file.setBaseName(file);
73 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
74 ✗ }
75
76 ✗ void BufferLogger ::BL_CloseFile_cmdHandler(const FwOpcodeType opCode, const U32 cmdSeq) {
77 ✗ m_file.closeAndEmitEvent();
78 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
79 ✗ }
80
81 ✗ void BufferLogger ::BL_SetLogging_cmdHandler(const FwOpcodeType opCode, const U32 cmdSeq, const LogState& state) {
82 ✗ m_state = state;
83 ✗ if (state == LogState::LOGGING_OFF) {
84 ✗ m_file.closeAndEmitEvent();
85 }
86 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
87 ✗ }
88
89 ✗ void BufferLogger ::BL_FlushFile_cmdHandler(const FwOpcodeType opCode, const U32 cmdSeq) {
90 ✗ const bool status = m_file.flush();
91 ✗ if (status) {
92 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
93 } else {
94 ✗ this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
95 }
96 ✗ }
97
98 } // namespace Svc
99