simplify FS interface further

This commit is contained in:
Robin Müller 2024-09-20 16:28:46 +02:00
parent c21185e1cb
commit d838259243
Signed by: muellerr
GPG Key ID: A649FB78196E3849
22 changed files with 91 additions and 109 deletions

View File

@ -164,8 +164,6 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info)
} }
size_t fileSegmentLen = 0; size_t fileSegmentLen = 0;
const uint8_t* fileData = fdInfo.getFileData(&fileSegmentLen); const uint8_t* fileData = fdInfo.getFileData(&fileSegmentLen);
FileOpParams fileOpParams(transactionParams.destName.data(), fileSegmentLen);
fileOpParams.offset = fdInfo.getOffset().value();
if (destParams.cfg.indicCfg.fileSegmentRecvIndicRequired) { if (destParams.cfg.indicCfg.fileSegmentRecvIndicRequired) {
FileSegmentRecvdParams segParams; FileSegmentRecvdParams segParams;
segParams.offset = fdInfo.getOffset().value(); segParams.offset = fdInfo.getOffset().value();
@ -177,7 +175,8 @@ ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info)
segParams.segmentMetadata = {segMetadata, segmentMetadatLen}; segParams.segmentMetadata = {segMetadata, segmentMetadatLen};
destParams.user.fileSegmentRecvdIndication(segParams); destParams.user.fileSegmentRecvdIndication(segParams);
} }
result = destParams.user.vfs.writeToFile(fileOpParams, fileData); result = destParams.user.vfs.writeToFile(transactionParams.destName.data(),
fdInfo.getOffset().value(), fileData, fileSegmentLen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
// TODO: Proper Error handling // TODO: Proper Error handling
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -451,26 +450,26 @@ ReturnValue_t cfdp::DestHandler::checksumVerification() {
std::array<uint8_t, 1024> buf{}; std::array<uint8_t, 1024> buf{};
etl::crc32 crcCalc; etl::crc32 crcCalc;
uint64_t currentOffset = 0; uint64_t currentOffset = 0;
FileOpParams params(transactionParams.destName.data(), transactionParams.fileSize.value());
while (currentOffset < transactionParams.fileSize.value()) { while (currentOffset < transactionParams.fileSize.value()) {
uint64_t readLen; uint64_t lenToRead;
if (currentOffset + buf.size() > transactionParams.fileSize.value()) { if (currentOffset + buf.size() > transactionParams.fileSize.value()) {
readLen = transactionParams.fileSize.value() - currentOffset; lenToRead = transactionParams.fileSize.value() - currentOffset;
} else { } else {
readLen = buf.size(); lenToRead = buf.size();
} }
if (readLen > 0) { if (lenToRead > 0) {
params.offset = currentOffset; size_t readLen = 0;
params.size = readLen; auto result =
auto result = destParams.user.vfs.readFromFile(params, buf.data(), buf.size()); destParams.user.vfs.readFromFile(transactionParams.destName.data(), currentOffset,
lenToRead, buf.data(), readLen, buf.size());
if (result != OK) { if (result != OK) {
// TODO: I think this is a case for a filestore rejection, but it might sense to print // TODO: I think this is a case for a filestore rejection, but it might sense to print
// a warning or trigger an event because this should generally not happen // a warning or trigger an event because this should generally not happen
return FAILED; return FAILED;
} }
crcCalc.add(buf.begin(), buf.begin() + readLen); crcCalc.add(buf.begin(), buf.begin() + lenToRead);
} }
currentOffset += readLen; currentOffset += lenToRead;
} }
uint32_t value = crcCalc.value(); uint32_t value = crcCalc.value();

View File

@ -123,25 +123,25 @@ ReturnValue_t cfdp::SourceHandler::checksumGeneration() {
std::array<uint8_t, 1024> buf{}; std::array<uint8_t, 1024> buf{};
etl::crc32 crcCalc; etl::crc32 crcCalc;
uint64_t currentOffset = 0; uint64_t currentOffset = 0;
FileOpParams params(transactionParams.sourceName.data(), transactionParams.fileSize.value());
while (currentOffset < transactionParams.fileSize.value()) { while (currentOffset < transactionParams.fileSize.value()) {
uint64_t readLen; uint64_t lenToRead;
if (currentOffset + buf.size() > transactionParams.fileSize.value()) { if (currentOffset + buf.size() > transactionParams.fileSize.value()) {
readLen = transactionParams.fileSize.value() - currentOffset; lenToRead = transactionParams.fileSize.value() - currentOffset;
} else { } else {
readLen = buf.size(); lenToRead = buf.size();
} }
if (readLen > 0) { if (lenToRead > 0) {
params.offset = currentOffset; size_t readLen = 0;
params.size = readLen; auto result =
auto result = sourceParams.user.vfs.readFromFile(params, buf.data(), buf.size()); sourceParams.user.vfs.readFromFile(transactionParams.sourceName.data(), currentOffset,
lenToRead, buf.data(), readLen, buf.size());
if (result != OK) { if (result != OK) {
addError(result); addError(result);
return FAILED; return FAILED;
} }
crcCalc.add(buf.begin(), buf.begin() + readLen); crcCalc.add(buf.begin(), buf.begin() + lenToRead);
} }
currentOffset += readLen; currentOffset += lenToRead;
} }
transactionParams.crc = crcCalc.value(); transactionParams.crc = crcCalc.value();
@ -240,7 +240,7 @@ ReturnValue_t cfdp::SourceHandler::prepareAndSendMetadataPdu() {
ReturnValue_t cfdp::SourceHandler::prepareAndSendNextFileDataPdu(bool& noFileDataPdu) { ReturnValue_t cfdp::SourceHandler::prepareAndSendNextFileDataPdu(bool& noFileDataPdu) {
cfdp::Fss offset(transactionParams.progress); cfdp::Fss offset(transactionParams.progress);
uint64_t readLen; uint64_t lenToRead;
uint64_t fileSize = transactionParams.fileSize.value(); uint64_t fileSize = transactionParams.fileSize.value();
noFileDataPdu = false; noFileDataPdu = false;
if (fileSize == 0) { if (fileSize == 0) {
@ -250,29 +250,31 @@ ReturnValue_t cfdp::SourceHandler::prepareAndSendNextFileDataPdu(bool& noFileDat
return OK; return OK;
} }
if (fileSize < transactionParams.remoteCfg.maxFileSegmentLen) { if (fileSize < transactionParams.remoteCfg.maxFileSegmentLen) {
readLen = transactionParams.fileSize.value(); lenToRead = transactionParams.fileSize.value();
} else { } else {
if (transactionParams.progress + transactionParams.remoteCfg.maxFileSegmentLen > fileSize) { if (transactionParams.progress + transactionParams.remoteCfg.maxFileSegmentLen > fileSize) {
readLen = fileSize - transactionParams.progress; lenToRead = fileSize - transactionParams.progress;
} else { } else {
readLen = transactionParams.remoteCfg.maxFileSegmentLen; lenToRead = transactionParams.remoteCfg.maxFileSegmentLen;
} }
} }
FileOpParams fileParams(transactionParams.sourceName.data(), readLen); FileOpParams fileParams(transactionParams.sourceName.data(), lenToRead);
fileParams.offset = transactionParams.progress; fileParams.offset = transactionParams.progress;
ReturnValue_t result = size_t readLen = 0;
sourceParams.user.vfs.readFromFile(fileParams, fileBuf.data(), fileBuf.size()); ReturnValue_t result = sourceParams.user.vfs.readFromFile(
transactionParams.sourceName.data(), transactionParams.progress, lenToRead, fileBuf.data(),
readLen, fileBuf.size());
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
addError(result); addError(result);
return result; return result;
} }
auto fileDataInfo = FileDataInfo(offset, fileBuf.data(), readLen); auto fileDataInfo = FileDataInfo(offset, fileBuf.data(), lenToRead);
auto fileDataPdu = FileDataCreator(transactionParams.pduConf, fileDataInfo); auto fileDataPdu = FileDataCreator(transactionParams.pduConf, fileDataInfo);
result = sendGenericPdu(fileDataPdu); result = sendGenericPdu(fileDataPdu);
if (result != OK) { if (result != OK) {
return result; return result;
} }
transactionParams.progress += readLen; transactionParams.progress += lenToRead;
if (transactionParams.progress >= fileSize) { if (transactionParams.progress >= fileSize) {
// Advance FSM after all file data PDUs were sent. // Advance FSM after all file data PDUs were sent.
step = TransactionStep::SENDING_EOF; step = TransactionStep::SENDING_EOF;

View File

@ -70,10 +70,10 @@ class Jgm3Model {
W[n][m] = W[n][m] - (((n + m - 1) / (double)(n - m)) * W[n][m] = W[n][m] - (((n + m - 1) / (double)(n - m)) *
(pow(Earth::MEAN_RADIUS, 2) / pow(r, 2)) * W[n - 2][m]); (pow(Earth::MEAN_RADIUS, 2) / pow(r, 2)) * W[n - 2][m]);
} // End of if(n!=(m+1)) } // End of if(n!=(m+1))
} // End of if(n==m){ } // End of if(n==m){
} // End of if(n==0 and m==0) } // End of if(n==0 and m==0)
} // End of for(uint8_t n=0;n<(DEGREE+1);n++) } // End of for(uint8_t n=0;n<(DEGREE+1);n++)
} // End of for(uint8_t m=0;m<(ORDER+1);m++) } // End of for(uint8_t m=0;m<(ORDER+1);m++)
// overwrite accel if not properly initialized // overwrite accel if not properly initialized
accel[0] = 0; accel[0] = 0;
@ -106,7 +106,7 @@ class Jgm3Model {
accel[1] += partAccel[1]; accel[1] += partAccel[1];
accel[2] += partAccel[2]; accel[2] += partAccel[2];
} // End of for(uint8_t n=0;n<DEGREE;n++) } // End of for(uint8_t n=0;n<DEGREE;n++)
} // End of uint8_t m=0;m<ORDER;m++ } // End of uint8_t m=0;m<ORDER;m++
} }
void initializeNavOrbit(const double position[3], const double velocity[3], timeval timeUTC) { void initializeNavOrbit(const double position[3], const double velocity[3], timeval timeUTC) {

View File

@ -17,8 +17,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t
if (hkOwner == nullptr) { if (hkOwner == nullptr) {
// Configuration error. // Configuration error.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " << "invalid!" << std::endl;
<< "invalid!" << std::endl;
#else #else
sif::printError( sif::printError(
"LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
@ -187,8 +186,8 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size
SerializeAdapter::serialize(&currentPoolId, buffer, size, maxSize, streamEndianness); SerializeAdapter::serialize(&currentPoolId, buffer, size, maxSize, streamEndianness);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: " sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: " << "Serialization error!"
<< "Serialization error!" << std::endl; << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"LocalPoolDataSetBase::serializeLocalPoolIds: " "LocalPoolDataSetBase::serializeLocalPoolIds: "

View File

@ -17,8 +17,8 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkO
} }
if (hkOwner == nullptr) { if (hkOwner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool " sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool " << "owner is a invalid!"
<< "owner is a invalid!" << std::endl; << std::endl;
#endif #endif
return; return;
} }

View File

@ -243,8 +243,8 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty(EventMessage* ev
if (owner == nullptr) { if (owner == nullptr) {
// Configuration error. // Configuration error.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerFailureIsolation::" sif::error << "DeviceHandlerFailureIsolation::" << "isFdirInActionOrAreWeFaulty: Owner not set!"
<< "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl; << std::endl;
#endif #endif
return false; return false;
} }

View File

@ -62,8 +62,7 @@ ReturnValue_t FailureIsolationBase::initialize() {
ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent); ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent);
if (parentIF == nullptr) { if (parentIF == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::intialize: Parent object " sif::error << "FailureIsolationBase::intialize: Parent object " << "invalid" << std::endl;
<< "invalid" << std::endl;
sif::error << "Make sure it implements ConfirmsFailuresIF" << std::endl; sif::error << "Make sure it implements ConfirmsFailuresIF" << std::endl;
#else #else
sif::printError("FailureIsolationBase::intialize: Parent object invalid\n"); sif::printError("FailureIsolationBase::intialize: Parent object invalid\n");

View File

@ -102,7 +102,8 @@ class HasFileSystemIF {
* @param fileOpInfo General information: File name, size to write, offset, additional arguments * @param fileOpInfo General information: File name, size to write, offset, additional arguments
* @param data The data to write to the file * @param data The data to write to the file
*/ */
virtual ReturnValue_t writeToFile(FileOpParams params, const uint8_t* data) = 0; virtual ReturnValue_t writeToFile(const char* path, size_t offset, const uint8_t* data,
size_t size) = 0;
/** /**
* @brief Generic function to read from a file. This variant takes a pointer to a buffer and * @brief Generic function to read from a file. This variant takes a pointer to a buffer and
@ -115,19 +116,8 @@ class HasFileSystemIF {
* @param args * @param args
* @return * @return
*/ */
virtual ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t** buffer, size_t& readSize, virtual ReturnValue_t readFromFile(const char* path, size_t offset, size_t size, uint8_t* buffer,
size_t maxSize) = 0; size_t& readSize, size_t maxSize) = 0;
/**
* Variant of the @readFromFile which does not perform pointer arithmetic.
* @param fileOpInfo General information: File name, size to write, offset, additional arguments
* @param buf
* @param maxSize
* @return
*/
virtual ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t* buf, size_t maxSize) {
size_t dummy = 0;
return readFromFile(fileOpInfo, &buf, dummy, maxSize);
}
/** /**
* @brief Generic function to create a new file. * @brief Generic function to create a new file.

View File

@ -321,8 +321,8 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
// Possible configuration error, too much data or/and data coming in too fast, // Possible configuration error, too much data or/and data coming in too fast,
// requiring larger buffers // requiring larger buffers
sif::warning << "TcpTmTcServer::handleServerOperation: Ring buffer reached " sif::warning << "TcpTmTcServer::handleServerOperation: Ring buffer reached " << "fill count"
<< "fill count" << std::endl; << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"TcpTmTcServer::handleServerOperation: Ring buffer reached " "TcpTmTcServer::handleServerOperation: Ring buffer reached "

View File

@ -49,8 +49,8 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t*
if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen, if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen,
SerializeIF::Endianness::BIG) != returnvalue::OK) { SerializeIF::Endianness::BIG) != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service20ParameterManagement::checkAndAcquireTargetID: " sif::error << "Service20ParameterManagement::checkAndAcquireTargetID: " << "Invalid data."
<< "Invalid data." << std::endl; << std::endl;
#else #else
sif::printError( sif::printError(
"Service20ParameterManagement::" "Service20ParameterManagement::"

View File

@ -196,8 +196,8 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply,
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Service3Housekeeping::handleReply: Invalid reply with " sif::warning << "Service3Housekeeping::handleReply: Invalid reply with " << "reply command "
<< "reply command " << command << std::endl; << command << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"Service3Housekeeping::handleReply: Invalid reply with " "Service3Housekeeping::handleReply: Invalid reply with "

View File

@ -12,8 +12,7 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig,
spillsToHigherPools(spillsToHigherPools) { spillsToHigherPools(spillsToHigherPools) {
if (NUMBER_OF_SUBPOOLS == 0) { if (NUMBER_OF_SUBPOOLS == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPool::LocalPool: Passed pool configuration is " sif::error << "LocalPool::LocalPool: Passed pool configuration is " << " invalid!" << std::endl;
<< " invalid!" << std::endl;
#endif #endif
} }
max_subpools_t index = 0; max_subpools_t index = 0;

View File

@ -38,10 +38,9 @@ ReturnValue_t Subsystem::checkSequence(HybridIterator<ModeListEntry> iter,
if (!existsModeTable(iter->getTableId())) { if (!existsModeTable(iter->getTableId())) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
using namespace std; using namespace std;
sif::warning << "Subsystem::checkSequence: " sif::warning << "Subsystem::checkSequence: " << "Object " << setfill('0') << hex << "0x"
<< "Object " << setfill('0') << hex << "0x" << setw(8) << getObjectId() << setw(8) << getObjectId() << setw(0) << ": Mode table for mode ID " << "0x"
<< setw(0) << ": Mode table for mode ID " << setw(8) << iter->getTableId() << " does not exist" << dec << endl;
<< "0x" << setw(8) << iter->getTableId() << " does not exist" << dec << endl;
#endif #endif
return TABLE_DOES_NOT_EXIST; return TABLE_DOES_NOT_EXIST;
} else { } else {

View File

@ -34,7 +34,7 @@ class ExecutableObjectIF {
* a reference to the executing task * a reference to the executing task
* @param task_ Pointer to the taskIF of this task * @param task_ Pointer to the taskIF of this task
*/ */
virtual void setTaskIF(PeriodicTaskIF* task_){}; virtual void setTaskIF(PeriodicTaskIF* task_) {};
/** /**
* This function should be called after the object was assigned to a * This function should be called after the object was assigned to a

View File

@ -101,8 +101,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
// Continue for now but print error output. // Continue for now but print error output.
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FixedSlotSequence::checkSequence:" sif::error << "FixedSlotSequence::checkSequence:" << " Custom check failed!" << std::endl;
<< " Custom check failed!" << std::endl;
#endif #endif
} }
} }

View File

@ -27,5 +27,5 @@ static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TMTC_DISTRIBUTION;
//! P1: Returnvalue, P2: 0 for TM issues, 1 for TC issues //! P1: Returnvalue, P2: 0 for TM issues, 1 for TC issues
static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); static constexpr Event HANDLE_PACKET_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
}; // namespace tmtcdistrib }; // namespace tmtcdistrib
#endif // FSFW_TMTCPACKET_DEFINITIONS_H #endif // FSFW_TMTCPACKET_DEFINITIONS_H

View File

@ -34,8 +34,7 @@ ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(unsigned int maxNumberOfPa
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of " sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of "
<< "packets stored exceeds limits. " << "packets stored exceeds limits. " << "Keeping default value." << std::endl;
<< "Keeping default value." << std::endl;
#endif #endif
return returnvalue::FAILED; return returnvalue::FAILED;
} }
@ -79,15 +78,13 @@ ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) {
result = handleTc(); result = handleTc();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "TmTcBridge::performOperation: " sif::debug << "TmTcBridge::performOperation: " << "Error handling TCs" << std::endl;
<< "Error handling TCs" << std::endl;
#endif #endif
} }
result = handleTm(); result = handleTm();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "TmTcBridge::performOperation: " sif::debug << "TmTcBridge::performOperation: " << "Error handling TMs" << std::endl;
<< "Error handling TMs" << std::endl;
#endif #endif
} }
return result; return result;

View File

@ -10,11 +10,12 @@ using namespace std;
HostFilesystem::HostFilesystem() = default; HostFilesystem::HostFilesystem() = default;
ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *data) { ReturnValue_t HostFilesystem::writeToFile(const char *path_, size_t offset, const uint8_t *data,
if (params.path() == nullptr) { size_t size) {
if (path_ == nullptr) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
path path(params.path()); path path(path_);
std::error_code e; std::error_code e;
if (not exists(path, e)) { if (not exists(path, e)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST; return HasFileSystemIF::FILE_DOES_NOT_EXIST;
@ -25,17 +26,17 @@ ReturnValue_t HostFilesystem::writeToFile(FileOpParams params, const uint8_t *da
if (file.fail()) { if (file.fail()) {
return HasFileSystemIF::GENERIC_FILE_ERROR; return HasFileSystemIF::GENERIC_FILE_ERROR;
} }
file.seekp(static_cast<unsigned int>(params.offset)); file.seekp(static_cast<unsigned int>(offset));
file.write(reinterpret_cast<const char *>(data), static_cast<unsigned int>(params.size)); file.write(reinterpret_cast<const char *>(data), static_cast<unsigned int>(size));
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize, ReturnValue_t HostFilesystem::readFromFile(const char *path_, size_t offset, size_t size,
size_t maxSize) { uint8_t *buffer, size_t &readSize, size_t maxSize) {
if (params.path() == nullptr) { if (path_ == nullptr) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
path path(params.path()); path path(path_);
std::error_code e; std::error_code e;
if (not exists(path, e)) { if (not exists(path, e)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST; return HasFileSystemIF::FILE_DOES_NOT_EXIST;
@ -44,8 +45,8 @@ ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer
if (file.fail()) { if (file.fail()) {
return HasFileSystemIF::GENERIC_FILE_ERROR; return HasFileSystemIF::GENERIC_FILE_ERROR;
} }
auto sizeToRead = static_cast<unsigned int>(params.size); auto sizeToRead = static_cast<unsigned int>(size);
file.seekg(static_cast<unsigned int>(params.offset)); file.seekg(static_cast<unsigned int>(offset));
if (readSize + sizeToRead > maxSize) { if (readSize + sizeToRead > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT; return SerializeIF::BUFFER_TOO_SHORT;
} }

View File

@ -16,9 +16,10 @@ class HostFilesystem : public HasFileSystemIF {
ReturnValue_t isDirectory(const char *path, bool &isDirectory) override; ReturnValue_t isDirectory(const char *path, bool &isDirectory) override;
bool fileExists(const char *path, FileSystemArgsIF *args) override; bool fileExists(const char *path, FileSystemArgsIF *args) override;
ReturnValue_t truncateFile(const char *path, FileSystemArgsIF *args) override; ReturnValue_t truncateFile(const char *path, FileSystemArgsIF *args) override;
ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override; ReturnValue_t writeToFile(const char *path, size_t offset, const uint8_t *data,
ReturnValue_t readFromFile(FileOpParams fileOpInfo, uint8_t **buffer, size_t &readSize, size_t size) override;
size_t maxSize) override; ReturnValue_t readFromFile(const char *path, size_t offset, size_t size, uint8_t *buffer,
size_t &readSize, size_t maxSize) override;
ReturnValue_t createFile(const char *path, const uint8_t *data, size_t size) override; ReturnValue_t createFile(const char *path, const uint8_t *data, size_t size) override;
ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override; ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override;
ReturnValue_t createDirectory(const char *path, bool createParentDirs, ReturnValue_t createDirectory(const char *path, bool createParentDirs,

View File

@ -418,8 +418,8 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck,
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO " sif::warning << "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO "
"definition with ID " "definition with ID "
<< gpioIdToCheck << " detected. " << gpioIdToCheck << " detected. " << "Duplicate will be removed from map to add"
<< "Duplicate will be removed from map to add" << std::endl; << std::endl;
#else #else
sif::printWarning( sif::printWarning(
"LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition " "LinuxLibgpioIF::checkForConflictsRegularGpio: Duplicate GPIO definition "

View File

@ -49,8 +49,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
if (not statusPair.second) { if (not statusPair.second) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::initializeInterface: Failed to insert device with address " sif::error << "I2cComIF::initializeInterface: Failed to insert device with address "
<< i2cAddress << "to I2C device " << i2cAddress << "to I2C device " << "map" << std::endl;
<< "map" << std::endl;
#endif #endif
return returnvalue::FAILED; return returnvalue::FAILED;
} }
@ -91,8 +90,8 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) { if (i2cDeviceMapIter == i2cDeviceMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " << "registered in i2cDeviceMap"
<< "registered in i2cDeviceMap" << std::endl; << std::endl;
#endif #endif
return returnvalue::FAILED; return returnvalue::FAILED;
} }

View File

@ -197,9 +197,8 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
if (result == MutexIF::MUTEX_TIMEOUT) { if (result == MutexIF::MUTEX_TIMEOUT) {
sif::error << "SpiComIF::sendMessage: Lock timeout" << std::endl; sif::error << "SpiComIF::sendMessage: Lock timeout" << std::endl;
} else { } else {
sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code " sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code " << "0x" << std::hex
<< "0x" << std::hex << std::setfill('0') << std::setw(4) << result << std::dec << std::setfill('0') << std::setw(4) << result << std::dec << std::endl;
<< std::endl;
} }
#else #else
sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result); sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result);
@ -307,9 +306,8 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code " sif::error << "SpiComIF::sendMessage: Failed to lock mutex with code " << "0x" << std::hex
<< "0x" << std::hex << std::setfill('0') << std::setw(4) << result << std::dec << std::setfill('0') << std::setw(4) << result << std::dec << std::endl;
<< std::endl;
#else #else
sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result); sif::printError("SpiComIF::sendMessage: Failed to lock mutex with code %d\n", result);
#endif #endif