Files
fault/fm-common/sources/fmMsg.h
Victor Romano 0d36c58f6a Add new methods/options to FM API
This commit does the following:

- Add a new option "keep_existing_alarm" when creating an alarm so,
if said alarm already exists, it won't be updated.

- Add a new method to clear alarms from a list. The input is a list
with each element being a tuple consisted of alarm_id and
entity_instance_id.

- Modified the existing method that created alarms from a list.
Previously, the client would loop through the list of alarms and send
requests to FM API. Now, alarms from the list are converted into
a vector of structs and passed to FM API in a single request.

Test plan (using FaultAPIsV2):
  - PASS: Build package and install.
  - PASS: Create a new alarm with keep_existing_alarm=True and verify
          a new alarm was created.
  - PASS: Create an existing alarm with keep_existing_alarm=True and
          verify the original alarm was kept and the returned UUID
          is correct.
  - PASS: Create an existing alarm without keep_existing_alarm and
          verify the original alarm was updated and the returned UUID
          is correct.
  - PASS: Create a list of alarms and verify they were correctly
          created and it was faster than previous method.
  - PASS: Clear a list of alarms that exist and verify they were
          successfully cleared.
  - PASS: Clear a list of alarms that don't exist and verify the API
          didn't raise any errors.
  - PASS: Stop pmond process and verify mtce raises the correct
          200.006 alarm only once. Restart pmond and verify the alarm
          is cleared.

Story: 2011311
Task: 52166

Change-Id: I2f901c4726c24f3522a8c5bae1d7d9b03ef24ce0
Signed-off-by: Victor Romano <victor.gluzromano@windriver.com>
2025-06-16 09:25:01 -03:00

73 lines
1.3 KiB
C++

//
// Copyright (c) 2014, 2024-2025 Wind River Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
#ifndef _FM_MSG_H
#define _FM_MSG_H
#include <vector>
#include "fmAPI.h"
#include <stdint.h>
#define FM_MSG_VAL_KEY (0x1a0ff11d)
#define FM_MSG_WAIT_FAIL (5)
#define FM_MSG_MAX_RET (2)
#define FM_MSG_INF_WAIT (0)
typedef enum {
EFmMsgV1= 1,
EFmMaxVersion
}EFmMsgVersionT;
typedef enum {
EFmMsgRx=0,
EFmMsgTx=1,
EFmMsgMax
}EFmMsgTypesT;
typedef enum {
EFmCreateFault = 0,
EFmUpdateFault,
EFmDeleteFault,
EFmDeleteFaults,
EFmGetFault,
EFmGetFaults,
EFmReturnUUID,
EFmGetFaultsById,
EFmGetFaultsByIdnEid,
EFmCreateFaultList,
EFmDeleteFaultList,
EFmActMax
}EFmMsgActionsT;
typedef struct {
EFmMsgVersionT version;
EFmMsgActionsT action;
uint32_t msg_size;
uint32_t msg_rc; //filled in by server
} SFmMsgHdrT;
typedef std::vector<char> fm_buff_t;
EFmErrorT fm_msg_utils_prep_requet_msg(fm_buff_t &buff,
EFmMsgActionsT act, const void * data, uint32_t len) ;
static inline void * ptr_to_data(fm_buff_t &buff) {
return &(buff[sizeof(SFmMsgHdrT)]);
}
static inline SFmMsgHdrT * ptr_to_hdr(fm_buff_t &buff) {
return (SFmMsgHdrT *)&(buff[0]);
}
static inline bool fm_valid_srv_msg(SFmMsgHdrT *msg, uint32_t exp_size) {
return (msg->msg_size==exp_size);
}
#endif /* _FM_MSG_H */