2020-05-17 01:17:11 +02:00
|
|
|
#include <framework/housekeeping/HousekeepingMessage.h>
|
2020-06-13 17:37:48 +02:00
|
|
|
#include <cstring>
|
2020-05-17 01:17:11 +02:00
|
|
|
|
2020-06-13 17:37:48 +02:00
|
|
|
HousekeepingMessage::HousekeepingMessage(MessageQueueMessageIF* message):
|
|
|
|
CommandMessageBase(message) {
|
2020-06-14 19:03:28 +02:00
|
|
|
if(message->getMaximumMessageSize() < HK_MESSAGE_SIZE) {
|
2020-06-17 20:21:49 +02:00
|
|
|
sif::error << "HousekeepingMessage::HousekeepingMessage: Passed "
|
|
|
|
"message buffer can not hold minimum " << HK_MESSAGE_SIZE
|
2020-06-14 19:03:28 +02:00
|
|
|
<< " bytes!" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
message->setMessageSize(HK_MESSAGE_SIZE);
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
2020-06-08 01:22:21 +02:00
|
|
|
|
2020-06-14 19:03:28 +02:00
|
|
|
HousekeepingMessage::~HousekeepingMessage() {}
|
|
|
|
|
|
|
|
void HousekeepingMessage::setParameter(uint32_t parameter) {
|
|
|
|
std::memcpy(getData(), ¶meter, sizeof(parameter));
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t HousekeepingMessage::getParameter() const {
|
|
|
|
uint32_t parameter;
|
|
|
|
std::memcpy(¶meter, getData(), sizeof(parameter));
|
|
|
|
return parameter;
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
2020-06-08 01:22:21 +02:00
|
|
|
|
2020-06-13 17:37:48 +02:00
|
|
|
void HousekeepingMessage::setHkReportMessage(sid_t sid,
|
|
|
|
store_address_t storeId) {
|
|
|
|
CommandMessageBase::setCommand(HK_REPORT);
|
|
|
|
setSid(sid);
|
|
|
|
setParameter(storeId.raw);
|
|
|
|
}
|
|
|
|
|
2020-06-14 19:03:28 +02:00
|
|
|
void HousekeepingMessage::setHkDiagnosticsMessage(sid_t sid,
|
|
|
|
store_address_t storeId) {
|
|
|
|
CommandMessageBase::setCommand(DIAGNOSTICS_REPORT);
|
|
|
|
setSid(sid);
|
|
|
|
setParameter(storeId.raw);
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
|
|
|
|
2020-06-14 19:03:28 +02:00
|
|
|
size_t HousekeepingMessage::getMinimumMessageSize() const {
|
|
|
|
return HK_MESSAGE_SIZE;
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sid_t HousekeepingMessage::getSid() const {
|
|
|
|
sid_t sid;
|
|
|
|
std::memcpy(&sid.raw, CommandMessageBase::getData(), sizeof(sid.raw));
|
|
|
|
return sid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-14 19:03:28 +02:00
|
|
|
sid_t HousekeepingMessage::getHkReportMessage(
|
|
|
|
store_address_t *storeIdToSet) const {
|
|
|
|
if(storeIdToSet != nullptr) {
|
|
|
|
*storeIdToSet = getParameter();
|
|
|
|
}
|
|
|
|
return getSid();
|
2020-06-13 17:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void HousekeepingMessage::setSid(sid_t sid) {
|
|
|
|
std::memcpy(CommandMessageBase::getData(), &sid.raw, sizeof(sid.raw));
|
|
|
|
}
|
2020-06-14 19:03:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
uint8_t* HousekeepingMessage::getData() {
|
|
|
|
return CommandMessageBase::getData() + sizeof(sid_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint8_t* HousekeepingMessage::getData() const {
|
|
|
|
return CommandMessageBase::getData() + sizeof(sid_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HousekeepingMessage::clear() {
|
|
|
|
// clear IPC store where it is needed.
|
|
|
|
}
|