all cstdout uses wrapped in preprocessor defines

This commit is contained in:
Robin Müller 2021-01-03 13:58:18 +01:00
parent 61fc6cac97
commit c19e628d79
96 changed files with 715 additions and 14 deletions

View File

@ -47,9 +47,11 @@ ReturnValue_t SharedRingBuffer::initialize() {
DynamicFIFO<size_t>* SharedRingBuffer::getReceiveSizesFIFO() {
if(receiveSizesFIFO == nullptr) {
// Configuration error.
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "SharedRingBuffer::getReceiveSizesFIFO: Ring buffer"
<< " was not configured to have sizes FIFO, returning nullptr!"
<< std::endl;
#endif
}
return receiveSizesFIFO;
}

View File

@ -107,7 +107,9 @@ MessageQueueId_t ExtendedControllerBase::getCommandQueue() const {
}
LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "ExtendedControllerBase::getDataSetHandle: No child "
<< " implementation provided, returning nullptr!" << std::endl;
#endif
return nullptr;
}

View File

@ -55,7 +55,9 @@ void Clcw::setBitLock(bool bitLock) {
}
void Clcw::print() {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "Clcw::print: Clcw is: " << std::hex << getAsWhole() << std::dec << std::endl;
#endif
}
void Clcw::setWhole(uint32_t rawClcw) {

View File

@ -98,8 +98,10 @@ ReturnValue_t DataLinkLayer::processFrame(uint16_t length) {
receivedDataLength = length;
ReturnValue_t status = allFramesReception();
if (status != RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DataLinkLayer::processFrame: frame reception failed. "
"Error code: " << std::hex << status << std::dec << std::endl;
#endif
// currentFrame.print();
return status;
} else {
@ -124,7 +126,9 @@ ReturnValue_t DataLinkLayer::initialize() {
if ( virtualChannels.begin() != virtualChannels.end() ) {
clcw->setVirtualChannel( virtualChannels.begin()->second->getChannelId() );
} else {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl;
#endif
return RETURN_FAILED;
}

View File

@ -29,9 +29,11 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
bufferPosition = &packetBuffer[packetLength];
status = RETURN_OK;
} else {
#if CPP_OSTREAM_ENABLED == 1
sif::error
<< "MapPacketExtraction::extractPackets. Packet too large! Size: "
<< packetLength << std::endl;
#endif
clearBuffers();
status = CONTENT_TOO_LARGE;
}
@ -51,24 +53,30 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
}
status = RETURN_OK;
} else {
#if CPP_OSTREAM_ENABLED == 1
sif::error
<< "MapPacketExtraction::extractPackets. Packet too large! Size: "
<< packetLength << std::endl;
#endif
clearBuffers();
status = CONTENT_TOO_LARGE;
}
} else {
#if CPP_OSTREAM_ENABLED == 1
sif::error
<< "MapPacketExtraction::extractPackets. Illegal segment! Last flag: "
<< (int) lastSegmentationFlag << std::endl;
#endif
clearBuffers();
status = ILLEGAL_SEGMENTATION_FLAG;
}
break;
default:
#if CPP_OSTREAM_ENABLED == 1
sif::error
<< "MapPacketExtraction::extractPackets. Illegal segmentationFlag: "
<< (int) segmentationFlag << std::endl;
#endif
clearBuffers();
status = DATA_CORRUPTED;
break;
@ -135,10 +143,14 @@ ReturnValue_t MapPacketExtraction::initialize() {
}
void MapPacketExtraction::printPacketBuffer(void) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "DLL: packet_buffer contains: " << std::endl;
#endif
for (uint32_t i = 0; i < this->packetLength; ++i) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "packet_buffer[" << std::dec << i << "]: 0x" << std::hex
<< (uint16_t) this->packetBuffer[i] << std::endl;
#endif
}
}

View File

@ -87,16 +87,25 @@ uint8_t* TcTransferFrame::getFullDataField() {
}
void TcTransferFrame::print() {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "Raw Frame: " << std::hex << std::endl;
for (uint16_t count = 0; count < this->getFullSize(); count++ ) {
sif::debug << (uint16_t)this->getFullFrame()[count] << " ";
}
sif::debug << std::dec << std::endl;
// debug << "Frame Header:" << std::endl;
// debug << "Version Number: " << std::hex << (uint16_t)this->current_frame.getVersionNumber() << std::endl;
// debug << "Bypass Flag set?| Ctrl Cmd Flag set?: " << (uint16_t)this->current_frame.bypassFlagSet() << " | " << (uint16_t)this->current_frame.controlCommandFlagSet() << std::endl;
// debug << "SCID : " << this->current_frame.getSpacecraftId() << std::endl;
// debug << "VCID : " << (uint16_t)this->current_frame.getVirtualChannelId() << std::endl;
// debug << "Frame length: " << std::dec << this->current_frame.getFrameLength() << std::endl;
// debug << "Sequence Number: " << (uint16_t)this->current_frame.getSequenceNumber() << std::endl;
sif::debug << "Frame Header:" << std::endl;
sif::debug << "Version Number: " << std::hex
<< (uint16_t)this->getVersionNumber() << std::endl;
sif::debug << "Bypass Flag set?| Ctrl Cmd Flag set?: "
<< (uint16_t)this->bypassFlagSet() << " | "
<< (uint16_t)this->controlCommandFlagSet() << std::endl;
sif::debug << "SCID : " << this->getSpacecraftId() << std::endl;
sif::debug << "VCID : " << (uint16_t)this->getVirtualChannelId()
<< std::endl;
sif::debug << "Frame length: " << std::dec << this->getFrameLength()
<< std::endl;
sif::debug << "Sequence Number: " << (uint16_t)this->getSequenceNumber()
<< std::endl;
#endif
}

View File

@ -37,7 +37,9 @@ TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uin
this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8;
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
} else {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "TcTransferFrameLocal: dataSize too large: " << dataSize << std::endl;
#endif
}
} else {
//No data in frame

View File

@ -102,8 +102,10 @@ uint8_t VirtualChannelReception::getChannelId() const {
ReturnValue_t VirtualChannelReception::initialize() {
ReturnValue_t returnValue = RETURN_FAILED;
if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: "
<< (int) slidingWindowWidth << std::endl;
#endif
return RETURN_FAILED;
}
for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end();

View File

@ -13,18 +13,24 @@ PoolDataSetBase::~PoolDataSetBase() {}
ReturnValue_t PoolDataSetBase::registerVariable(
PoolVariableIF *variable) {
if (state != States::STATE_SET_UNINITIALISED) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: "
"Call made in wrong position." << std::endl;
#endif
return DataSetIF::DATA_SET_UNINITIALISED;
}
if (variable == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: "
"Pool variable is nullptr." << std::endl;
#endif
return DataSetIF::POOL_VAR_NULL;
}
if (fillCount >= maxFillCount) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: "
"DataSet is full." << std::endl;
#endif
return DataSetIF::DATA_SET_FULL;
}
registeredVariables[fillCount] = variable;
@ -47,9 +53,11 @@ ReturnValue_t PoolDataSetBase::read(uint32_t lockTimeout) {
unlockDataPool();
}
else {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::read(): "
"Call made in wrong position. Don't forget to commit"
" member datasets!" << std::endl;
#endif
result = SET_WAS_ALREADY_READ;
}
@ -138,8 +146,10 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) {
} else if (registeredVariables[count]->getDataPoolId()
!= PoolVariableIF::NO_PARAMETER) {
if (result != COMMITING_WITHOUT_READING) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::commit(): commit-without-read call made "
"with non write-only variable." << std::endl;
#endif
result = COMMITING_WITHOUT_READING;
}
}

View File

@ -12,9 +12,11 @@ PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, uint8_t setLength,
std::memset(this->address, 0, this->getByteSize());
}
else if (initValue.size() != setLength){
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "PoolEntry: setLength is not equal to initializer list"
"length! Performing zero initialization with given setLength"
<< std::endl;
#endif
std::memset(this->address, 0, this->getByteSize());
}
else {
@ -67,10 +69,14 @@ bool PoolEntry<T>::getValid() {
template <typename T>
void PoolEntry<T>::print() {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "Pool Entry Validity: " <<
(this->valid? " (valid) " : " (invalid) ") << std::endl;
#endif
arrayprinter::print(reinterpret_cast<uint8_t*>(address), length);
#if CPP_OSTREAM_ENABLED == 1
sif::debug << std::dec << std::endl;
#endif
}
template<typename T>

View File

@ -89,8 +89,10 @@ public:
* @return
*/
virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden"
<< ". Returning nullptr!" << std::endl;
#endif
return nullptr;
}

View File

@ -21,15 +21,19 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner,
MessageQueueIF* queueToUse, bool appendValidityBuffer):
appendValidityBuffer(appendValidityBuffer) {
if(owner == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
<< "Invalid supplied owner!" << std::endl;
#endif
return;
}
this->owner = owner;
mutex = MutexFactory::instance()->createMutex();
if(mutex == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
<< "Could not create mutex." << std::endl;
#endif
}
hkQueue = queueToUse;
@ -39,17 +43,21 @@ LocalDataPoolManager::~LocalDataPoolManager() {}
ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
if(queueToUse == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::initialize: "
<< std::hex << "0x" << owner->getObjectId() << ". Supplied "
<< "queue invalid!" << std::dec << std::endl;
#endif
}
hkQueue = queueToUse;
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
if(ipcStore == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::initialize: "
<< std::hex << "0x" << owner->getObjectId() << ": Could not "
<< "set IPC store." <<std::dec << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -61,8 +69,10 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
hkDestinationId = hkPacketReceiver->getHkQueue();
}
else {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
<< "Default HK destination object is invalid!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
}
@ -85,8 +95,10 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
}
return result;
}
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "HousekeepingManager: The map should only be initialized "
<< "once!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK;
}
@ -339,8 +351,10 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
AcceptsHkPacketsIF* hkReceiverObject =
objectManager->get<AcceptsHkPacketsIF>(packetDestination);
if(hkReceiverObject == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:"
<< " Invalid receiver!"<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK;
}
@ -369,8 +383,10 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePackets(sid_t sid,
AcceptsHkPacketsIF* hkReceiverObject =
objectManager->get<AcceptsHkPacketsIF>(packetDestination);
if(hkReceiverObject == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:"
<< " Invalid receiver!"<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK;
}
@ -575,8 +591,10 @@ ReturnValue_t LocalDataPoolManager::printPoolEntry(
lp_id_t localPoolId) {
auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "HousekeepingManager::fechPoolEntry:"
<< " Pool entry not found." << std::endl;
#endif
return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
}
poolIter->second->print();
@ -596,8 +614,10 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
MessageQueueId_t destination) {
if(dataSet == nullptr) {
// Configuration error.
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
<< " Set ID not found or dataset not assigned!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -678,10 +698,12 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
sid, dataSet, true);
if(result != HasReturnvaluesIF::RETURN_OK) {
// configuration error
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "LocalDataPoolManager::performHkOperation:"
<< "0x" << std::hex << std::setfill('0') << std::setw(8)
<< owner->getObjectId() << " Error generating "
<< "HK packet" << std::setfill(' ') << std::dec << std::endl;
#endif
}
}
@ -726,8 +748,10 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
// Get and check dataset first.
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
if(dataSet == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
<< " Set ID not found" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -752,8 +776,10 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
ReturnValue_t result = ipcStore->getFreeElement(&storeId,
expectedSize,&storePtr);
if(result != HasReturnvaluesIF::RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "HousekeepingManager::generateHousekeepingPacket: "
<< "Could not get free element from IPC store." << std::endl;
#endif
return result;
}
@ -762,8 +788,10 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
result = setPacket.serialize(&storePtr, &size, expectedSize,
SerializeIF::Endianness::BIG);
if(expectedSize != size) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "HousekeepingManager::generateSetStructurePacket: "
<< "Expected size is not equal to serialized size" << std::endl;
#endif
}
// Send structure reporting reply.

View File

@ -375,15 +375,19 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId,
PoolEntry<T> **poolEntry) {
auto poolIter = localPoolMap.find(localPoolId);
if (poolIter == localPoolMap.end()) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry "
"not found." << std::endl;
#endif
return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
}
*poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second);
if(*poolEntry == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "HousekeepingManager::fetchPoolEntry:"
" Pool entry not found." << std::endl;
#endif
return HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT;
}
return HasReturnvaluesIF::RETURN_OK;

View File

@ -12,8 +12,10 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
if(hkOwner == nullptr) {
// Configuration error.
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
<< "invalid!" << std::endl;
#endif
return;
}
hkManager = hkOwner->getHkManagerHandle();
@ -147,8 +149,10 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
auto result = SerializeAdapter::serialize(&currentPoolId, buffer,
size, maxSize, streamEndianness);
if(result != HasReturnvaluesIF::RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization"
" error!" << std::endl;
#endif
return result;
}
}
@ -206,8 +210,10 @@ ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size,
void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const {
if(position > 7) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "Pool Raw Access: Bit setting invalid position"
<< std::endl;
#endif
return;
}
uint8_t shiftNumber = position + (7 - 2 * position);
@ -256,8 +262,10 @@ sid_t LocalPoolDataSetBase::getSid() const {
bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte,
uint8_t position) const {
if(position > 7) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "Pool Raw Access: Bit setting invalid position"
<< std::endl;
#endif
return false;
}
uint8_t shiftNumber = position + (7 - 2 * position);

View File

@ -5,12 +5,16 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId,
pool_rwm_t setReadWriteMode): localPoolId(poolId),
readWriteMode(setReadWriteMode) {
if(poolId == PoolVariableIF::NO_PARAMETER) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
<< "which is the NO_PARAMETER value!" << std::endl;
#endif
}
if(hkOwner == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool "
<< "owner is a invalid!" << std::endl;
#endif
return;
}
hkManager = hkOwner->getHkManagerHandle();
@ -23,15 +27,19 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
DataSetIF *dataSet, pool_rwm_t setReadWriteMode): localPoolId(poolId),
readWriteMode(setReadWriteMode) {
if(poolId == PoolVariableIF::NO_PARAMETER) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
<< "which is the NO_PARAMETER value!" << std::endl;
#endif
}
HasLocalDataPoolIF* hkOwner =
objectManager->get<HasLocalDataPoolIF>(poolOwner);
if(hkOwner == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVariable: The supplied pool owner did not "
<< "implement the correct interface"
<< " HasLocalDataPoolIF!" << std::endl;
#endif
return;
}
hkManager = hkOwner->getHkManagerHandle();

View File

@ -33,18 +33,22 @@ inline ReturnValue_t LocalPoolVariable<T>::read(dur_millis_t lockTimeout) {
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "LocalPoolVar: Invalid read write "
"mode for read() call." << std::endl;
#endif
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
if(result != RETURN_OK or poolEntry == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "PoolVector: Read of local pool variable of object "
<< std::hex << std::setw(8) << std::setfill('0')
<< hkManager->getOwner() << " and lp ID " << localPoolId
<< std::dec << " failed." << std::setfill(' ') << std::endl;
#endif
return result;
}
this->value = *(poolEntry->address);
@ -62,17 +66,21 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(dur_millis_t lockTimeout) {
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_READ) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "LocalPoolVariable: Invalid read write "
"mode for commit() call." << std::endl;
#endif
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
if(result != RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "PoolVector: Read of local pool variable of object "
"0x" << std::hex << std::setw(8) << std::setfill('0') <<
hkManager->getOwner() << " and lp ID 0x" << localPoolId <<
std::dec << " failed.\n" << std::flush;
#endif
return result;
}
*(poolEntry->address) = this->value;

View File

@ -32,8 +32,10 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(uint32_t lockTimeout)
template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "LocalPoolVar: Invalid read write "
"mode for read() call." << std::endl;
#endif
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
@ -42,10 +44,12 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
memset(this->value, 0, vectorSize * sizeof(T));
if(result != RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "PoolVector: Read of local pool variable of object "
"0x" << std::hex << std::setw(8) << std::setfill('0') <<
hkManager->getOwner() << "and lp ID 0x" << localPoolId <<
std::dec << " failed." << std::endl;
#endif
return result;
}
std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize());
@ -64,17 +68,21 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_READ) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "LocalPoolVar: Invalid read write "
"mode for commit() call." << std::endl;
#endif
return PoolVariableIF::INVALID_READ_WRITE_MODE;
}
PoolEntry<T>* poolEntry = nullptr;
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
if(result != RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "PoolVector: Read of local pool variable of object "
"0x" << std::hex << std::setw(8) << std::setfill('0') <<
hkManager->getOwner() << " and lp ID 0x" << localPoolId <<
std::dec << " failed.\n" << std::flush;
#endif
return result;
}
std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize());
@ -89,8 +97,10 @@ inline T& LocalPoolVector<T, vectorSize>::operator [](int i) {
}
// If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here.
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVector: Invalid index. Setting or returning"
" last value!" << std::endl;
#endif
return value[i];
}
@ -101,8 +111,10 @@ inline const T& LocalPoolVector<T, vectorSize>::operator [](int i) const {
}
// If this happens, I have to set some value. I consider this
// a configuration error, but I wont exit here.
#if CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVector: Invalid index. Setting or returning"
" last value!" << std::endl;
#endif
return value[i];
}

View File

@ -14,7 +14,9 @@ public:
if(readObject != nullptr) {
readResult = readObject->read(mutexTimeout);
#if FSFW_PRINT_VERBOSITY_LEVEL == 1
#if CPP_OSTREAM_ENABLED == 1
sif::error << "PoolReadHelper: Read failed!" << std::endl;
#endif
#endif
}
}

View File

@ -15,8 +15,10 @@ ReturnValue_t pst::pollingSequenceInitDefault(
return HasReturnvaluesIF::RETURN_OK;
}
else {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!"
<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
}

View File

@ -39,11 +39,13 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
cookieInfo.state = COOKIE_UNUSED;
cookieInfo.pendingCommand = deviceCommandMap.end();
if (comCookie == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerBase: ObjectID 0x" << std::hex
<< std::setw(8) << std::setfill('0') << this->getObjectId()
<< std::dec << ": Do not pass nullptr as a cookie, consider "
<< std::setfill(' ') << "passing a dummy cookie instead!"
<< std::endl;
#endif
}
if (this->fdirInstance == nullptr) {
this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId,
@ -130,24 +132,30 @@ ReturnValue_t DeviceHandlerBase::initialize() {
communicationInterface = objectManager->get<DeviceCommunicationIF>(
deviceCommunicationId);
if (communicationInterface == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerBase::initialize: Communication interface "
"invalid." << std::endl;
sif::error << "Make sure it is set up properly and implements"
" DeviceCommunicationIF" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
result = communicationInterface->initializeInterface(comCookie);
if (result != RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerBase::initialize: Initializing "
"communication interface failed!" << std::endl;
#endif
return result;
}
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerBase::initialize: IPC store not set up in "
"factory." << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
@ -156,10 +164,12 @@ ReturnValue_t DeviceHandlerBase::initialize() {
AcceptsDeviceResponsesIF>(rawDataReceiverId);
if (rawReceiver == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerBase::initialize: Raw receiver object "
"ID set but no valid object found." << std::endl;
sif::error << "Make sure the raw receiver object is set up properly"
" and implements AcceptsDeviceResponsesIF" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
defaultRawReceiver = rawReceiver->getDeviceQueue();
@ -168,10 +178,12 @@ ReturnValue_t DeviceHandlerBase::initialize() {
if(powerSwitcherId != objects::NO_OBJECT) {
powerSwitcher = objectManager->get<PowerSwitchIF>(powerSwitcherId);
if (powerSwitcher == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerBase::initialize: Power switcher "
<< "object ID set but no valid object found." << std::endl;
sif::error << "Make sure the raw receiver object is set up properly"
<< " and implements PowerSwitchIF" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
@ -708,8 +720,10 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
case RETURN_OK:
handleReply(receivedData, foundId, foundLen);
if(foundLen == 0) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
" Packet parsing will be stuck." << std::endl;
#endif
}
break;
case APERIODIC_REPLY: {
@ -720,8 +734,10 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
foundId);
}
if(foundLen == 0) {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
" Packet parsing will be stuck." << std::endl;
#endif
}
break;
}
@ -1275,9 +1291,11 @@ void DeviceHandlerBase::buildInternalCommand(void) {
result = buildNormalDeviceCommand(&deviceCommandId);
if (result == BUSY) {
//so we can track misconfigurations
#if CPP_OSTREAM_ENABLED == 1
sif::debug << std::hex << getObjectId()
<< ": DHB::buildInternalCommand: Busy" << std::dec
<< std::endl;
#endif
result = NOTHING_TO_SEND; //no need to report this
}
}
@ -1302,10 +1320,12 @@ void DeviceHandlerBase::buildInternalCommand(void) {
result = COMMAND_NOT_SUPPORTED;
} else if (iter->second.isExecuting) {
//so we can track misconfigurations
#if CPP_OSTREAM_ENABLED == 1
sif::debug << std::hex << getObjectId()
<< ": DHB::buildInternalCommand: Command "
<< deviceCommandId << " isExecuting" << std::dec
<< std::endl;
#endif
// this is an internal command, no need to report a failure here,
// missed reply will track if a reply is too late, otherwise, it's ok
return;

View File

@ -169,8 +169,10 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() {
ReturnValue_t DeviceHandlerFailureIsolation::initialize() {
ReturnValue_t result = FailureIsolationBase::initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerFailureIsolation::initialize: Could not"
" initialize FailureIsolationBase." << std::endl;
#endif
return result;
}
ConfirmsFailuresIF* power = objectManager->get<ConfirmsFailuresIF>(
@ -250,8 +252,10 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty(
if (owner == nullptr) {
// Configuration error.
#if CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerFailureIsolation::"
<< "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl;
#endif
return false;
}

View File

@ -122,6 +122,7 @@ void EventManager::printEvent(EventMessage* message) {
case severity::INFO:
#if DEBUG_INFO_EVENT == 1
string = translateObject(message->getReporter());
#if CPP_OSTREAM_ENABLED == 1
sif::info << "EVENT: ";
if (string != 0) {
sif::info << string;
@ -132,10 +133,12 @@ void EventManager::printEvent(EventMessage* message) {
<< std::dec << message->getEventId() << std::hex << ") P1: 0x"
<< message->getParameter1() << " P2: 0x"
<< message->getParameter2() << std::dec << std::endl;
#endif
#endif /* CPP_OSTREAM_ENABLED == 1 */
#endif /* DEBUG_INFO_EVENT == 1 */
break;
default:
string = translateObject(message->getReporter());
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "EventManager: ";
if (string != 0) {
sif::debug << string;
@ -146,13 +149,13 @@ void EventManager::printEvent(EventMessage* message) {
sif::debug << " reported " << translateEvents(message->getEvent())
<< " (" << std::dec << message->getEventId() << ") "
<< std::endl;
sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1()
<< ", P1 Dec: " << std::dec << message->getParameter1()
<< std::endl;
sif::debug << std::hex << "P2 Hex: 0x" << message->getParameter2()
<< ", P2 Dec: " << std::dec << message->getParameter2()
<< std::endl;
#endif
break;
}
}

View File

@ -21,8 +21,10 @@ ReturnValue_t FailureIsolationBase::initialize() {
EventManagerIF* manager = objectManager->get<EventManagerIF>(
objects::EVENT_MANAGER);
if (manager == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::initialize: Event Manager has not"
" been initialized!" << std::endl;
#endif
return RETURN_FAILED;
}
ReturnValue_t result = manager->registerListener(eventQueue->getId());
@ -36,8 +38,10 @@ ReturnValue_t FailureIsolationBase::initialize() {
}
owner = objectManager->get<HasHealthIF>(ownerId);
if (owner == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::intialize: Owner object "
"invalid. Make sure it implements HasHealthIF" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
@ -45,10 +49,14 @@ ReturnValue_t FailureIsolationBase::initialize() {
ConfirmsFailuresIF* parentIF = objectManager->get<ConfirmsFailuresIF>(
faultTreeParent);
if (parentIF == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::intialize: Parent object"
<< "invalid." << std::endl;
#endif
#if CPP_OSTREAM_ENABLED == 1
sif::error << "Make sure it implements ConfirmsFailuresIF."
<< std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
return RETURN_FAILED;
}

View File

@ -4,10 +4,12 @@
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
bool printInfo, size_t maxCharPerLine) {
#if CPP_OSTREAM_ENABLED == 1
if(printInfo) {
sif::info << "Printing data with size " << size << ": ";
}
sif::info << "[";
#endif
if(type == OutputType::HEX) {
arrayprinter::printHex(data, size, maxCharPerLine);
}
@ -21,6 +23,7 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
void arrayprinter::printHex(const uint8_t *data, size_t size,
size_t maxCharPerLine) {
#if CPP_OSTREAM_ENABLED == 1
sif::info << std::hex;
for(size_t i = 0; i < size; i++) {
sif::info << "0x" << static_cast<int>(data[i]);
@ -28,16 +31,18 @@ void arrayprinter::printHex(const uint8_t *data, size_t size,
sif::info << " , ";
if(i > 0 and i % maxCharPerLine == 0) {
sif::info << std::endl;
}
}
}
sif::info << std::dec;
sif::info << "]" << std::endl;
#endif
}
void arrayprinter::printDec(const uint8_t *data, size_t size,
size_t maxCharPerLine) {
#if CPP_OSTREAM_ENABLED == 1
sif::info << std::dec;
for(size_t i = 0; i < size; i++) {
sif::info << static_cast<int>(data[i]);
@ -49,13 +54,16 @@ void arrayprinter::printDec(const uint8_t *data, size_t size,
}
}
sif::info << "]" << std::endl;
#endif
}
void arrayprinter::printBin(const uint8_t *data, size_t size) {
#if CPP_OSTREAM_ENABLED == 1
sif::info << "\n" << std::flush;
for(size_t i = 0; i < size; i++) {
sif::info << "Byte " << i + 1 << ": 0b"<<
std::bitset<8>(data[i]) << ",\n" << std::flush;
}
sif::info << "]" << std::endl;
#endif
}

View File

@ -41,14 +41,18 @@ ReturnValue_t HealthHelper::initialize() {
eventSender = objectManager->get<EventReportingProxyIF>(objectId);
if (healthTable == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "HealthHelper::initialize: Health table object needs"
"to be created in factory." << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
if(eventSender == nullptr) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "HealthHelper::initialize: Owner has to implement "
"ReportingProxyIF." << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
@ -79,8 +83,10 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
health, oldHealth);
if (MessageQueueSenderIF::sendMessage(parentQueue, &information,
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "HealthHelper::informParent: sending health reply failed."
<< std::endl;
#endif
}
}
@ -98,8 +104,10 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
}
if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply,
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "HealthHelper::handleHealthCommand: sending health "
"reply failed." << std::endl;
#endif
}
}

View File

@ -29,14 +29,16 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
uint32_t newTmHits = getAndResetTmHits();
uint32_t newStoreHits = getAndResetStoreHits();
#ifdef DEBUG
#if FSFW_ENHANCED_PRINTOUT == 1
if(diagnosticPrintout) {
if((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "InternalErrorReporter::performOperation: Errors "
<< "occured!" << std::endl;
sif::debug << "Queue errors: " << newQueueHits << std::endl;
sif::debug << "TM errors: " << newTmHits << std::endl;
sif::debug << "Store errors: " << newStoreHits << std::endl;
#endif
}
}
#endif

View File

@ -15,8 +15,10 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) :
this->messageSize = this->HEADER_SIZE + size;
}
else {
#if CPP_OSTREAM_ENABLED == 1
sif::warning << "MessageQueueMessage: Passed size larger than maximum"
"allowed size! Setting content to 0" << std::endl;
#endif
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
this->messageSize = this->HEADER_SIZE;
}
@ -52,7 +54,9 @@ void MessageQueueMessage::setSender(MessageQueueId_t setId) {
}
void MessageQueueMessage::print(bool printWholeMessage) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "MessageQueueMessage content: " << std::endl;
#endif
if(printWholeMessage) {
arrayprinter::print(getData(), getMaximumMessageSize());
}

View File

@ -12,12 +12,16 @@ public:
ReturnValue_t status = mutex->lockMutex(timeoutType,
timeoutMs);
if(status == MutexIF::MUTEX_TIMEOUT) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "MutexHelper: Lock of mutex failed with timeout of "
<< timeoutMs << " milliseconds!" << std::endl;
#endif
}
else if(status != HasReturnvaluesIF::RETURN_OK){
#if CPP_OSTREAM_ENABLED == 1
sif::error << "MutexHelper: Lock of Mutex failed with code "
<< status << std::endl;
#endif
}
}

View File

@ -16,7 +16,9 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) {
lastSender = message->getSender();
lastCommand = message->getCommand();
if (busy) {
#if CPP_OSTREAM_ENABLED == 1
sif::debug << "MemHelper: Busy!" << std::endl;
#endif
}
switch (lastCommand) {
case MemoryMessage::CMD_MEMORY_DUMP:

View File

@ -72,8 +72,10 @@ private:
if (timeStamper == nullptr) {
timeStamper = objectManager->get<TimeStamperIF>( timeStamperId );
if ( timeStamper == nullptr ) {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "MonitoringReportContent::checkAndSetStamper: "
"Stamper not found!" << std::endl;
#endif
return false;
}
}

View File

@ -18,13 +18,18 @@ ObjectManager::~ObjectManager() {
ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
auto returnPair = objectList.emplace(id, object);
if (returnPair.second) {
#if CPP_OSTREAM_ENABLED == 1
// sif::debug << "ObjectManager::insert: Object " << std::hex
// << (int)id << std::dec << " inserted." << std::endl;
#endif
return this->RETURN_OK;
} else {
#if CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::insert: Object id " << std::hex
<< (int)id << std::dec << " is already in use!" << std::endl;
<< static_cast<uint32_t> id << std::dec
<< " is already in use!" << std::endl;
sif::error << "Terminating program." << std::endl;
#endif
//This is very severe and difficult to handle in other places.
std::exit(INSERTION_FAILED);
}
@ -33,12 +38,16 @@ ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
ReturnValue_t ObjectManager::remove( object_id_t id ) {
if ( this->getSystemObject(id) != NULL ) {