continue TM handling refactoring
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
This commit is contained in:
48
mission/tmtc/VirtualChannelWithQueue.cpp
Normal file
48
mission/tmtc/VirtualChannelWithQueue.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <mission/tmtc/VirtualChannelWithQueue.h>
|
||||
|
||||
#include "CcsdsIpCoreHandler.h"
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "fsfw/tmtcservices/TmTcMessage.h"
|
||||
|
||||
VirtualChannelWithQueue::VirtualChannelWithQueue(VirtualChannel& channel, StorageManagerIF& tmStore,
|
||||
uint32_t tmQueueDepth,
|
||||
const std::atomic_bool& linkStateProvider)
|
||||
: channel(channel) {
|
||||
auto mqArgs = MqArgs(channel.getObjectId(), reinterpret_cast<void*>(channel.getVcid()));
|
||||
tmQueue = QueueFactory::instance()->createMessageQueue(
|
||||
tmQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
||||
}
|
||||
|
||||
ReturnValue_t VirtualChannelWithQueue::sendNextTm() {
|
||||
TmTcMessage message;
|
||||
ReturnValue_t result = tmQueue->receiveMessage(&message);
|
||||
if (result == MessageQueueIF::EMPTY) {
|
||||
return result;
|
||||
}
|
||||
store_address_t storeId = message.getStorageId();
|
||||
const uint8_t* data = nullptr;
|
||||
size_t size = 0;
|
||||
result = tmStore->getData(storeId, &data, &size);
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "VirtualChannel::performOperation: Failed to read data from TM store"
|
||||
<< std::endl;
|
||||
tmStore->deleteData(storeId);
|
||||
return result;
|
||||
}
|
||||
|
||||
channel.write(data, size);
|
||||
tmStore->deleteData(storeId);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
MessageQueueId_t VirtualChannelWithQueue::getReportReceptionQueue(uint8_t virtualChannel) const {
|
||||
return tmQueue->getId();
|
||||
}
|
||||
|
||||
VirtualChannel& VirtualChannelWithQueue::vc() { return channel; }
|
Reference in New Issue
Block a user