mirror of
https://github.com/nasa/fprime.git
synced 2025-12-11 04:35:25 -06:00
Removes NATIVE_INT_TYPE, NATIVE_UINT_TYPE, and POINTER_CAST from Fw (#3286)
* NATIVE_INT_TYPE use in toString * NATIVE_INT_TYPE use in SimpleObjRegistry * NATIVE_INT_TYPE use in Asserts * NATIVE_INT_TYPE use in Fw/Comp * NATIVE_INT_TYPE use in getCapacity * NATIVE_INT_TYPE use in getEntries * NATIVE_INT_TYPE use in size/length * NATIVE_INT_TYPE use in FILE_NAME_ARG * NATIVE_INT_TYPE use in Fw (misc) * NATIVE_INT_TYPE use in identifier * NATIVE_INT_TYPE use in Fw (misc II) * POINTER_CAST in Buffer * POINTER_CAST in Serializable * sp * Removing no longer used DefaultTypes.hpp * Fixes to accomidate Fw refactor * Unit-test and CI fixes * Fixing review comments - pt 1
This commit is contained in:
parent
83d5448389
commit
ec08d43dd3
@ -29,7 +29,7 @@ namespace Drv {
|
||||
return *this;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE DataBuffer::getBuffCapacity() const {
|
||||
FwSizeType DataBuffer::getBuffCapacity() const {
|
||||
return sizeof(this->m_data);
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ namespace Drv {
|
||||
virtual ~DataBuffer();
|
||||
DataBuffer& operator=(const DataBuffer& other);
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
U8* getBuffAddr();
|
||||
const U8* getBuffAddr() const;
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ Fw::SerializeStatus Buffer::serialize(Fw::SerializeBufferBase& buffer) const {
|
||||
return stat;
|
||||
}
|
||||
#endif
|
||||
stat = buffer.serialize(reinterpret_cast<POINTER_CAST>(this->m_bufferData));
|
||||
stat = buffer.serialize(reinterpret_cast<PlatformPointerCastType>(this->m_bufferData));
|
||||
if (stat != Fw::FW_SERIALIZE_OK) {
|
||||
return stat;
|
||||
}
|
||||
@ -146,7 +146,7 @@ Fw::SerializeStatus Buffer::deserialize(Fw::SerializeBufferBase& buffer) {
|
||||
return Fw::FW_DESERIALIZE_TYPE_MISMATCH;
|
||||
}
|
||||
#endif
|
||||
POINTER_CAST pointer;
|
||||
PlatformPointerCastType pointer;
|
||||
stat = buffer.deserialize(pointer);
|
||||
if (stat != Fw::FW_SERIALIZE_OK) {
|
||||
return stat;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
namespace Fw {
|
||||
|
||||
CmdArgBuffer::CmdArgBuffer(const U8 *args, NATIVE_UINT_TYPE size) {
|
||||
CmdArgBuffer::CmdArgBuffer(const U8 *args, FwSizeType size) {
|
||||
SerializeStatus stat = this->setBuff(args,size);
|
||||
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<FwAssertArgType>(stat));
|
||||
}
|
||||
@ -29,7 +29,7 @@ namespace Fw {
|
||||
return *this;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE CmdArgBuffer::getBuffCapacity() const {
|
||||
FwSizeType CmdArgBuffer::getBuffCapacity() const {
|
||||
return sizeof(this->m_bufferData);
|
||||
}
|
||||
|
||||
|
||||
@ -26,13 +26,13 @@ namespace Fw {
|
||||
SERIALIZED_SIZE = FW_CMD_ARG_BUFFER_MAX_SIZE + sizeof(I32) //!< size when serialized. Buffer + size of buffer
|
||||
};
|
||||
|
||||
CmdArgBuffer(const U8 *args, NATIVE_UINT_TYPE size); //!< buffer source constructor
|
||||
CmdArgBuffer(const U8 *args, FwSizeType size); //!< buffer source constructor
|
||||
CmdArgBuffer(); //!< default constructor
|
||||
CmdArgBuffer(const CmdArgBuffer& other); //!< other arg buffer constructor
|
||||
virtual ~CmdArgBuffer(); //!< destructor
|
||||
CmdArgBuffer& operator=(const CmdArgBuffer& other); //!< Equal operator
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const; //!< return capacity of buffer (how much it can hold)
|
||||
FwSizeType getBuffCapacity() const; //!< return capacity of buffer (how much it can hold)
|
||||
U8* getBuffAddr(); //!< return address of buffer (non const version)
|
||||
const U8* getBuffAddr() const; //!< return address of buffer (const version)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
namespace Fw {
|
||||
|
||||
ComBuffer::ComBuffer(const U8 *args, NATIVE_UINT_TYPE size) {
|
||||
ComBuffer::ComBuffer(const U8 *args, FwSizeType size) {
|
||||
SerializeStatus stat = SerializeBufferBase::setBuff(args,size);
|
||||
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<FwAssertArgType>(stat));
|
||||
}
|
||||
@ -29,7 +29,7 @@ namespace Fw {
|
||||
return *this;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE ComBuffer::getBuffCapacity() const {
|
||||
FwSizeType ComBuffer::getBuffCapacity() const {
|
||||
return sizeof(this->m_bufferData);
|
||||
}
|
||||
|
||||
|
||||
@ -25,13 +25,13 @@ namespace Fw {
|
||||
SERIALIZED_SIZE = FW_COM_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType) // size of buffer + storage of size word
|
||||
};
|
||||
|
||||
ComBuffer(const U8 *args, NATIVE_UINT_TYPE size);
|
||||
ComBuffer(const U8 *args, FwSizeType size);
|
||||
ComBuffer();
|
||||
ComBuffer(const ComBuffer& other);
|
||||
virtual ~ComBuffer();
|
||||
ComBuffer& operator=(const ComBuffer& other);
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
U8* getBuffAddr();
|
||||
const U8* getBuffAddr() const;
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ namespace Fw {
|
||||
class ActiveComponentExitSerializableBuffer : public Fw::SerializeBufferBase {
|
||||
|
||||
public:
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const {
|
||||
FwSizeType getBuffCapacity() const {
|
||||
return sizeof(m_buff);
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Fw {
|
||||
ActiveComponentBase::~ActiveComponentBase() {
|
||||
}
|
||||
|
||||
void ActiveComponentBase::init(NATIVE_INT_TYPE instance) {
|
||||
void ActiveComponentBase::init(FwEnumStoreType instance) {
|
||||
QueuedComponentBase::init(instance);
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ class ActiveComponentBase : public QueuedComponentBase {
|
||||
|
||||
explicit ActiveComponentBase(const char* name); //!< Constructor
|
||||
virtual ~ActiveComponentBase(); //!< Destructor
|
||||
void init(NATIVE_INT_TYPE instance); //!< initialization code
|
||||
void init(FwEnumStoreType instance); //!< initialization code
|
||||
virtual void preamble(); //!< A function that will be called before the event loop is entered
|
||||
MsgDispatchStatus dispatch(); //!< The function that will dispatching messages
|
||||
virtual void finalizer(); //!< A function that will be called after exiting the loop
|
||||
|
||||
@ -14,7 +14,7 @@ namespace Fw {
|
||||
return "Comp: %s";
|
||||
}
|
||||
|
||||
void PassiveComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) {
|
||||
void PassiveComponentBase::toString(char* buffer, FwSizeType size) {
|
||||
FW_ASSERT(size > 0);
|
||||
FW_ASSERT(buffer != nullptr);
|
||||
Fw::FormatStatus status = Fw::ExternalString(buffer, static_cast<Fw::ExternalString::SizeType>(size)).format(
|
||||
@ -34,12 +34,12 @@ namespace Fw {
|
||||
PassiveComponentBase::~PassiveComponentBase() {
|
||||
}
|
||||
|
||||
void PassiveComponentBase::init(NATIVE_INT_TYPE instance) {
|
||||
void PassiveComponentBase::init(FwEnumStoreType instance) {
|
||||
ObjBase::init();
|
||||
this->m_instance = instance;
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE PassiveComponentBase::getInstance() const {
|
||||
FwEnumStoreType PassiveComponentBase::getInstance() const {
|
||||
return this->m_instance;
|
||||
}
|
||||
|
||||
|
||||
@ -20,17 +20,17 @@ namespace Fw {
|
||||
PROTECTED:
|
||||
PassiveComponentBase(const char* name); //!< Named constructor
|
||||
virtual ~PassiveComponentBase(); //!< Destructor
|
||||
void init(NATIVE_INT_TYPE instance); //!< Initialization function
|
||||
NATIVE_INT_TYPE getInstance() const;
|
||||
void init(FwEnumStoreType instance); //!< Initialization function
|
||||
FwEnumStoreType getInstance() const;
|
||||
|
||||
|
||||
#if FW_OBJECT_TO_STRING == 1
|
||||
virtual const char* getToStringFormatString(); //!< Return the format for a generic component toString
|
||||
void toString(char* str, NATIVE_INT_TYPE size) override; //!< returns string description of component
|
||||
void toString(char* str, FwSizeType size) override; //!< returns string description of component
|
||||
#endif
|
||||
PRIVATE:
|
||||
U32 m_idBase; //!< ID base for opcodes etc.
|
||||
NATIVE_INT_TYPE m_instance; //!< instance of component object
|
||||
FwEnumStoreType m_instance; //!< instance of component object
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -15,7 +15,7 @@ namespace Fw {
|
||||
|
||||
}
|
||||
|
||||
void QueuedComponentBase::init(NATIVE_INT_TYPE instance) {
|
||||
void QueuedComponentBase::init(FwEnumStoreType instance) {
|
||||
PassiveComponentBase::init(instance);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ namespace Fw {
|
||||
return this->m_queue.create(queueName, depth, msgSize);
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE QueuedComponentBase::getNumMsgsDropped() {
|
||||
FwSizeType QueuedComponentBase::getNumMsgsDropped() {
|
||||
return this->m_msgsDropped;
|
||||
}
|
||||
|
||||
|
||||
@ -32,17 +32,17 @@ namespace Fw {
|
||||
PROTECTED:
|
||||
QueuedComponentBase(const char* name); //!< Constructor
|
||||
virtual ~QueuedComponentBase(); //!< Destructor
|
||||
void init(NATIVE_INT_TYPE instance); //!< initialization function
|
||||
void init(FwEnumStoreType instance); //!< initialization function
|
||||
Os::Queue m_queue; //!< queue object for active component
|
||||
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize);
|
||||
virtual MsgDispatchStatus doDispatch()=0; //!< method to dispatch a single message in the queue.
|
||||
#if FW_OBJECT_TO_STRING == 1
|
||||
virtual const char* getToStringFormatString(); //!< Format string for toString function
|
||||
#endif
|
||||
NATIVE_INT_TYPE getNumMsgsDropped(); //!< return number of messages dropped
|
||||
FwSizeType getNumMsgsDropped(); //!< return number of messages dropped
|
||||
void incNumMsgDropped(); //!< increment the number of messages dropped
|
||||
PRIVATE:
|
||||
NATIVE_INT_TYPE m_msgsDropped; //!< number of messages dropped from full queue
|
||||
FwSizeType m_msgsDropped; //!< number of messages dropped from full queue
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ Utils::HashBuffer DpContainer::computeDataHash() const {
|
||||
FW_ASSERT(DATA_OFFSET + dataSize <= bufferSize, static_cast<FwAssertArgType>(DATA_OFFSET + dataSize),
|
||||
static_cast<FwAssertArgType>(bufferSize));
|
||||
Utils::HashBuffer computedHash;
|
||||
Utils::Hash::hash(dataAddr, static_cast<NATIVE_INT_TYPE>(dataSize), computedHash);
|
||||
Utils::Hash::hash(dataAddr, dataSize, computedHash);
|
||||
return computedHash;
|
||||
}
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ struct DpContainerHeader {
|
||||
DP_CONTAINER_HEADER_ASSERT_EQ(status, FW_SERIALIZE_OK);
|
||||
// Deserialize the user data
|
||||
DpContainerHeader::moveDeserToOffset(file, line, buffer, DpContainer::Header::USER_DATA_OFFSET);
|
||||
NATIVE_UINT_TYPE size = sizeof this->m_userData;
|
||||
FwSizeType size = sizeof this->m_userData;
|
||||
const bool omitLength = true;
|
||||
status = serializeRepr.deserialize(this->m_userData, size, omitLength);
|
||||
DP_CONTAINER_HEADER_ASSERT_EQ(status, FW_SERIALIZE_OK);
|
||||
|
||||
@ -50,7 +50,7 @@ namespace Fw {
|
||||
}
|
||||
|
||||
SerializeStatus AmpcsEvrLogPacket::deserialize(SerializeBufferBase& buffer) {
|
||||
NATIVE_UINT_TYPE len;
|
||||
FwSizeType len;
|
||||
|
||||
SerializeStatus stat;
|
||||
|
||||
@ -75,7 +75,7 @@ namespace Fw {
|
||||
return stat;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE size = buffer.getBuffLeft();
|
||||
FwSizeType size = buffer.getBuffLeft();
|
||||
stat = buffer.deserialize(this->m_logBuffer.getBuffAddr(),size,true);
|
||||
if (stat == FW_SERIALIZE_OK) {
|
||||
// Shouldn't fail
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
namespace Fw {
|
||||
|
||||
LogBuffer::LogBuffer(const U8 *args, NATIVE_UINT_TYPE size) {
|
||||
LogBuffer::LogBuffer(const U8 *args, FwSizeType size) {
|
||||
SerializeStatus stat = SerializeBufferBase::setBuff(args,size);
|
||||
FW_ASSERT(FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
|
||||
}
|
||||
@ -29,7 +29,7 @@ namespace Fw {
|
||||
return *this;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE LogBuffer::getBuffCapacity() const {
|
||||
FwSizeType LogBuffer::getBuffCapacity() const {
|
||||
return sizeof(this->m_bufferData);
|
||||
}
|
||||
|
||||
|
||||
@ -26,13 +26,13 @@ namespace Fw {
|
||||
SERIALIZED_SIZE = FW_LOG_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType)
|
||||
};
|
||||
|
||||
LogBuffer(const U8 *args, NATIVE_UINT_TYPE size);
|
||||
LogBuffer(const U8 *args, FwSizeType size);
|
||||
LogBuffer();
|
||||
LogBuffer(const LogBuffer& other);
|
||||
virtual ~LogBuffer();
|
||||
LogBuffer& operator=(const LogBuffer& other);
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
U8* getBuffAddr();
|
||||
const U8* getBuffAddr() const;
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ namespace Fw {
|
||||
}
|
||||
|
||||
// remainder of buffer must be telemetry value
|
||||
NATIVE_UINT_TYPE size = buffer.getBuffLeft();
|
||||
FwSizeType size = buffer.getBuffLeft();
|
||||
stat = buffer.deserialize(this->m_logBuffer.getBuffAddr(),size,true);
|
||||
if (stat == FW_SERIALIZE_OK) {
|
||||
// Shouldn't fail
|
||||
|
||||
@ -27,7 +27,7 @@ bool Register::precondition(const MockLogging::FakeLogger& truth) {
|
||||
// Register NULL or truth as the system logger
|
||||
void Register::action(MockLogging::FakeLogger& truth) {
|
||||
// Select a registration value: 1 -> logger, 0 -> NULL
|
||||
NATIVE_INT_TYPE random = STest::Pick::lowerUpper(0, 1);
|
||||
U32 random = STest::Pick::lowerUpper(0, 1);
|
||||
if (random == 1) {
|
||||
Fw::Logger::registerLogger(&truth);
|
||||
truth.s_current = &truth;
|
||||
@ -48,8 +48,8 @@ bool LogGood::precondition(const MockLogging::FakeLogger& truth) {
|
||||
|
||||
// Log valid messages
|
||||
void LogGood::action(MockLogging::FakeLogger& truth) {
|
||||
NATIVE_INT_TYPE random = STest::Pick::lowerUpper(0, 10);
|
||||
NATIVE_INT_TYPE ra[10];
|
||||
U32 random = STest::Pick::lowerUpper(0, 10);
|
||||
U32 ra[10];
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
ra[i] = STest::Pick::lowerUpper(0, 0xffffffff);
|
||||
}
|
||||
@ -127,8 +127,8 @@ bool LogGoodStringObject::precondition(const MockLogging::FakeLogger& truth) {
|
||||
// Log valid messages
|
||||
void LogGoodStringObject::action(MockLogging::FakeLogger& truth) {
|
||||
Fw::String my_string;
|
||||
NATIVE_INT_TYPE random = STest::Pick::lowerUpper(0, my_string.getCapacity() - 1);
|
||||
for (int i = 0; i < random; ++i) {
|
||||
U32 random = STest::Pick::lowerUpper(0, my_string.getCapacity() - 1);
|
||||
for (U32 i = 0; i < random; ++i) {
|
||||
const_cast<char*>(my_string.toChar())[i] =
|
||||
static_cast<char>(STest::Pick::lowerUpper(0, std::numeric_limits<unsigned char>::max()));
|
||||
}
|
||||
@ -149,8 +149,8 @@ bool LogBad::precondition(const MockLogging::FakeLogger& truth) {
|
||||
|
||||
// Log valid messages
|
||||
void LogBad::action(MockLogging::FakeLogger& truth) {
|
||||
NATIVE_INT_TYPE random = STest::Pick::lowerUpper(0, 10);
|
||||
NATIVE_INT_TYPE ra[10];
|
||||
U32 random = STest::Pick::lowerUpper(0, 10);
|
||||
U32 ra[10];
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
ra[i] = STest::Pick::lowerUpper(0, 0xffffffff);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ namespace Fw {
|
||||
this->m_objName = name;
|
||||
}
|
||||
#if FW_OBJECT_TO_STRING == 1
|
||||
void ObjBase::toString(char* str, NATIVE_INT_TYPE size) {
|
||||
void ObjBase::toString(char* str, FwSizeType size) {
|
||||
FW_ASSERT(size > 0);
|
||||
FW_ASSERT(str != nullptr);
|
||||
Fw::FormatStatus formatStatus = Fw::ExternalString(str, static_cast<Fw::ExternalString::SizeType>(size)).format("Obj: %s", this->m_objName.toChar());
|
||||
|
||||
@ -61,7 +61,7 @@ namespace Fw {
|
||||
//!
|
||||
//! \param str destination buffer where string description is placed
|
||||
//! \param size destination buffer size (including terminator). String should be terminated
|
||||
virtual void toString(char* str, NATIVE_INT_TYPE size); //!< virtual method to get description of object
|
||||
virtual void toString(char* str, FwSizeType size); //!< virtual method to get description of object
|
||||
#endif // FW_OBJECT_TO_STRING
|
||||
#endif // FW_OBJECT_NAMES
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ namespace Fw {
|
||||
ObjBase::setObjRegistry(this);
|
||||
this->m_numEntries = 0;
|
||||
// Initialize pointer array
|
||||
for (NATIVE_INT_TYPE entry = 0; entry < FW_OBJ_SIMPLE_REG_ENTRIES; entry++) {
|
||||
for (FwSizeType entry = 0; entry < FW_OBJ_SIMPLE_REG_ENTRIES; entry++) {
|
||||
this->m_objPtrArray[entry] = nullptr;
|
||||
}
|
||||
}
|
||||
@ -23,7 +23,7 @@ namespace Fw {
|
||||
}
|
||||
|
||||
void SimpleObjRegistry::dump() {
|
||||
for (NATIVE_INT_TYPE obj = 0; obj < this->m_numEntries; obj++) {
|
||||
for (FwSizeType obj = 0; obj < this->m_numEntries; obj++) {
|
||||
#if FW_OBJECT_NAMES == 1
|
||||
#if FW_OBJECT_TO_STRING == 1
|
||||
char objDump[FW_OBJ_SIMPLE_REG_BUFF_SIZE];
|
||||
@ -43,7 +43,7 @@ namespace Fw {
|
||||
|
||||
#if FW_OBJECT_NAMES == 1
|
||||
void SimpleObjRegistry::dump(const char* objName) {
|
||||
for (NATIVE_INT_TYPE obj = 0; obj < this->m_numEntries; obj++) {
|
||||
for (FwSizeType obj = 0; obj < this->m_numEntries; obj++) {
|
||||
char objDump[FW_OBJ_SIMPLE_REG_BUFF_SIZE];
|
||||
if (strncmp(objName,this->m_objPtrArray[obj]->getObjName(),sizeof(objDump)) == 0) {
|
||||
#if FW_OBJECT_TO_STRING == 1
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Fw {
|
||||
private:
|
||||
void regObject(ObjBase* obj); //!< register an object with the registry
|
||||
ObjBase* m_objPtrArray[FW_OBJ_SIMPLE_REG_ENTRIES]; //!< array of objects
|
||||
NATIVE_INT_TYPE m_numEntries; //!< number of entries in the registry
|
||||
FwSizeType m_numEntries; //!< number of entries in the registry
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ namespace Fw {
|
||||
return "Port: %s %s->(%s)";
|
||||
}
|
||||
|
||||
void PortBase::toString(char* buffer, NATIVE_INT_TYPE size) {
|
||||
void PortBase::toString(char* buffer, FwSizeType size) {
|
||||
FW_ASSERT(size > 0);
|
||||
// Get the port-custom format string
|
||||
const char* formatString = this->getToStringFormatString();
|
||||
|
||||
@ -35,7 +35,7 @@ namespace Fw {
|
||||
#if FW_OBJECT_TO_STRING
|
||||
virtual const char* getToStringFormatString(); //!< Get format string for toString call
|
||||
|
||||
void toString(char* str, NATIVE_INT_TYPE size) override; //!< Unified port toString method
|
||||
void toString(char* str, FwSizeType size) override; //!< Unified port toString method
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
namespace Fw {
|
||||
|
||||
ParamBuffer::ParamBuffer(const U8 *args, NATIVE_UINT_TYPE size) {
|
||||
ParamBuffer::ParamBuffer(const U8 *args, FwSizeType size) {
|
||||
SerializeStatus stat = SerializeBufferBase::setBuff(args,size);
|
||||
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<FwAssertArgType>(stat));
|
||||
}
|
||||
@ -29,7 +29,7 @@ namespace Fw {
|
||||
return *this;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE ParamBuffer::getBuffCapacity() const {
|
||||
FwSizeType ParamBuffer::getBuffCapacity() const {
|
||||
return sizeof(this->m_bufferData);
|
||||
}
|
||||
|
||||
|
||||
@ -32,13 +32,13 @@ namespace Fw {
|
||||
SERIALIZED_SIZE = FW_PARAM_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType)
|
||||
};
|
||||
|
||||
ParamBuffer(const U8 *args, NATIVE_UINT_TYPE size);
|
||||
ParamBuffer(const U8 *args, FwSizeType size);
|
||||
ParamBuffer();
|
||||
ParamBuffer(const ParamBuffer& other);
|
||||
virtual ~ParamBuffer();
|
||||
ParamBuffer& operator=(const ParamBuffer& other);
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
U8* getBuffAddr();
|
||||
const U8* getBuffAddr() const;
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
namespace Fw {
|
||||
|
||||
SerializableFile::SerializableFile(MemAllocator* allocator, NATIVE_UINT_TYPE maxSerializedSize) :
|
||||
SerializableFile::SerializableFile(MemAllocator* allocator, FwSizeType maxSerializedSize) :
|
||||
m_allocator(allocator),
|
||||
m_recoverable(false), // for compiler; not used
|
||||
m_actualSize(maxSerializedSize),
|
||||
@ -50,7 +50,7 @@ namespace Fw {
|
||||
|
||||
this->reset();
|
||||
SerializeStatus serStatus;
|
||||
serStatus = this->m_buffer.setBuffLen(static_cast<NATIVE_UINT_TYPE>(length));
|
||||
serStatus = this->m_buffer.setBuffLen(static_cast<FwSizeType>(length));
|
||||
FW_ASSERT(FW_SERIALIZE_OK == serStatus, serStatus);
|
||||
serStatus = serializable.deserialize(this->m_buffer);
|
||||
if(FW_SERIALIZE_OK != serStatus) {
|
||||
|
||||
@ -32,7 +32,7 @@ namespace Fw {
|
||||
};
|
||||
|
||||
// NOTE!: This should not be used with an allocator that can return a smaller buffer than requested
|
||||
SerializableFile(MemAllocator* allocator, NATIVE_UINT_TYPE maxSerializedSize);
|
||||
SerializableFile(MemAllocator* allocator, FwSizeType maxSerializedSize);
|
||||
~SerializableFile();
|
||||
|
||||
Status load(const char* fileName, Serializable& serializable);
|
||||
@ -42,7 +42,7 @@ namespace Fw {
|
||||
void reset();
|
||||
MemAllocator* m_allocator;
|
||||
bool m_recoverable; // don't care; for allocator
|
||||
NATIVE_UINT_TYPE m_actualSize; // for checking
|
||||
FwSizeType m_actualSize; // for checking
|
||||
SerialBuffer m_buffer;
|
||||
};
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ namespace Fw {
|
||||
SmSignalBuffer::SmSignalBuffer(const U8 *args, Serializable::SizeType size) : m_bufferData{} {
|
||||
FW_ASSERT(args != nullptr);
|
||||
FW_ASSERT(size <= sizeof(this->m_bufferData));
|
||||
SerializeStatus stat = SerializeBufferBase::setBuff(args,static_cast<NATIVE_UINT_TYPE>(size));
|
||||
SerializeStatus stat = SerializeBufferBase::setBuff(args,size);
|
||||
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<FwAssertArgType>(stat));
|
||||
}
|
||||
|
||||
|
||||
@ -45,14 +45,14 @@ namespace Test {
|
||||
#if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
|
||||
(void)fprintf(stderr,"Assert: 0x%" PRIx32 ":%" PRI_PlatformUIntType "\n", this->m_file, this->m_lineNo);
|
||||
#else
|
||||
(void)fprintf(stderr,"Assert: %s:%" PRI_PlatformUIntType "\n", this->m_file.toChar(), this->m_lineNo);
|
||||
(void)fprintf(stderr,"Assert: %s:%" PRI_FwSizeType "\n", this->m_file.toChar(), this->m_lineNo);
|
||||
#endif
|
||||
}
|
||||
|
||||
void UnitTestAssert::reportAssert(
|
||||
FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -80,8 +80,8 @@ namespace Test {
|
||||
|
||||
void UnitTestAssert::retrieveAssert(
|
||||
File& file,
|
||||
NATIVE_UINT_TYPE& lineNo,
|
||||
NATIVE_UINT_TYPE& numArgs,
|
||||
FwSizeType& lineNo,
|
||||
FwSizeType& numArgs,
|
||||
FwAssertArgType& arg1,
|
||||
FwAssertArgType& arg2,
|
||||
FwAssertArgType& arg3,
|
||||
|
||||
@ -32,8 +32,8 @@ namespace Test {
|
||||
void doAssert();
|
||||
void reportAssert(
|
||||
FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -44,8 +44,8 @@ namespace Test {
|
||||
// retrieves assertion failure values
|
||||
void retrieveAssert(
|
||||
File& file,
|
||||
NATIVE_UINT_TYPE& lineNo,
|
||||
NATIVE_UINT_TYPE& numArgs,
|
||||
FwSizeType& lineNo,
|
||||
FwSizeType& numArgs,
|
||||
FwAssertArgType& arg1,
|
||||
FwAssertArgType& arg2,
|
||||
FwAssertArgType& arg3,
|
||||
@ -62,8 +62,8 @@ namespace Test {
|
||||
|
||||
private:
|
||||
File m_file;
|
||||
NATIVE_UINT_TYPE m_lineNo;
|
||||
NATIVE_UINT_TYPE m_numArgs;
|
||||
FwSizeType m_lineNo;
|
||||
FwSizeType m_numArgs;
|
||||
FwAssertArgType m_arg1;
|
||||
FwAssertArgType m_arg2;
|
||||
FwAssertArgType m_arg3;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
namespace Fw {
|
||||
|
||||
TlmBuffer::TlmBuffer(const U8 *args, NATIVE_UINT_TYPE size) {
|
||||
TlmBuffer::TlmBuffer(const U8 *args, FwSizeType size) {
|
||||
SerializeStatus stat = SerializeBufferBase::setBuff(args,size);
|
||||
FW_ASSERT(FW_SERIALIZE_OK == stat,static_cast<FwAssertArgType>(stat));
|
||||
}
|
||||
@ -29,7 +29,7 @@ namespace Fw {
|
||||
return *this;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE TlmBuffer::getBuffCapacity() const {
|
||||
FwSizeType TlmBuffer::getBuffCapacity() const {
|
||||
return sizeof(this->m_bufferData);
|
||||
}
|
||||
|
||||
|
||||
@ -25,13 +25,13 @@ namespace Fw {
|
||||
SERIALIZED_SIZE = FW_TLM_BUFFER_MAX_SIZE + sizeof(FwBuffSizeType)
|
||||
};
|
||||
|
||||
TlmBuffer(const U8 *args, NATIVE_UINT_TYPE size);
|
||||
TlmBuffer(const U8 *args, FwSizeType size);
|
||||
TlmBuffer();
|
||||
TlmBuffer(const TlmBuffer& other);
|
||||
virtual ~TlmBuffer();
|
||||
TlmBuffer& operator=(const TlmBuffer& other);
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
U8* getBuffAddr();
|
||||
const U8* getBuffAddr() const;
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ namespace Fw {
|
||||
return Fw::FW_SERIALIZE_OK;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE TlmPacket::getNumEntries() {
|
||||
FwSizeType TlmPacket::getNumEntries() {
|
||||
return this->m_numEntries;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ namespace Fw {
|
||||
|
||||
SerializeStatus TlmPacket::addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer) {
|
||||
// check to make sure there is room for all the fields
|
||||
NATIVE_UINT_TYPE left = this->m_tlmBuffer.getBuffCapacity()-this->m_tlmBuffer.getBuffLength();
|
||||
FwSizeType left = this->m_tlmBuffer.getBuffCapacity()-this->m_tlmBuffer.getBuffLength();
|
||||
if (
|
||||
(sizeof(FwChanIdType) + Time::SERIALIZED_SIZE + buffer.getBuffLength()) > left
|
||||
) {
|
||||
@ -97,7 +97,7 @@ namespace Fw {
|
||||
}
|
||||
|
||||
// extract telemetry value
|
||||
SerializeStatus TlmPacket::extractValue(FwChanIdType &id, Time& timeTag, TlmBuffer& buffer, NATIVE_UINT_TYPE bufferSize) {
|
||||
SerializeStatus TlmPacket::extractValue(FwChanIdType &id, Time& timeTag, TlmBuffer& buffer, FwSizeType bufferSize) {
|
||||
|
||||
// deserialize items out of buffer
|
||||
|
||||
@ -147,7 +147,7 @@ namespace Fw {
|
||||
return stat;
|
||||
}
|
||||
// deserialize the channel value entry buffers
|
||||
NATIVE_UINT_TYPE size = buffer.getBuffLeft();
|
||||
FwSizeType size = buffer.getBuffLeft();
|
||||
stat = buffer.deserialize(this->m_tlmBuffer.getBuffAddr(),size,true);
|
||||
if (stat == FW_SERIALIZE_OK) {
|
||||
// Shouldn't fail
|
||||
|
||||
@ -31,7 +31,7 @@ namespace Fw {
|
||||
SerializeStatus addValue(FwChanIdType id, Time& timeTag, TlmBuffer& buffer);
|
||||
//! extract telemetry value - since there are potentially multiple channel values in the packet,
|
||||
//! the size of the entry must be known
|
||||
SerializeStatus extractValue(FwChanIdType &id, Time& timeTag, TlmBuffer& buffer, NATIVE_UINT_TYPE bufferSize);
|
||||
SerializeStatus extractValue(FwChanIdType &id, Time& timeTag, TlmBuffer& buffer, FwSizeType bufferSize);
|
||||
|
||||
//! Reset serialization of values. This should be done when starting to accumulate a new set of values.
|
||||
SerializeStatus resetPktSer();
|
||||
@ -42,11 +42,11 @@ namespace Fw {
|
||||
//! set the internal buffer for deserializing values
|
||||
void setBuffer(Fw::ComBuffer& buffer);
|
||||
//! get the number of packets added via addValue()
|
||||
NATIVE_UINT_TYPE getNumEntries();
|
||||
FwSizeType getNumEntries();
|
||||
|
||||
PRIVATE:
|
||||
ComBuffer m_tlmBuffer; //!< serialized data
|
||||
NATIVE_UINT_TYPE m_numEntries; //!< number of entries stored during addValue()
|
||||
FwSizeType m_numEntries; //!< number of entries stored during addValue()
|
||||
};
|
||||
|
||||
} /* namespace Fw */
|
||||
|
||||
@ -40,18 +40,18 @@ TEST(FwTlmTest,TlmPacketSerializeFill) {
|
||||
|
||||
// compute a single entry size assuming for the test that the value of the telemetry channel
|
||||
// is a U32
|
||||
static const NATIVE_UINT_TYPE SIZE_OF_ENTRY = sizeof(FwChanIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32);
|
||||
static const FwSizeType SIZE_OF_ENTRY = sizeof(FwChanIdType) + Fw::Time::SERIALIZED_SIZE + sizeof(U32);
|
||||
|
||||
// compute the number of entries that should fit - will equal rounded down value of
|
||||
// ComBuffer size - size of telemetry packet id / size of an entry
|
||||
static const NATIVE_UINT_TYPE NUM_ENTRIES = (FW_COM_BUFFER_MAX_SIZE - sizeof(FwPacketDescriptorType))/SIZE_OF_ENTRY;
|
||||
static const FwSizeType NUM_ENTRIES = (FW_COM_BUFFER_MAX_SIZE - sizeof(FwPacketDescriptorType))/SIZE_OF_ENTRY;
|
||||
|
||||
Fw::TlmPacket pktIn;
|
||||
ASSERT_EQ(Fw::FW_SERIALIZE_OK,pktIn.resetPktSer());
|
||||
|
||||
// fill a telemetry packet
|
||||
|
||||
for (NATIVE_UINT_TYPE entry = 0; entry < NUM_ENTRIES; entry++) {
|
||||
for (FwSizeType entry = 0; entry < NUM_ENTRIES; entry++) {
|
||||
|
||||
// Serialize data
|
||||
|
||||
@ -81,7 +81,7 @@ TEST(FwTlmTest,TlmPacketSerializeFill) {
|
||||
ASSERT_EQ(Fw::FW_SERIALIZE_OK,pktOut.resetPktDeser());
|
||||
|
||||
// empty the packet of entries
|
||||
for (NATIVE_UINT_TYPE entry = 0; entry < NUM_ENTRIES; entry++) {
|
||||
for (FwSizeType entry = 0; entry < NUM_ENTRIES; entry++) {
|
||||
// Deserialize data
|
||||
Fw::TlmBuffer buffOut;
|
||||
Fw::Time timeOut;
|
||||
|
||||
@ -20,8 +20,8 @@ void defaultPrintAssert(const CHAR* msg) {
|
||||
}
|
||||
|
||||
void defaultReportAssert(FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -29,40 +29,38 @@ void defaultReportAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg5,
|
||||
FwAssertArgType arg6,
|
||||
CHAR* destBuffer,
|
||||
NATIVE_INT_TYPE buffSize) {
|
||||
static_assert(std::numeric_limits<FwSizeType>::max() >= std::numeric_limits<NATIVE_INT_TYPE>::max(),
|
||||
"NATIVE_INT_TYPE cannot fit into FwSizeType");
|
||||
FwSizeType buffSize) {
|
||||
switch (numArgs) {
|
||||
case 0:
|
||||
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize), fileIdFs, file, lineNo);
|
||||
(void)stringFormat(destBuffer, buffSize, fileIdFs, file, lineNo);
|
||||
break;
|
||||
case 1:
|
||||
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
|
||||
(void)stringFormat(destBuffer, buffSize,
|
||||
fileIdFs " %" PRI_FwAssertArgType, file, lineNo, arg1);
|
||||
break;
|
||||
case 2:
|
||||
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
|
||||
(void)stringFormat(destBuffer, buffSize,
|
||||
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, lineNo, arg1, arg2);
|
||||
break;
|
||||
case 3:
|
||||
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
|
||||
(void)stringFormat(destBuffer, buffSize,
|
||||
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file,
|
||||
lineNo, arg1, arg2, arg3);
|
||||
break;
|
||||
case 4:
|
||||
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
|
||||
(void)stringFormat(destBuffer, buffSize,
|
||||
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
|
||||
" %" PRI_FwAssertArgType,
|
||||
file, lineNo, arg1, arg2, arg3, arg4);
|
||||
break;
|
||||
case 5:
|
||||
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
|
||||
(void)stringFormat(destBuffer, buffSize,
|
||||
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
|
||||
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
|
||||
file, lineNo, arg1, arg2, arg3, arg4, arg5);
|
||||
break;
|
||||
case 6:
|
||||
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
|
||||
(void)stringFormat(destBuffer, buffSize,
|
||||
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
|
||||
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
|
||||
file, lineNo, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
@ -77,8 +75,8 @@ void AssertHook::printAssert(const CHAR* msg) {
|
||||
}
|
||||
|
||||
void AssertHook::reportAssert(FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -86,7 +84,7 @@ void AssertHook::reportAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg5,
|
||||
FwAssertArgType arg6) {
|
||||
CHAR destBuffer[FW_ASSERT_TEXT_SIZE];
|
||||
defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, destBuffer, sizeof(destBuffer));
|
||||
defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, destBuffer, static_cast<FwSizeType>(sizeof(destBuffer)));
|
||||
// print message
|
||||
this->printAssert(destBuffer);
|
||||
}
|
||||
@ -107,9 +105,9 @@ void AssertHook::deregisterHook() {
|
||||
}
|
||||
|
||||
// Default handler of SwAssert functions
|
||||
NATIVE_INT_TYPE defaultSwAssert(FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
I8 defaultSwAssert(FILE_NAME_ARG file,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -118,7 +116,7 @@ NATIVE_INT_TYPE defaultSwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg6) {
|
||||
if (nullptr == s_assertHook) {
|
||||
CHAR assertMsg[FW_ASSERT_TEXT_SIZE];
|
||||
defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, assertMsg, sizeof(assertMsg));
|
||||
defaultReportAssert(file, lineNo, numArgs, arg1, arg2, arg3, arg4, arg5, arg6, assertMsg, static_cast<FwSizeType>(sizeof(assertMsg)));
|
||||
defaultPrintAssert(assertMsg);
|
||||
assert(0);
|
||||
} else {
|
||||
@ -128,66 +126,66 @@ NATIVE_INT_TYPE defaultSwAssert(FILE_NAME_ARG file,
|
||||
return 0;
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo) {
|
||||
I8 SwAssert(FILE_NAME_ARG file, FwSizeType lineNo) {
|
||||
return defaultSwAssert(file, lineNo, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, NATIVE_UINT_TYPE lineNo) {
|
||||
I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwSizeType lineNo) {
|
||||
return defaultSwAssert(file, lineNo, 1, arg1, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, NATIVE_UINT_TYPE lineNo) {
|
||||
I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwSizeType lineNo) {
|
||||
return defaultSwAssert(file, lineNo, 2, arg1, arg2, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file,
|
||||
I8 SwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
NATIVE_UINT_TYPE lineNo) {
|
||||
FwSizeType lineNo) {
|
||||
return defaultSwAssert(file, lineNo, 3, arg1, arg2, arg3, 0, 0, 0);
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file,
|
||||
I8 SwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
FwAssertArgType arg4,
|
||||
NATIVE_UINT_TYPE lineNo) {
|
||||
FwSizeType lineNo) {
|
||||
return defaultSwAssert(file, lineNo, 4, arg1, arg2, arg3, arg4, 0, 0);
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file,
|
||||
I8 SwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
FwAssertArgType arg4,
|
||||
FwAssertArgType arg5,
|
||||
NATIVE_UINT_TYPE lineNo) {
|
||||
FwSizeType lineNo) {
|
||||
return defaultSwAssert(file, lineNo, 5, arg1, arg2, arg3, arg4, arg5, 0);
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file,
|
||||
I8 SwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
FwAssertArgType arg4,
|
||||
FwAssertArgType arg5,
|
||||
FwAssertArgType arg6,
|
||||
NATIVE_UINT_TYPE lineNo) {
|
||||
FwSizeType lineNo) {
|
||||
return defaultSwAssert(file, lineNo, 6, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
}
|
||||
} // namespace Fw
|
||||
|
||||
// define C asserts.
|
||||
// define C asserts with C linkage
|
||||
extern "C" {
|
||||
NATIVE_INT_TYPE CAssert0(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo);
|
||||
I8 CAssert0(FILE_NAME_ARG file, FwSizeType lineNo);
|
||||
}
|
||||
|
||||
NATIVE_INT_TYPE CAssert0(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo) {
|
||||
I8 CAssert0(FILE_NAME_ARG file, FwSizeType lineNo) {
|
||||
if (nullptr == Fw::s_assertHook) {
|
||||
CHAR assertMsg[FW_ASSERT_TEXT_SIZE];
|
||||
Fw::defaultReportAssert(file, lineNo, 0, 0, 0, 0, 0, 0, 0, assertMsg, sizeof(assertMsg));
|
||||
Fw::defaultReportAssert(file, lineNo, 0, 0, 0, 0, 0, 0, 0, assertMsg, static_cast<FwSizeType>(sizeof(assertMsg)));
|
||||
} else {
|
||||
Fw::s_assertHook->reportAssert(file, lineNo, 0, 0, 0, 0, 0, 0, 0);
|
||||
Fw::s_assertHook->doAssert();
|
||||
|
||||
@ -55,48 +55,48 @@
|
||||
|
||||
namespace Fw {
|
||||
//! Assert with no arguments
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN;
|
||||
I8 SwAssert(FILE_NAME_ARG file, FwSizeType lineNo) CLANG_ANALYZER_NORETURN;
|
||||
|
||||
//! Assert with one argument
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN;
|
||||
I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwSizeType lineNo) CLANG_ANALYZER_NORETURN;
|
||||
|
||||
//! Assert with two arguments
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, NATIVE_UINT_TYPE lineNo)
|
||||
I8 SwAssert(FILE_NAME_ARG file, FwAssertArgType arg1, FwAssertArgType arg2, FwSizeType lineNo)
|
||||
CLANG_ANALYZER_NORETURN;
|
||||
|
||||
//! Assert with three arguments
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file,
|
||||
I8 SwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN;
|
||||
FwSizeType lineNo) CLANG_ANALYZER_NORETURN;
|
||||
|
||||
//! Assert with four arguments
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file,
|
||||
I8 SwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
FwAssertArgType arg4,
|
||||
NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN;
|
||||
FwSizeType lineNo) CLANG_ANALYZER_NORETURN;
|
||||
|
||||
//! Assert with five arguments
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file,
|
||||
I8 SwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
FwAssertArgType arg4,
|
||||
FwAssertArgType arg5,
|
||||
NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN;
|
||||
FwSizeType lineNo) CLANG_ANALYZER_NORETURN;
|
||||
|
||||
//! Assert with six arguments
|
||||
NATIVE_INT_TYPE SwAssert(FILE_NAME_ARG file,
|
||||
I8 SwAssert(FILE_NAME_ARG file,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
FwAssertArgType arg4,
|
||||
FwAssertArgType arg5,
|
||||
FwAssertArgType arg6,
|
||||
NATIVE_UINT_TYPE lineNo) CLANG_ANALYZER_NORETURN;
|
||||
FwSizeType lineNo) CLANG_ANALYZER_NORETURN;
|
||||
} // namespace Fw
|
||||
|
||||
// Base class for declaring an assert hook
|
||||
@ -111,8 +111,8 @@ class AssertHook {
|
||||
virtual ~AssertHook(){}; //!< destructor
|
||||
// override this function to intercept asserts
|
||||
virtual void reportAssert(FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
|
||||
@ -21,15 +21,14 @@ extern "C" {
|
||||
#else // ASSERT is defined
|
||||
|
||||
#if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
|
||||
#define FILE_NAME_ARG NATIVE_UINT_TYPE
|
||||
#define FILE_NAME_ARG U32
|
||||
#define FW_CASSERT(cond) ((void)((cond) ? (0) : (CAssert0(ASSERT_FILE_ID, __LINE__))))
|
||||
#else
|
||||
#define FILE_NAME_ARG const CHAR*
|
||||
#define FW_CASSERT(cond) ((void)((cond) ? (0) : (CAssert0((FILE_NAME_ARG)(__FILE__), __LINE__))))
|
||||
#endif
|
||||
|
||||
I32 CAssert0(FILE_NAME_ARG file, U32 lineNo); //!< C assert function
|
||||
I32 CAssert1(FILE_NAME_ARG file, U32 lineNo, NATIVE_INT_TYPE arg1); //!< C assert function 1
|
||||
I8 CAssert0(FILE_NAME_ARG file, FwSizeType lineNo); //!< C assert function
|
||||
|
||||
#endif // ASSERT is defined
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ MallocAllocator::MallocAllocator() {}
|
||||
|
||||
MallocAllocator::~MallocAllocator() {}
|
||||
|
||||
void* MallocAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable) {
|
||||
void* MallocAllocator::allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable) {
|
||||
// don't use identifier
|
||||
// heap memory is never recoverable
|
||||
recoverable = false;
|
||||
@ -30,7 +30,7 @@ void* MallocAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_T
|
||||
return mem;
|
||||
}
|
||||
|
||||
void MallocAllocator::deallocate(const NATIVE_UINT_TYPE identifier, void* ptr) {
|
||||
void MallocAllocator::deallocate(const FwEnumStoreType identifier, void* ptr) {
|
||||
::free(ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -37,13 +37,13 @@ class MallocAllocator : public MemAllocator {
|
||||
* \param recoverable - flag to indicate the memory could be recoverable (always set to false)
|
||||
* \return the pointer to memory. Zero if unable to allocate.
|
||||
*/
|
||||
void* allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable);
|
||||
void* allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable);
|
||||
//! Deallocate memory
|
||||
/*!
|
||||
* \param identifier the memory segment identifier (not used)
|
||||
* \param ptr the pointer to memory returned by allocate()
|
||||
*/
|
||||
void deallocate(const NATIVE_UINT_TYPE identifier, void* ptr);
|
||||
void deallocate(const FwEnumStoreType identifier, void* ptr);
|
||||
};
|
||||
|
||||
} /* namespace Fw */
|
||||
|
||||
@ -52,13 +52,13 @@ class MemAllocator {
|
||||
* \param recoverable - flag to indicate the memory could be recoverable
|
||||
* \return the pointer to memory. Zero if unable to allocate
|
||||
*/
|
||||
virtual void* allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable) = 0;
|
||||
virtual void* allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable) = 0;
|
||||
//! Deallocate memory
|
||||
/*!
|
||||
* \param identifier the memory segment identifier, each identifier is to be used in once single allocation
|
||||
* \param ptr the pointer to memory returned by allocate()
|
||||
*/
|
||||
virtual void deallocate(const NATIVE_UINT_TYPE identifier, void* ptr) = 0;
|
||||
virtual void deallocate(const FwEnumStoreType identifier, void* ptr) = 0;
|
||||
|
||||
protected:
|
||||
MemAllocator();
|
||||
|
||||
@ -21,7 +21,7 @@ MmapAllocator::MmapAllocator() : m_length(0) {}
|
||||
|
||||
MmapAllocator::~MmapAllocator() {}
|
||||
|
||||
void* MmapAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable) {
|
||||
void* MmapAllocator::allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable) {
|
||||
void* addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
size = 0;
|
||||
@ -35,7 +35,7 @@ void* MmapAllocator::allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYP
|
||||
return addr;
|
||||
}
|
||||
|
||||
void MmapAllocator::deallocate(const NATIVE_UINT_TYPE identifier, void* ptr) {
|
||||
void MmapAllocator::deallocate(const FwEnumStoreType identifier, void* ptr) {
|
||||
if (this->m_length) {
|
||||
int stat = munmap(ptr, this->m_length);
|
||||
FW_ASSERT(stat == 0, stat);
|
||||
|
||||
@ -31,15 +31,15 @@ class MmapAllocator : public MemAllocator {
|
||||
//! \param identifier: identifier to use with allocation
|
||||
//! \param size: size of memory to be allocated
|
||||
//! \param recoverable: (output) is this memory recoverable after a reset. Always false for mmap.
|
||||
void* allocate(const NATIVE_UINT_TYPE identifier, NATIVE_UINT_TYPE& size, bool& recoverable);
|
||||
void* allocate(const FwEnumStoreType identifier, FwSizeType& size, bool& recoverable);
|
||||
|
||||
//! Deallocation of memory using the mmap allocator
|
||||
//! \param identifier: identifier used at allocation
|
||||
//! \param ptr: pointer to memory being deallocated
|
||||
void deallocate(const NATIVE_UINT_TYPE identifier, void* ptr);
|
||||
void deallocate(const FwEnumStoreType identifier, void* ptr);
|
||||
|
||||
private:
|
||||
NATIVE_UINT_TYPE m_length;
|
||||
FwSizeType m_length;
|
||||
};
|
||||
|
||||
} /* namespace Fw */
|
||||
|
||||
@ -15,9 +15,9 @@
|
||||
|
||||
namespace Fw {
|
||||
|
||||
SerialBuffer ::SerialBuffer(U8* const data, const U32 capacity) : m_data(data), m_capacity(capacity) {}
|
||||
SerialBuffer ::SerialBuffer(U8* const data, const FwSizeType capacity) : m_data(data), m_capacity(capacity) {}
|
||||
|
||||
NATIVE_UINT_TYPE SerialBuffer ::getBuffCapacity() const {
|
||||
FwSizeType SerialBuffer ::getBuffCapacity() const {
|
||||
return m_capacity;
|
||||
}
|
||||
|
||||
@ -34,12 +34,12 @@ void SerialBuffer ::fill() {
|
||||
FW_ASSERT(status == FW_SERIALIZE_OK);
|
||||
}
|
||||
|
||||
SerializeStatus SerialBuffer ::pushBytes(const U8* const addr, const NATIVE_UINT_TYPE n) {
|
||||
SerializeStatus SerialBuffer ::pushBytes(const U8* const addr, const FwSizeType n) {
|
||||
// "true" means "just push the bytes"
|
||||
return this->serialize(const_cast<U8*>(addr), n, true);
|
||||
}
|
||||
|
||||
SerializeStatus SerialBuffer ::popBytes(U8* const addr, NATIVE_UINT_TYPE n) {
|
||||
SerializeStatus SerialBuffer ::popBytes(U8* const addr, FwSizeType n) {
|
||||
// "true" means "just pop the bytes"
|
||||
return this->deserialize(addr, n, true);
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class SerialBuffer final : public SerializeBufferBase {
|
||||
//! Construct a SerialBuffer
|
||||
//!
|
||||
SerialBuffer(U8* const data, //!< Pointer to the data
|
||||
const U32 capacity //!< The buffer capacity
|
||||
const FwSizeType capacity //!< The buffer capacity
|
||||
);
|
||||
|
||||
public:
|
||||
@ -38,7 +38,7 @@ class SerialBuffer final : public SerializeBufferBase {
|
||||
// Pure virtual methods from SerializeBufferBase
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const;
|
||||
FwSizeType getBuffCapacity() const;
|
||||
|
||||
U8* getBuffAddr();
|
||||
|
||||
@ -54,12 +54,12 @@ class SerialBuffer final : public SerializeBufferBase {
|
||||
|
||||
//! Push n bytes onto the buffer
|
||||
SerializeStatus pushBytes(const U8* const addr, //!< Address of bytes to push
|
||||
const NATIVE_UINT_TYPE n //!< Number of bytes
|
||||
const FwSizeType n //!< Number of bytes
|
||||
);
|
||||
|
||||
//! Pop n bytes off the buffer
|
||||
SerializeStatus popBytes(U8* const addr, //!< Address of bytes to pop
|
||||
NATIVE_UINT_TYPE n //!< Number of bytes to pop
|
||||
FwSizeType n //!< Number of bytes to pop
|
||||
);
|
||||
|
||||
private:
|
||||
@ -71,7 +71,7 @@ class SerialBuffer final : public SerializeBufferBase {
|
||||
U8* const m_data;
|
||||
|
||||
//! The capacity
|
||||
const U32 m_capacity;
|
||||
const FwSizeType m_capacity;
|
||||
};
|
||||
|
||||
} // namespace Fw
|
||||
|
||||
@ -222,7 +222,7 @@ SerializeStatus SerializeBufferBase::serialize(const void* val) {
|
||||
return FW_SERIALIZE_NO_ROOM_LEFT;
|
||||
}
|
||||
|
||||
return this->serialize(reinterpret_cast<POINTER_CAST>(val));
|
||||
return this->serialize(reinterpret_cast<PlatformPointerCastType>(val));
|
||||
}
|
||||
|
||||
SerializeStatus SerializeBufferBase::serialize(const U8* buff, Serializable::SizeType length) {
|
||||
|
||||
@ -25,7 +25,7 @@ class SerializeBufferBase; //!< forward declaration
|
||||
class Serializable {
|
||||
public:
|
||||
// Size type for backwards compatibility
|
||||
using SizeType = NATIVE_UINT_TYPE;
|
||||
using SizeType = FwSizeType;
|
||||
|
||||
public:
|
||||
virtual SerializeStatus serialize(SerializeBufferBase& buffer) const = 0; //!< serialize contents
|
||||
@ -85,9 +85,9 @@ class SerializeBufferBase {
|
||||
const void* val); //!< serialize pointer (careful, only pointer value, not contents are serialized)
|
||||
|
||||
//! serialize data buffer
|
||||
SerializeStatus serialize(const U8* buff, NATIVE_UINT_TYPE length, bool noLength);
|
||||
SerializeStatus serialize(const U8* buff, FwSizeType length, bool noLength);
|
||||
//! serialize data buffer
|
||||
SerializeStatus serialize(const U8* buff, NATIVE_UINT_TYPE length);
|
||||
SerializeStatus serialize(const U8* buff, FwSizeType length);
|
||||
|
||||
//! \brief serialize a byte buffer of a given length
|
||||
//!
|
||||
@ -133,10 +133,10 @@ class SerializeBufferBase {
|
||||
SerializeStatus deserialize(void*& val); //!< deserialize point value (careful, pointer value only, not contents)
|
||||
|
||||
//! deserialize data buffer
|
||||
SerializeStatus deserialize(U8* buff, NATIVE_UINT_TYPE& length, bool noLength);
|
||||
SerializeStatus deserialize(U8* buff, FwSizeType& length, bool noLength);
|
||||
|
||||
//! deserialize data buffer
|
||||
SerializeStatus deserialize(U8* buff, NATIVE_UINT_TYPE& length);
|
||||
SerializeStatus deserialize(U8* buff, FwSizeType& length);
|
||||
//! \brief deserialize a byte buffer of a given length
|
||||
//!
|
||||
//! Deserialize bytes into `buff` of `length` bytes. If `serializationMode` is set to `INCLUDE_LENGTH` then
|
||||
|
||||
@ -24,7 +24,7 @@ namespace Fw {
|
||||
|
||||
class StringBase : public Serializable {
|
||||
public:
|
||||
using SizeType = NATIVE_UINT_TYPE;
|
||||
using SizeType = FwSizeType;
|
||||
virtual const CHAR* toChar() const = 0; //<! Convert to a C-style char*
|
||||
virtual SizeType getCapacity() const = 0; //!< return size of buffer
|
||||
SizeType length() const; //!< Get length of string
|
||||
|
||||
@ -1,96 +0,0 @@
|
||||
/**
|
||||
* \brief DefaultTypes.hpp provides fallback defaults for the platform types
|
||||
*
|
||||
* This fill contains default implementations for types typically defined in
|
||||
* PlatformTypes.hpp. These default implementations are based on x86_64 Linux
|
||||
* but are often appropriate for most systems.
|
||||
*/
|
||||
#include <limits>
|
||||
/**
|
||||
* Default implementation for deprecated (see note)
|
||||
*/
|
||||
#ifndef PLATFORM_INT_TYPE_DEFINED
|
||||
typedef int PlatformIntType;
|
||||
extern const PlatformIntType PlatformIntType_MIN;
|
||||
extern const PlatformIntType PlatformIntType_MAX;
|
||||
#define PLATFORM_INT_TYPE_DEFINED
|
||||
#define PRI_PlatformIntType "d"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default implementation for deprecated (see note)
|
||||
*/
|
||||
#ifndef PLATFORM_UINT_TYPE_DEFINED
|
||||
typedef unsigned int PlatformUIntType;
|
||||
extern const PlatformUIntType PlatformUIntType_MIN;
|
||||
extern const PlatformUIntType PlatformUIntType_MAX;
|
||||
#define PLATFORM_UINT_TYPE_DEFINED
|
||||
#define PRI_PlatformUIntType "ud"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default implementation for ports indices
|
||||
*/
|
||||
#ifndef PLATFORM_INDEX_TYPE_DEFINED
|
||||
typedef PlatformIntType PlatformIndexType;
|
||||
extern const PlatformIndexType PlatformIndexType_MIN;
|
||||
extern const PlatformIndexType PlatformIndexType_MAX;
|
||||
#define PLATFORM_INDEX_TYPE_DEFINED
|
||||
#define PRI_PlatformIndexType PRI_PlatformIntType
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default implementation for sizes
|
||||
*/
|
||||
#ifndef PLATFORM_SIZE_TYPE_DEFINED
|
||||
typedef PlatformUIntType PlatformSizeType;
|
||||
extern const PlatformSizeType PlatformSizeType_MIN;
|
||||
extern const PlatformSizeType PlatformSizeType_MAX;
|
||||
#define PLATFORM_SIZE_TYPE_DEFINED
|
||||
#define PRI_PlatformSizeType PRI_PlatformUIntType
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default implementation for argument to fw_assert
|
||||
*/
|
||||
#ifndef PLATFORM_ASSERT_ARG_TYPE_DEFINED
|
||||
typedef PlatformIntType PlatformAssertArgType;
|
||||
extern const PlatformAssertArgType PlatformAssertArgType_MIN;
|
||||
extern const PlatformAssertArgType PlatformAssertArgType_MAX;
|
||||
#define PLATFORM_ASSERT_ARG_TYPE_DEFINED
|
||||
#define PRI_PlatformAssertArgType PRI_PlatformIntType
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default implementation for pointers stored as integers
|
||||
*/
|
||||
#ifndef PLATFORM_POINTER_CAST_TYPE_DEFINED
|
||||
// Check for __SIZEOF_POINTER__ or cause error
|
||||
#ifndef __SIZEOF_POINTER__
|
||||
#error "Compiler does not support __SIZEOF_POINTER__, cannot use default for PlatformPointerCastType"
|
||||
#endif
|
||||
|
||||
// Pointer sizes are determined by size of compiler
|
||||
#if __SIZEOF_POINTER__ == 8
|
||||
typedef uint64_t PlatformPointerCastType;
|
||||
extern const PlatformPointerCastType PlatformPointerCastType_MIN;
|
||||
extern const PlatformPointerCastType PlatformPointerCastType_MAX;
|
||||
#define PRI_PlatformPointerCastType PRIx64
|
||||
#elif __SIZEOF_POINTER__ == 4
|
||||
typedef uint32_t PlatformPointerCastType;
|
||||
extern const PlatformPointerCastType PlatformPointerCastType_MIN;
|
||||
extern const PlatformPointerCastType PlatformPointerCastType_MAX;
|
||||
#define PRI_PlatformPointerCastType PRIx32
|
||||
#elif __SIZEOF_POINTER__ == 2
|
||||
typedef uint16_t PlatformPointerCastType;
|
||||
extern const PlatformPointerCastType PlatformPointerCastType_MIN;
|
||||
extern const PlatformPointerCastType PlatformPointerCastType_MAX;
|
||||
#define PRI_PlatformPointerCastType PRIx16
|
||||
#else
|
||||
typedef uint8_t PlatformPointerCastType;
|
||||
extern const PlatformPointerCastType PlatformPointerCastType_MIN;
|
||||
extern const PlatformPointerCastType PlatformPointerCastType_MAX;
|
||||
#define PRI_PlatformPointerCastType PRIx8
|
||||
#endif
|
||||
#define PLATFORM_POINTER_CAST_TYPE_DEFINED
|
||||
#endif
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
class SerializeTestBuffer : public Fw::SerializeBufferBase {
|
||||
public:
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const { // !< returns capacity, not current size, of buffer
|
||||
FwSizeType getBuffCapacity() const { // !< returns capacity, not current size, of buffer
|
||||
return sizeof(m_testBuff);
|
||||
}
|
||||
|
||||
@ -742,8 +742,8 @@ void AssertTest() {
|
||||
TestAssertHook() {}
|
||||
virtual ~TestAssertHook() {}
|
||||
void reportAssert(FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -765,9 +765,9 @@ void AssertTest() {
|
||||
|
||||
FILE_NAME_ARG getFile() { return this->m_file; }
|
||||
|
||||
NATIVE_UINT_TYPE getLineNo() { return this->m_lineNo; }
|
||||
FwSizeType getLineNo() { return this->m_lineNo; }
|
||||
|
||||
NATIVE_UINT_TYPE getNumArgs() { return this->m_numArgs; }
|
||||
FwSizeType getNumArgs() { return this->m_numArgs; }
|
||||
|
||||
FwAssertArgType getArg1() { return this->m_arg1; }
|
||||
|
||||
@ -793,8 +793,8 @@ void AssertTest() {
|
||||
#else
|
||||
FILE_NAME_ARG m_file = nullptr;
|
||||
#endif
|
||||
NATIVE_UINT_TYPE m_lineNo = 0;
|
||||
NATIVE_UINT_TYPE m_numArgs = 0;
|
||||
FwSizeType m_lineNo = 0;
|
||||
FwSizeType m_numArgs = 0;
|
||||
FwAssertArgType m_arg1 = 0;
|
||||
FwAssertArgType m_arg2 = 0;
|
||||
FwAssertArgType m_arg3 = 0;
|
||||
@ -1202,12 +1202,12 @@ TEST(PerformanceTest, F64SerPerfTest) {
|
||||
F64 in = 10000.0;
|
||||
F64 out = 0;
|
||||
|
||||
NATIVE_INT_TYPE iters = 1000000;
|
||||
FwSizeType iters = 1000000;
|
||||
|
||||
Os::IntervalTimer timer;
|
||||
timer.start();
|
||||
|
||||
for (NATIVE_INT_TYPE iter = 0; iter < iters; iter++) {
|
||||
for (FwSizeType iter = 0; iter < iters; iter++) {
|
||||
buff.resetSer();
|
||||
buff.serialize(in);
|
||||
buff.deserialize(out);
|
||||
@ -1215,7 +1215,7 @@ TEST(PerformanceTest, F64SerPerfTest) {
|
||||
|
||||
timer.stop();
|
||||
|
||||
printf("%d iterations took %d us (%f us each).\n", iters, timer.getDiffUsec(),
|
||||
printf("%" PRI_FwSizeType " iterations took %d us (%f us each).\n", iters, timer.getDiffUsec(),
|
||||
static_cast<F32>(timer.getDiffUsec()) / static_cast<F32>(iters));
|
||||
}
|
||||
|
||||
@ -1223,7 +1223,7 @@ TEST(AllocatorTest, MallocAllocatorTest) {
|
||||
// Since it is a wrapper around malloc, the test consists of requesting
|
||||
// memory and verifying a non-zero pointer, unchanged size, and not recoverable.
|
||||
Fw::MallocAllocator allocator;
|
||||
NATIVE_UINT_TYPE size = 100; // one hundred bytes
|
||||
FwSizeType size = 100; // one hundred bytes
|
||||
bool recoverable;
|
||||
void* ptr = allocator.allocate(10, size, recoverable);
|
||||
ASSERT_EQ(100, size);
|
||||
|
||||
@ -20,11 +20,10 @@ namespace Os {
|
||||
FileSystem::Status fs_status;
|
||||
FwSignedSizeType fileSize = 0;
|
||||
fs_status = FileSystem::getFileSize(fileName, fileSize); //!< gets the size of the file (in bytes) at location path
|
||||
// fileSize will be used as a NATIVE_INT_TYPE below and thus must cast cleanly to that type
|
||||
if( FileSystem::OP_OK != fs_status) {
|
||||
return File::BAD_SIZE;
|
||||
}
|
||||
const NATIVE_INT_TYPE max_itr = static_cast<NATIVE_INT_TYPE>(fileSize/VFILE_HASH_CHUNK_SIZE + 1);
|
||||
const FwSignedSizeType max_itr = (fileSize/VFILE_HASH_CHUNK_SIZE + 1);
|
||||
|
||||
// Read all data from file and update hash:
|
||||
Utils::Hash hash;
|
||||
@ -44,7 +43,7 @@ namespace Os {
|
||||
break;
|
||||
}
|
||||
// Add chunk to hash calculation:
|
||||
hash.update(&buffer, static_cast<NATIVE_INT_TYPE>(size));
|
||||
hash.update(&buffer, static_cast<FwSizeType>(size));
|
||||
cnt++;
|
||||
}
|
||||
file.close();
|
||||
@ -74,18 +73,18 @@ namespace Os {
|
||||
|
||||
// Read hash from checksum file:
|
||||
unsigned char savedHash[HASH_DIGEST_LENGTH];
|
||||
FwSignedSizeType size = hashBuffer.getBuffCapacity();
|
||||
FwSignedSizeType size = static_cast<FwSignedSizeType>(hashBuffer.getBuffCapacity());
|
||||
status = hashFile.read(savedHash, size);
|
||||
if( File::OP_OK != status ) {
|
||||
return status;
|
||||
}
|
||||
if( size != static_cast<NATIVE_INT_TYPE>(hashBuffer.getBuffCapacity()) ) {
|
||||
if(static_cast<FwSizeType>(size) != hashBuffer.getBuffCapacity()) {
|
||||
return File::BAD_SIZE;
|
||||
}
|
||||
hashFile.close();
|
||||
|
||||
// Return the hash buffer:
|
||||
Utils::HashBuffer savedHashBuffer(savedHash, static_cast<NATIVE_UINT_TYPE>(size));
|
||||
Utils::HashBuffer savedHashBuffer(savedHash, static_cast<FwSizeType>(size));
|
||||
hashBuffer = savedHashBuffer;
|
||||
|
||||
return status;
|
||||
@ -101,12 +100,12 @@ namespace Os {
|
||||
}
|
||||
|
||||
// Write out the hash
|
||||
FwSignedSizeType size = hashBuffer.getBuffLength();
|
||||
FwSignedSizeType size = static_cast<FwSignedSizeType>(hashBuffer.getBuffLength());
|
||||
status = hashFile.write(hashBuffer.getBuffAddr(), size, Os::File::WaitType::NO_WAIT);
|
||||
if( File::OP_OK != status ) {
|
||||
return status;
|
||||
}
|
||||
if( size != static_cast<NATIVE_INT_TYPE>(hashBuffer.getBuffLength()) ) {
|
||||
if(static_cast<FwSizeType>(size) != hashBuffer.getBuffLength()) {
|
||||
return File::BAD_SIZE;
|
||||
}
|
||||
hashFile.close();
|
||||
|
||||
@ -57,7 +57,7 @@ void testValidateFile(const char* fileName) {
|
||||
return;
|
||||
}
|
||||
Utils::HashBuffer buf;
|
||||
EXPECT_TRUE(fileSize == buf.getBuffCapacity());
|
||||
EXPECT_TRUE(static_cast<FwSizeType>(fileSize) == buf.getBuffCapacity());
|
||||
|
||||
// Validate file:
|
||||
printf("Validating file %s against hash file %s\n", fileName, hashFileName);
|
||||
|
||||
@ -34,7 +34,7 @@ namespace Ref {
|
||||
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK,static_cast<FwAssertArgType>(stat));
|
||||
// deserialize data
|
||||
U8 testData[24] = {0};
|
||||
NATIVE_UINT_TYPE size = sizeof(testData);
|
||||
FwSizeType size = sizeof(testData);
|
||||
stat = buff.deserialize(testData,size);
|
||||
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK,static_cast<FwAssertArgType>(stat));
|
||||
// deserialize checksum
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Svc {
|
||||
// Member Functions
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool LogFile::write_to_log(const char *const buf, const U32 size)
|
||||
bool LogFile::write_to_log(const char *const buf, const FwSizeType size)
|
||||
{
|
||||
|
||||
FW_ASSERT(buf != nullptr);
|
||||
@ -50,9 +50,9 @@ namespace Svc {
|
||||
// Make sure we won't exceed the maximum size:
|
||||
// Note: second condition in if statement is true if there is overflow
|
||||
// in the addition below
|
||||
U32 projectedSize = this->m_currentFileSize + size;
|
||||
FwSizeType projectedSize = this->m_currentFileSize + size;
|
||||
if ( projectedSize > this->m_maxFileSize ||
|
||||
(this->m_currentFileSize > (std::numeric_limits<U32>::max() - size)) ) {
|
||||
(this->m_currentFileSize > (std::numeric_limits<FwSizeType>::max() - size)) ) {
|
||||
|
||||
status = false;
|
||||
this->m_openFile = false;
|
||||
@ -61,16 +61,16 @@ namespace Svc {
|
||||
// Won't exceed max size, so write to file:
|
||||
else {
|
||||
|
||||
FwSignedSizeType writeSize = size;
|
||||
FwSignedSizeType writeSize = static_cast<FwSignedSizeType>(size);
|
||||
Os::File::Status stat = this->m_file.write(reinterpret_cast<const U8*>(buf),writeSize,Os::File::WAIT);
|
||||
|
||||
// Assert that we are not trying to write to a file we never opened:
|
||||
FW_ASSERT(stat != Os::File::NOT_OPENED);
|
||||
|
||||
// Only return a good status if the write was valid
|
||||
status = (writeSize > 0);
|
||||
status = (stat == Os::File::OP_OK) && (static_cast<FwSizeType>(writeSize) == size);
|
||||
|
||||
this->m_currentFileSize += static_cast<U32>(writeSize);
|
||||
this->m_currentFileSize += static_cast<FwSizeType>(writeSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ namespace Svc {
|
||||
}
|
||||
|
||||
|
||||
bool LogFile::set_log_file(const char* fileName, const U32 maxSize, const U32 maxBackups)
|
||||
bool LogFile::set_log_file(const char* fileName, const FwSizeType maxSize, const FwSizeType maxBackups)
|
||||
{
|
||||
FW_ASSERT(fileName != nullptr);
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ namespace Svc {
|
||||
//! \param maxBackups The max backups for the file. Default: 10
|
||||
//!
|
||||
//! \return true if creating the file was successful, false otherwise
|
||||
bool set_log_file(const char* fileName, const U32 maxSize, const U32 maxBackups = 10);
|
||||
bool set_log_file(const char* fileName, const FwSizeType maxSize, const FwSizeType maxBackups = 10);
|
||||
|
||||
//! \brief Write the passed buf to the log if possible
|
||||
//!
|
||||
@ -48,7 +48,7 @@ namespace Svc {
|
||||
//! \param size The size of buf
|
||||
//!
|
||||
//! \return true if writing to the file was successful, false otherwise
|
||||
bool write_to_log(const char *const buf, const U32 size);
|
||||
bool write_to_log(const char *const buf, const FwSizeType size);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Member Variables
|
||||
@ -61,13 +61,13 @@ namespace Svc {
|
||||
Os::File m_file;
|
||||
|
||||
// The max size of the text log file:
|
||||
U32 m_maxFileSize;
|
||||
FwSizeType m_maxFileSize;
|
||||
|
||||
// True if there is currently an open file to write text logs to:
|
||||
bool m_openFile;
|
||||
|
||||
// Current size of the file:
|
||||
U32 m_currentFileSize;
|
||||
FwSizeType m_currentFileSize;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -22,8 +22,8 @@ namespace Fw {
|
||||
void defaultReportAssert
|
||||
(
|
||||
FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -31,7 +31,7 @@ namespace Fw {
|
||||
FwAssertArgType arg5,
|
||||
FwAssertArgType arg6,
|
||||
CHAR* destBuffer,
|
||||
NATIVE_INT_TYPE buffSize
|
||||
FwSizeType buffSize
|
||||
);
|
||||
|
||||
}
|
||||
@ -62,8 +62,8 @@ namespace Svc {
|
||||
|
||||
void AssertFatalAdapterComponentImpl::AssertFatalAdapter::reportAssert(
|
||||
FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -98,8 +98,8 @@ namespace Svc {
|
||||
|
||||
void AssertFatalAdapterComponentImpl::reportAssert(
|
||||
FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -117,7 +117,7 @@ namespace Svc {
|
||||
#endif
|
||||
|
||||
CHAR msg[Fw::StringBase::BUFFER_SIZE(FW_ASSERT_TEXT_SIZE)] = {0};
|
||||
Fw::defaultReportAssert(file,lineNo,numArgs,arg1,arg2,arg3,arg4,arg5,arg6,msg,sizeof(msg));
|
||||
Fw::defaultReportAssert(file,static_cast<U32>(lineNo),numArgs,arg1,arg2,arg3,arg4,arg5,arg6,msg,sizeof(msg));
|
||||
Fw::Logger::log("%s\n", msg);
|
||||
|
||||
// Handle the case where the ports aren't connected yet
|
||||
@ -130,25 +130,25 @@ namespace Svc {
|
||||
case 0:
|
||||
this->log_FATAL_AF_ASSERT_0(
|
||||
fileArg,
|
||||
lineNo);
|
||||
static_cast<U32>(lineNo));
|
||||
break;
|
||||
case 1:
|
||||
this->log_FATAL_AF_ASSERT_1(
|
||||
fileArg,
|
||||
lineNo,
|
||||
static_cast<U32>(lineNo),
|
||||
static_cast<U32>(arg1));
|
||||
break;
|
||||
case 2:
|
||||
this->log_FATAL_AF_ASSERT_2(
|
||||
fileArg,
|
||||
lineNo,
|
||||
static_cast<U32>(lineNo),
|
||||
static_cast<U32>(arg1),
|
||||
static_cast<U32>(arg2));
|
||||
break;
|
||||
case 3:
|
||||
this->log_FATAL_AF_ASSERT_3(
|
||||
fileArg,
|
||||
lineNo,
|
||||
static_cast<U32>(lineNo),
|
||||
static_cast<U32>(arg1),
|
||||
static_cast<U32>(arg2),
|
||||
static_cast<U32>(arg3));
|
||||
@ -156,7 +156,7 @@ namespace Svc {
|
||||
case 4:
|
||||
this->log_FATAL_AF_ASSERT_4(
|
||||
fileArg,
|
||||
lineNo,
|
||||
static_cast<U32>(lineNo),
|
||||
static_cast<U32>(arg1),
|
||||
static_cast<U32>(arg2),
|
||||
static_cast<U32>(arg3),
|
||||
@ -165,7 +165,7 @@ namespace Svc {
|
||||
case 5:
|
||||
this->log_FATAL_AF_ASSERT_5(
|
||||
fileArg,
|
||||
lineNo,
|
||||
static_cast<U32>(lineNo),
|
||||
static_cast<U32>(arg1),
|
||||
static_cast<U32>(arg2),
|
||||
static_cast<U32>(arg3),
|
||||
@ -175,7 +175,7 @@ namespace Svc {
|
||||
case 6:
|
||||
this->log_FATAL_AF_ASSERT_6(
|
||||
fileArg,
|
||||
lineNo,
|
||||
static_cast<U32>(lineNo),
|
||||
static_cast<U32>(arg1),
|
||||
static_cast<U32>(arg2),
|
||||
static_cast<U32>(arg3),
|
||||
@ -184,7 +184,7 @@ namespace Svc {
|
||||
static_cast<U32>(arg6));
|
||||
break;
|
||||
default:
|
||||
this->log_FATAL_AF_UNEXPECTED_ASSERT(fileArg,lineNo,numArgs);
|
||||
this->log_FATAL_AF_UNEXPECTED_ASSERT(fileArg,static_cast<U32>(lineNo),static_cast<U32>(numArgs));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -40,8 +40,8 @@ namespace Svc {
|
||||
//! Report the assert as a FATAL
|
||||
void reportAssert(
|
||||
FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
@ -60,8 +60,8 @@ namespace Svc {
|
||||
private:
|
||||
void reportAssert(
|
||||
FILE_NAME_ARG file,
|
||||
NATIVE_UINT_TYPE lineNo,
|
||||
NATIVE_UINT_TYPE numArgs,
|
||||
FwSizeType lineNo,
|
||||
FwSizeType numArgs,
|
||||
FwAssertArgType arg1,
|
||||
FwAssertArgType arg2,
|
||||
FwAssertArgType arg3,
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "Fw/Types/BasicTypes.hpp"
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace Svc {
|
||||
|
||||
@ -46,21 +46,25 @@ BufferAccumulator ::~BufferAccumulator() {}
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void BufferAccumulator ::allocateQueue(
|
||||
NATIVE_INT_TYPE identifier, Fw::MemAllocator& allocator,
|
||||
FwEnumStoreType identifier, Fw::MemAllocator& allocator,
|
||||
NATIVE_UINT_TYPE maxNumBuffers //!< The maximum number of buffers
|
||||
) {
|
||||
|
||||
this->m_allocatorId = identifier;
|
||||
NATIVE_UINT_TYPE memSize = static_cast<NATIVE_UINT_TYPE>(sizeof(Fw::Buffer) * maxNumBuffers);
|
||||
// Overflow protection
|
||||
FW_ASSERT(
|
||||
(std::numeric_limits<FwSizeType>::max() / maxNumBuffers) >= sizeof(Fw::Buffer)
|
||||
);
|
||||
FwSizeType memSize = static_cast<FwSizeType>(sizeof(Fw::Buffer) * maxNumBuffers);
|
||||
bool recoverable = false;
|
||||
this->m_bufferMemory = static_cast<Fw::Buffer*>(
|
||||
allocator.allocate(static_cast<NATIVE_UINT_TYPE>(identifier), memSize, recoverable));
|
||||
allocator.allocate(identifier, memSize, recoverable));
|
||||
//TODO: Fail gracefully here
|
||||
m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
|
||||
}
|
||||
|
||||
void BufferAccumulator ::deallocateQueue(Fw::MemAllocator& allocator) {
|
||||
allocator.deallocate(static_cast<NATIVE_UINT_TYPE>(this->m_allocatorId), this->m_bufferMemory);
|
||||
allocator.deallocate(static_cast<FwEnumStoreType>(this->m_allocatorId), this->m_bufferMemory);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@ -103,7 +103,7 @@ namespace Svc {
|
||||
//! Give the class a memory buffer. Should be called after constructor
|
||||
//! and init, but before task is spawned.
|
||||
void allocateQueue(
|
||||
NATIVE_INT_TYPE identifier, Fw::MemAllocator& allocator,
|
||||
FwEnumStoreType identifier, Fw::MemAllocator& allocator,
|
||||
NATIVE_UINT_TYPE maxNumBuffers //!< The maximum number of buffers
|
||||
);
|
||||
|
||||
@ -204,7 +204,7 @@ namespace Svc {
|
||||
U32 m_cmdSeq;
|
||||
|
||||
//! The allocator ID
|
||||
NATIVE_INT_TYPE m_allocatorId;
|
||||
FwEnumStoreType m_allocatorId;
|
||||
};
|
||||
|
||||
} // namespace Svc
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Svc {
|
||||
initLog(
|
||||
const char *const logFilePrefix,
|
||||
const char *const logFileSuffix,
|
||||
const U32 maxFileSize,
|
||||
const FwSizeType maxFileSize,
|
||||
const U8 sizeOfSize
|
||||
)
|
||||
{
|
||||
@ -56,7 +56,7 @@ namespace Svc {
|
||||
{
|
||||
if (m_state == LogState::LOGGING_ON) {
|
||||
const U8 *const addr = fwBuffer.getData();
|
||||
const U32 size = fwBuffer.getSize();
|
||||
const FwSizeType size = fwBuffer.getSize();
|
||||
m_file.logBuffer(addr, size);
|
||||
}
|
||||
this->bufferSendOut_out(0, fwBuffer);
|
||||
@ -71,7 +71,7 @@ namespace Svc {
|
||||
{
|
||||
if (m_state == LogState::LOGGING_ON) {
|
||||
const U8 *const addr = data.getBuffAddr();
|
||||
const U32 size = data.getBuffLength();
|
||||
const FwSizeType size = data.getBuffLength();
|
||||
m_file.logBuffer(addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ namespace Svc {
|
||||
void init(
|
||||
const char *const prefix, //!< The file name prefix
|
||||
const char *const suffix, //!< The file name suffix
|
||||
const U32 maxSize, //!< The maximum file size
|
||||
const FwSizeType maxSize, //!< The maximum file size
|
||||
const U8 sizeOfSize //!< The number of bytes to use when storing the size field and the start of each buffer)
|
||||
);
|
||||
|
||||
@ -73,7 +73,7 @@ namespace Svc {
|
||||
//! Log a buffer
|
||||
void logBuffer(
|
||||
const U8 *const data, //!< The buffer data
|
||||
const U32 size //!< The size
|
||||
const FwSizeType size //!< The size
|
||||
);
|
||||
|
||||
//! Close the file and emit an event
|
||||
@ -91,20 +91,20 @@ namespace Svc {
|
||||
//! \return Success or failure
|
||||
bool writeBuffer(
|
||||
const U8 *const data, //!< The buffer data
|
||||
const U32 size //!< The number of bytes to write
|
||||
const FwSizeType size //!< The number of bytes to write
|
||||
);
|
||||
|
||||
//! Write the size field of a buffer
|
||||
//! \return Success or failure
|
||||
bool writeSize(
|
||||
const U32 size //!< The size
|
||||
const FwSizeType size //!< The size
|
||||
);
|
||||
|
||||
//! Write bytes to a file
|
||||
//! \return Success or failure
|
||||
bool writeBytes(
|
||||
const void *const data, //!< The data
|
||||
const U32 length //!< The number of bytes to write
|
||||
const FwSizeType length //!< The number of bytes to write
|
||||
);
|
||||
|
||||
//! Write a hash file
|
||||
@ -131,7 +131,7 @@ namespace Svc {
|
||||
NATIVE_UINT_TYPE m_fileCounter;
|
||||
|
||||
//! The maximum file size
|
||||
U32 m_maxSize;
|
||||
FwSizeType m_maxSize;
|
||||
|
||||
//! The number of bytes to use when storing the size field at the start of each buffer
|
||||
U8 m_sizeOfSize;
|
||||
@ -146,7 +146,7 @@ namespace Svc {
|
||||
Os::File m_osFile;
|
||||
|
||||
//! The number of bytes written to the current file
|
||||
U32 m_bytesWritten;
|
||||
FwSizeType m_bytesWritten;
|
||||
|
||||
}; // class File
|
||||
|
||||
@ -170,7 +170,7 @@ namespace Svc {
|
||||
void initLog(
|
||||
const char *const logFilePrefix, //!< The log file name prefix
|
||||
const char *const logFileSuffix, //!< The log file name suffix
|
||||
const U32 maxFileSize, //!< The maximum file size
|
||||
const FwSizeType maxFileSize, //!< The maximum file size
|
||||
const U8 sizeOfSize //!< The number of bytes to use when storing the size field at the start of each buffer
|
||||
);
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ namespace Svc {
|
||||
init(
|
||||
const char *const logFilePrefix,
|
||||
const char *const logFileSuffix,
|
||||
const U32 maxFileSize,
|
||||
const FwSizeType maxFileSize,
|
||||
const U8 sizeOfSize
|
||||
)
|
||||
{
|
||||
@ -62,7 +62,7 @@ namespace Svc {
|
||||
this->m_maxSize = maxFileSize;
|
||||
this->m_sizeOfSize = sizeOfSize;
|
||||
|
||||
FW_ASSERT(sizeOfSize <= sizeof(U32), sizeOfSize);
|
||||
FW_ASSERT(sizeOfSize <= sizeof(FwSizeType), sizeOfSize);
|
||||
FW_ASSERT(m_maxSize > sizeOfSize, static_cast<FwAssertArgType>(m_maxSize));
|
||||
}
|
||||
|
||||
@ -82,12 +82,12 @@ namespace Svc {
|
||||
void BufferLogger::File ::
|
||||
logBuffer(
|
||||
const U8 *const data,
|
||||
const U32 size
|
||||
const FwSizeType size
|
||||
)
|
||||
{
|
||||
// Close the file if it will be too big
|
||||
if (this->m_mode == File::Mode::OPEN) {
|
||||
const U32 projectedByteCount =
|
||||
const FwSizeType projectedByteCount =
|
||||
this->m_bytesWritten + this->m_sizeOfSize + size;
|
||||
if (projectedByteCount > this->m_maxSize) {
|
||||
this->closeAndEmitEvent();
|
||||
@ -124,7 +124,7 @@ namespace Svc {
|
||||
|
||||
// NOTE(mereweth) - check that file path has been set and that initLog has been called
|
||||
if ((this->m_baseName.toChar()[0] == '\0') ||
|
||||
(this->m_sizeOfSize > sizeof(U32)) ||
|
||||
(this->m_sizeOfSize > sizeof(FwSizeType)) ||
|
||||
(this->m_maxSize <= this->m_sizeOfSize)) {
|
||||
this->m_bufferLogger.log_WARNING_HI_BL_NoLogFileOpenInitError();
|
||||
return;
|
||||
@ -168,7 +168,7 @@ namespace Svc {
|
||||
bool BufferLogger::File ::
|
||||
writeBuffer(
|
||||
const U8 *const data,
|
||||
const U32 size
|
||||
const FwSizeType size
|
||||
)
|
||||
{
|
||||
bool status = this->writeSize(size);
|
||||
@ -179,11 +179,11 @@ namespace Svc {
|
||||
}
|
||||
|
||||
bool BufferLogger::File ::
|
||||
writeSize(const U32 size)
|
||||
writeSize(const FwSizeType size)
|
||||
{
|
||||
FW_ASSERT(this->m_sizeOfSize <= sizeof(U32));
|
||||
U8 sizeBuffer[sizeof(U32)];
|
||||
U32 sizeRegister = size;
|
||||
FW_ASSERT(this->m_sizeOfSize <= sizeof(FwSizeType));
|
||||
U8 sizeBuffer[sizeof(FwSizeType)];
|
||||
FwSizeType sizeRegister = size;
|
||||
for (U8 i = 0; i < this->m_sizeOfSize; ++i) {
|
||||
sizeBuffer[this->m_sizeOfSize - i - 1] = sizeRegister & 0xFF;
|
||||
sizeRegister >>= 8;
|
||||
@ -198,11 +198,11 @@ namespace Svc {
|
||||
bool BufferLogger::File ::
|
||||
writeBytes(
|
||||
const void *const data,
|
||||
const U32 length
|
||||
const FwSizeType length
|
||||
)
|
||||
{
|
||||
FW_ASSERT(length > 0, static_cast<FwAssertArgType>(length));
|
||||
FwSignedSizeType size = length;
|
||||
FW_ASSERT((length > 0) and (length <= std::numeric_limits<FwSignedSizeType>::max()), static_cast<FwAssertArgType>(length));
|
||||
FwSignedSizeType size = static_cast<FwSignedSizeType>(length);
|
||||
const Os::File::Status fileStatus = this->m_osFile.write(reinterpret_cast<const U8*>(data), size);
|
||||
bool status;
|
||||
if (fileStatus == Os::File::OP_OK && size == static_cast<NATIVE_INT_TYPE>(length)) {
|
||||
@ -212,7 +212,7 @@ namespace Svc {
|
||||
else {
|
||||
Fw::LogStringArg string(this->m_name.toChar());
|
||||
|
||||
this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, static_cast<U32>(size), length, string);
|
||||
this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, static_cast<U32>(size), static_cast<U32>(length), string);
|
||||
status = false;
|
||||
}
|
||||
return status;
|
||||
|
||||
@ -160,7 +160,7 @@ namespace Svc {
|
||||
|
||||
void BufferManagerComponentImpl::setup(
|
||||
NATIVE_UINT_TYPE mgrId, //!< manager ID
|
||||
NATIVE_UINT_TYPE memId, //!< Memory segment identifier
|
||||
FwEnumStoreType memId, //!< Memory segment identifier
|
||||
Fw::MemAllocator& allocator, //!< memory allocator
|
||||
const BufferBins& bins //!< Set of user bins
|
||||
) {
|
||||
@ -186,7 +186,7 @@ namespace Svc {
|
||||
}
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE allocatedSize = memorySize;
|
||||
FwSizeType allocatedSize = memorySize;
|
||||
bool recoverable = false; //!< don't care if it is recoverable since they are a pool of user buffers
|
||||
|
||||
// allocate memory
|
||||
|
||||
@ -85,7 +85,7 @@ namespace Svc
|
||||
|
||||
void setup(
|
||||
NATIVE_UINT_TYPE mgrID, //!< ID of manager for buffer checking
|
||||
NATIVE_UINT_TYPE memID, //!< Memory segment identifier
|
||||
FwEnumStoreType memID, //!< Memory segment identifier
|
||||
Fw::MemAllocator &allocator, //!< memory allocator. MUST be persistent for later deallocation.
|
||||
//! MUST persist past destructor if cleanup() not called explicitly.
|
||||
const BufferBins &bins //!< Set of user bins
|
||||
@ -141,7 +141,7 @@ namespace Svc
|
||||
|
||||
AllocatedBuffer *m_buffers; //!< pointer to allocated buffer space
|
||||
Fw::MemAllocator *m_allocator; //!< allocator for memory
|
||||
NATIVE_UINT_TYPE m_memId; //!< identifier for allocator
|
||||
FwEnumStoreType m_memId; //!< identifier for allocator
|
||||
NATIVE_UINT_TYPE m_numStructs; //!< number of allocated structs
|
||||
|
||||
// stats
|
||||
|
||||
@ -44,8 +44,8 @@ class TestAllocator: public Fw::MemAllocator {
|
||||
* \return the pointer to memory. Zero if unable to allocate.
|
||||
*/
|
||||
void *allocate(
|
||||
const NATIVE_UINT_TYPE identifier,
|
||||
NATIVE_UINT_TYPE &size,
|
||||
const FwEnumStoreType identifier,
|
||||
FwSizeType &size,
|
||||
bool& recoverable) {
|
||||
this->m_reqId = identifier;
|
||||
this->m_reqSize = size;
|
||||
@ -58,7 +58,7 @@ class TestAllocator: public Fw::MemAllocator {
|
||||
* \ptr the pointer to memory returned by allocate()
|
||||
*/
|
||||
void deallocate(
|
||||
const NATIVE_UINT_TYPE identifier,
|
||||
const FwEnumStoreType identifier,
|
||||
void* ptr) {
|
||||
this->m_alloc.deallocate(identifier,ptr);
|
||||
}
|
||||
@ -77,8 +77,8 @@ class TestAllocator: public Fw::MemAllocator {
|
||||
|
||||
private:
|
||||
Fw::MallocAllocator m_alloc;
|
||||
NATIVE_UINT_TYPE m_reqId;
|
||||
NATIVE_UINT_TYPE m_reqSize;
|
||||
FwEnumStoreType m_reqId;
|
||||
FwSizeType m_reqSize;
|
||||
void* m_mem;
|
||||
|
||||
};
|
||||
|
||||
@ -56,9 +56,9 @@ namespace Svc {
|
||||
|
||||
void CmdSequencerComponentImpl ::
|
||||
allocateBuffer(
|
||||
const NATIVE_INT_TYPE identifier,
|
||||
const FwEnumStoreType identifier,
|
||||
Fw::MemAllocator& allocator,
|
||||
const NATIVE_UINT_TYPE bytes
|
||||
const FwSizeType bytes
|
||||
)
|
||||
{
|
||||
this->m_sequence->allocateBuffer(identifier, allocator, bytes);
|
||||
|
||||
@ -217,9 +217,9 @@ namespace Svc {
|
||||
|
||||
//! Give the sequence representation a memory buffer
|
||||
void allocateBuffer(
|
||||
NATIVE_INT_TYPE identifier, //!< The identifier
|
||||
FwEnumStoreType identifier, //!< The identifier
|
||||
Fw::MemAllocator& allocator, //!< The allocator
|
||||
NATIVE_UINT_TYPE bytes //!< The number of bytes
|
||||
FwSizeType bytes //!< The number of bytes
|
||||
);
|
||||
|
||||
//! Deallocate the buffer
|
||||
@ -291,7 +291,7 @@ namespace Svc {
|
||||
Fw::ExternalSerializeBuffer m_buffer;
|
||||
|
||||
//! The allocator ID
|
||||
NATIVE_INT_TYPE m_allocatorId;
|
||||
FwEnumStoreType m_allocatorId;
|
||||
|
||||
//! The sequence header
|
||||
Header m_header;
|
||||
@ -325,7 +325,7 @@ namespace Svc {
|
||||
//! Update computed CRC
|
||||
void update(
|
||||
const BYTE* buffer, //!< The buffer
|
||||
NATIVE_UINT_TYPE bufferSize //!< The buffer size
|
||||
FwSizeType bufferSize //!< The buffer size
|
||||
);
|
||||
|
||||
//! Finalize computed CRC
|
||||
@ -544,9 +544,9 @@ namespace Svc {
|
||||
//! Call this after constructor and init, and after setting
|
||||
//! the sequence format, but before task is spawned.
|
||||
void allocateBuffer(
|
||||
const NATIVE_INT_TYPE identifier, //!< The identifier
|
||||
const FwEnumStoreType identifier, //!< The identifier
|
||||
Fw::MemAllocator& allocator, //!< The allocator
|
||||
const NATIVE_UINT_TYPE bytes //!< The number of bytes
|
||||
const FwSizeType bytes //!< The number of bytes
|
||||
);
|
||||
|
||||
//! (Optional) Load a sequence to run later.
|
||||
|
||||
@ -31,10 +31,10 @@ namespace Svc {
|
||||
}
|
||||
|
||||
void CmdSequencerComponentImpl::FPrimeSequence::CRC ::
|
||||
update(const BYTE* buffer, NATIVE_UINT_TYPE bufferSize)
|
||||
update(const BYTE* buffer, FwSizeType bufferSize)
|
||||
{
|
||||
FW_ASSERT(buffer);
|
||||
for(NATIVE_UINT_TYPE index = 0; index < bufferSize; index++) {
|
||||
for(FwSizeType index = 0; index < bufferSize; index++) {
|
||||
this->m_computed = static_cast<U32>(update_crc_32(this->m_computed, static_cast<char>(buffer[index])));
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ namespace Svc {
|
||||
and this->extractCRC();
|
||||
}
|
||||
if (status) {
|
||||
const NATIVE_UINT_TYPE buffLen = this->m_buffer.getBuffLength();
|
||||
const FwSizeType buffLen = this->m_buffer.getBuffLength();
|
||||
this->m_crc.update(buffAddr, buffLen);
|
||||
this->m_crc.finalize();
|
||||
}
|
||||
@ -166,9 +166,9 @@ namespace Svc {
|
||||
FwSignedSizeType readLen = Sequence::Header::SERIALIZED_SIZE;
|
||||
FW_ASSERT(readLen >= 0, static_cast<FwAssertArgType>(readLen));
|
||||
|
||||
const NATIVE_UINT_TYPE capacity = buffer.getBuffCapacity();
|
||||
const FwSizeType capacity = buffer.getBuffCapacity();
|
||||
FW_ASSERT(
|
||||
capacity >= static_cast<NATIVE_UINT_TYPE>(readLen),
|
||||
capacity >= static_cast<FwSizeType>(readLen),
|
||||
static_cast<FwAssertArgType>(capacity),
|
||||
static_cast<FwAssertArgType>(readLen)
|
||||
);
|
||||
@ -260,10 +260,10 @@ namespace Svc {
|
||||
readRecordsAndCRC()
|
||||
{
|
||||
Os::File& file = this->m_sequenceFile;
|
||||
const NATIVE_UINT_TYPE size = this->m_header.m_fileSize;
|
||||
const FwSizeType size = this->m_header.m_fileSize;
|
||||
Fw::SerializeBufferBase& buffer = this->m_buffer;
|
||||
|
||||
FwSignedSizeType readLen = size;
|
||||
FwSignedSizeType readLen = static_cast<FwSignedSizeType>(size);
|
||||
Os::File::Status fileStatus = file.read(
|
||||
buffer.getBuffAddr(),
|
||||
readLen
|
||||
@ -277,7 +277,7 @@ namespace Svc {
|
||||
return false;
|
||||
}
|
||||
// check read size
|
||||
if (static_cast<NATIVE_INT_TYPE>(size) != readLen) {
|
||||
if (size != static_cast<FwSizeType>(readLen)) {
|
||||
this->m_events.fileInvalid(
|
||||
CmdSequencer_FileReadStage::READ_SEQ_DATA_SIZE,
|
||||
static_cast<I32>(readLen)
|
||||
@ -298,8 +298,8 @@ namespace Svc {
|
||||
U32& crc = this->m_crc.m_stored;
|
||||
|
||||
// Compute the data size
|
||||
const U32 buffSize = buffer.getBuffLength();
|
||||
const U32 crcSize = sizeof(crc);
|
||||
const FwSizeType buffSize = buffer.getBuffLength();
|
||||
const FwSizeType crcSize = sizeof(crc);
|
||||
U8 *const buffAddr = buffer.getBuffAddr();
|
||||
if (buffSize < crcSize) {
|
||||
this->m_events.fileInvalid(
|
||||
@ -309,7 +309,7 @@ namespace Svc {
|
||||
return false;
|
||||
}
|
||||
FW_ASSERT(buffSize >= crcSize, static_cast<FwAssertArgType>(buffSize), crcSize);
|
||||
const NATIVE_UINT_TYPE dataSize = buffSize - crcSize;
|
||||
const FwSizeType dataSize = buffSize - crcSize;
|
||||
// Create a CRC buffer pointing at the CRC in the main buffer, after the data
|
||||
Fw::ExternalSerializeBuffer crcBuff(&buffAddr[dataSize], crcSize);
|
||||
Fw::SerializeStatus status = crcBuff.setBuffLen(crcSize);
|
||||
@ -409,7 +409,7 @@ namespace Svc {
|
||||
{
|
||||
Fw::SerializeBufferBase& buffer = this->m_buffer;
|
||||
comBuffer.resetSer();
|
||||
NATIVE_UINT_TYPE size = recordSize;
|
||||
FwSizeType size = recordSize;
|
||||
Fw::SerializeStatus status = comBuffer.setBuffLen(recordSize);
|
||||
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
|
||||
status = buffer.deserialize(comBuffer.getBuffAddr(), size, true);
|
||||
@ -430,7 +430,7 @@ namespace Svc {
|
||||
}
|
||||
|
||||
// Deserialize all records
|
||||
for (NATIVE_UINT_TYPE recordNumber = 0; recordNumber < numRecords; recordNumber++) {
|
||||
for (U32 recordNumber = 0; recordNumber < numRecords; recordNumber++) {
|
||||
Fw::SerializeStatus status = this->deserializeRecord(record);
|
||||
if (status != Fw::FW_SERIALIZE_OK) {
|
||||
this->m_events.recordInvalid(recordNumber, status);
|
||||
@ -438,9 +438,9 @@ namespace Svc {
|
||||
}
|
||||
}
|
||||
// Check there is no data left
|
||||
const U32 buffLeftSize = buffer.getBuffLeft();
|
||||
const FwSizeType buffLeftSize = buffer.getBuffLeft();
|
||||
if (buffLeftSize > 0) {
|
||||
this->m_events.recordMismatch(numRecords, buffLeftSize);
|
||||
this->m_events.recordMismatch(numRecords, static_cast<U32>(buffLeftSize));
|
||||
return false;
|
||||
}
|
||||
// Rewind deserialization
|
||||
|
||||
@ -75,9 +75,9 @@ namespace Svc {
|
||||
|
||||
void CmdSequencerComponentImpl::Sequence ::
|
||||
allocateBuffer(
|
||||
NATIVE_INT_TYPE identifier,
|
||||
FwEnumStoreType identifier,
|
||||
Fw::MemAllocator& allocator,
|
||||
NATIVE_UINT_TYPE bytes
|
||||
FwSizeType bytes
|
||||
)
|
||||
{
|
||||
// has to be at least as big as a header
|
||||
@ -85,7 +85,7 @@ namespace Svc {
|
||||
bool recoverable;
|
||||
this->m_allocatorId = identifier;
|
||||
this->m_buffer.setExtBuffer(
|
||||
static_cast<U8*>(allocator.allocate(static_cast<NATIVE_UINT_TYPE>(identifier),bytes,recoverable)),
|
||||
static_cast<U8*>(allocator.allocate(identifier,bytes,recoverable)),
|
||||
bytes
|
||||
);
|
||||
}
|
||||
@ -94,7 +94,7 @@ namespace Svc {
|
||||
deallocateBuffer(Fw::MemAllocator& allocator)
|
||||
{
|
||||
allocator.deallocate(
|
||||
static_cast<NATIVE_UINT_TYPE>(this->m_allocatorId),
|
||||
this->m_allocatorId,
|
||||
this->m_buffer.getBuffAddr()
|
||||
);
|
||||
this->m_buffer.clear();
|
||||
|
||||
@ -148,7 +148,7 @@ namespace Svc {
|
||||
Sequence::Record record;
|
||||
|
||||
// Deserialize all records and count the records
|
||||
const NATIVE_UINT_TYPE loopBound = buffer.getBuffLeft();
|
||||
const U32 loopBound = static_cast<U32>(buffer.getBuffLeft());
|
||||
U32 numRecords = 0;
|
||||
for ( ; numRecords < loopBound; ++numRecords) {
|
||||
if (not this->hasMoreRecords()) {
|
||||
@ -254,7 +254,7 @@ namespace Svc {
|
||||
}
|
||||
if (status) {
|
||||
U8 *const buffAddr = this->m_buffer.getBuffAddr();
|
||||
const NATIVE_UINT_TYPE buffLen = this->m_buffer.getBuffLength();
|
||||
const FwSizeType buffLen = this->m_buffer.getBuffLength();
|
||||
FW_ASSERT(
|
||||
buffLen == this->m_header.m_fileSize,
|
||||
static_cast<FwAssertArgType>(buffLen),
|
||||
@ -305,17 +305,17 @@ namespace Svc {
|
||||
readRecords()
|
||||
{
|
||||
Os::File& file = this->m_sequenceFile;
|
||||
const NATIVE_UINT_TYPE size = this->m_header.m_fileSize;
|
||||
const FwSizeType size = this->m_header.m_fileSize;
|
||||
Fw::SerializeBufferBase& buffer = this->m_buffer;
|
||||
U8 *const addr = buffer.getBuffAddr();
|
||||
|
||||
// Check file size
|
||||
if (size > this->m_buffer.getBuffCapacity()) {
|
||||
this->m_events.fileSizeError(size);
|
||||
this->m_events.fileSizeError(static_cast<U32>(size));
|
||||
return false;
|
||||
}
|
||||
|
||||
FwSignedSizeType readLen = size;
|
||||
FwSignedSizeType readLen = static_cast<FwSignedSizeType>(size);
|
||||
const Os::File::Status fileStatus = file.read(addr, readLen);
|
||||
// Check read status
|
||||
if (fileStatus != Os::File::OP_OK) {
|
||||
@ -326,7 +326,7 @@ namespace Svc {
|
||||
return false;
|
||||
}
|
||||
// Check read size
|
||||
const NATIVE_UINT_TYPE readLenUint = static_cast<NATIVE_UINT_TYPE>(readLen);
|
||||
const FwSizeType readLenUint = static_cast<FwSizeType>(readLen);
|
||||
if (readLenUint != size) {
|
||||
this->m_events.fileInvalid(
|
||||
CmdSequencer_FileReadStage::READ_SEQ_DATA_SIZE,
|
||||
@ -433,7 +433,7 @@ namespace Svc {
|
||||
status = comBuffer.serialize(zeros);
|
||||
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
|
||||
// Set the buffer length
|
||||
const U32 fixedBuffLen = comBuffer.getBuffLength();
|
||||
const U32 fixedBuffLen = static_cast<U32>(comBuffer.getBuffLength());
|
||||
FW_ASSERT(
|
||||
fixedBuffLen == sizeof(cmdDescriptor) + sizeof(zeros),
|
||||
static_cast<FwAssertArgType>(fixedBuffLen)
|
||||
@ -442,7 +442,7 @@ namespace Svc {
|
||||
status = comBuffer.setBuffLen(totalBuffLen);
|
||||
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
|
||||
// Copy the opcode and argument bytes
|
||||
NATIVE_UINT_TYPE size = cmdLength;
|
||||
FwSizeType size = cmdLength;
|
||||
U8 *const addr = comBuffer.getBuffAddr();
|
||||
FW_ASSERT(addr != nullptr);
|
||||
// true means "don't serialize the length"
|
||||
|
||||
@ -19,7 +19,7 @@ namespace Svc {
|
||||
|
||||
namespace Buffers {
|
||||
|
||||
NATIVE_UINT_TYPE FileBuffer ::
|
||||
FwSizeType FileBuffer ::
|
||||
getBuffCapacity() const
|
||||
{
|
||||
return sizeof(m_buff);
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Svc {
|
||||
|
||||
public:
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const;
|
||||
FwSizeType getBuffCapacity() const;
|
||||
|
||||
U8* getBuffAddr();
|
||||
|
||||
|
||||
@ -102,11 +102,11 @@ namespace Svc {
|
||||
FW_ASSERT(portNum == 0);
|
||||
|
||||
// Get length of buffer:
|
||||
U32 size32 = data.getBuffLength();
|
||||
FwSizeType sizeNative = data.getBuffLength();
|
||||
// ComLogger only writes 16-bit sizes to save space
|
||||
// on disk:
|
||||
FW_ASSERT(size32 < 65536, static_cast<FwAssertArgType>(size32));
|
||||
U16 size = size32 & 0xFFFF;
|
||||
FW_ASSERT(sizeNative < 65536, static_cast<FwAssertArgType>(sizeNative));
|
||||
U16 size = sizeNative & 0xFFFF;
|
||||
|
||||
// Close the file if it will be too big:
|
||||
if( OPEN == this->m_fileMode ) {
|
||||
@ -223,7 +223,7 @@ namespace Svc {
|
||||
serialLength.serialize(size);
|
||||
if(this->writeToFile(serialLength.getBuffAddr(),
|
||||
static_cast<U16>(serialLength.getBuffLength()))) {
|
||||
this->m_byteCount += serialLength.getBuffLength();
|
||||
this->m_byteCount += static_cast<U32>(serialLength.getBuffLength());
|
||||
}
|
||||
else {
|
||||
return;
|
||||
|
||||
@ -24,7 +24,7 @@ ComQueue ::QueueConfigurationTable ::QueueConfigurationTable() {
|
||||
ComQueue ::ComQueue(const char* const compName)
|
||||
: ComQueueComponentBase(compName),
|
||||
m_state(WAITING),
|
||||
m_allocationId(static_cast<NATIVE_UINT_TYPE>(-1)),
|
||||
m_allocationId(static_cast<FwEnumStoreType>(-1)),
|
||||
m_allocator(nullptr),
|
||||
m_allocation(nullptr) {
|
||||
// Initialize throttles to "off"
|
||||
@ -43,10 +43,10 @@ void ComQueue ::cleanup() {
|
||||
}
|
||||
|
||||
void ComQueue::configure(QueueConfigurationTable queueConfig,
|
||||
NATIVE_UINT_TYPE allocationId,
|
||||
FwEnumStoreType allocationId,
|
||||
Fw::MemAllocator& allocator) {
|
||||
FwIndexType currentPriorityIndex = 0;
|
||||
NATIVE_UINT_TYPE totalAllocation = 0;
|
||||
FwSizeType totalAllocation = 0;
|
||||
|
||||
// Store/initialize allocator members
|
||||
this->m_allocator = &allocator;
|
||||
@ -167,7 +167,7 @@ void ComQueue::run_handler(const FwIndexType portNum, U32 context) {
|
||||
// Downlink the high-water marks for the Fw::ComBuffer array types
|
||||
ComQueueDepth comQueueDepth;
|
||||
for (U32 i = 0; i < comQueueDepth.SIZE; i++) {
|
||||
comQueueDepth[i] = this->m_queues[i].get_high_water_mark();
|
||||
comQueueDepth[i] = static_cast<U32>(this->m_queues[i].get_high_water_mark());
|
||||
this->m_queues[i].clear_high_water_mark();
|
||||
}
|
||||
this->tlmWrite_comQueueDepth(comQueueDepth);
|
||||
@ -175,7 +175,7 @@ void ComQueue::run_handler(const FwIndexType portNum, U32 context) {
|
||||
// Downlink the high-water marks for the Fw::Buffer array types
|
||||
BuffQueueDepth buffQueueDepth;
|
||||
for (U32 i = 0; i < buffQueueDepth.SIZE; i++) {
|
||||
buffQueueDepth[i] = this->m_queues[i + COM_PORT_COUNT].get_high_water_mark();
|
||||
buffQueueDepth[i] = static_cast<U32>(this->m_queues[i + COM_PORT_COUNT].get_high_water_mark());
|
||||
this->m_queues[i + COM_PORT_COUNT].clear_high_water_mark();
|
||||
}
|
||||
this->tlmWrite_buffQueueDepth(buffQueueDepth);
|
||||
|
||||
@ -111,7 +111,7 @@ class ComQueue final : public ComQueueComponentBase {
|
||||
//! Takes in the queue depth and priority per-port in order from Fw::Com through Fw::Buffer ports. Calculates the
|
||||
//! queue metadata stored `m_prioritizedList` and then sorts that list by priority.
|
||||
void configure(QueueConfigurationTable queueConfig, //!< Table of the configuration properties for the component
|
||||
NATIVE_UINT_TYPE allocationId, //!< Identifier used when dealing with the Fw::MemAllocator
|
||||
FwEnumStoreType allocationId, //!< Identifier used when dealing with the Fw::MemAllocator
|
||||
Fw::MemAllocator& allocator //!< Fw::MemAllocator used to acquire memory
|
||||
);
|
||||
|
||||
@ -192,7 +192,7 @@ class ComQueue final : public ComQueueComponentBase {
|
||||
SendState m_state; //!< State of the component
|
||||
|
||||
// Storage for Fw::MemAllocator properties
|
||||
NATIVE_UINT_TYPE m_allocationId; //!< Component's allocation ID
|
||||
FwEnumStoreType m_allocationId; //!< Component's allocation ID
|
||||
Fw::MemAllocator* m_allocator; //!< Pointer to Fw::MemAllocator instance for deallocation
|
||||
void* m_allocation; //!< Pointer to allocated memory
|
||||
};
|
||||
|
||||
@ -123,7 +123,7 @@ void Deframer ::route(Fw::Buffer& packetBuffer) {
|
||||
// Process the packet
|
||||
if (status == Fw::FW_SERIALIZE_OK) {
|
||||
U8 *const packetData = packetBuffer.getData();
|
||||
const U32 packetSize = packetBuffer.getSize();
|
||||
const FwSizeType packetSize = packetBuffer.getSize();
|
||||
switch (packetType) {
|
||||
// Handle a command packet
|
||||
case Fw::ComPacket::FW_PACKET_COMMAND: {
|
||||
@ -148,6 +148,8 @@ void Deframer ::route(Fw::Buffer& packetBuffer) {
|
||||
// If the file uplink output port is connected,
|
||||
// send the file packet. Otherwise take no action.
|
||||
if (isConnected_bufferOut_OutputPort(0)) {
|
||||
FW_ASSERT((packetSize - sizeof(packetType)) < std::numeric_limits<U32>::max(),
|
||||
static_cast<FwAssertArgType>(packetSize - sizeof(packetType)));
|
||||
// Shift the packet buffer to skip the packet type
|
||||
// The FileUplink component does not expect the packet
|
||||
// type to be there.
|
||||
@ -185,22 +187,22 @@ void Deframer ::route(Fw::Buffer& packetBuffer) {
|
||||
|
||||
void Deframer ::processBuffer(Fw::Buffer& buffer) {
|
||||
|
||||
const U32 bufferSize = buffer.getSize();
|
||||
const FwSizeType bufferSize = buffer.getSize();
|
||||
U8 *const bufferData = buffer.getData();
|
||||
// Current offset into buffer
|
||||
U32 offset = 0;
|
||||
FwSizeType offset = 0;
|
||||
// Remaining data in buffer
|
||||
U32 remaining = bufferSize;
|
||||
FwSizeType remaining = bufferSize;
|
||||
|
||||
for (U32 i = 0; i < bufferSize; ++i) {
|
||||
for (FwSizeType i = 0; i < bufferSize; ++i) {
|
||||
// If there is no data left, exit the loop
|
||||
if (remaining == 0) {
|
||||
break;
|
||||
}
|
||||
// Compute the size of data to serialize
|
||||
const NATIVE_UINT_TYPE ringFreeSize = m_inRing.get_free_size();
|
||||
const NATIVE_UINT_TYPE serSize = (ringFreeSize <= remaining) ?
|
||||
ringFreeSize : static_cast<NATIVE_UINT_TYPE>(remaining);
|
||||
const FwSizeType ringFreeSize = m_inRing.get_free_size();
|
||||
const FwSizeType serSize = (ringFreeSize <= remaining) ?
|
||||
ringFreeSize : static_cast<FwSizeType>(remaining);
|
||||
// Serialize data into the ring buffer
|
||||
const Fw::SerializeStatus status =
|
||||
m_inRing.serialize(&bufferData[offset], serSize);
|
||||
@ -229,15 +231,15 @@ void Deframer ::processRing() {
|
||||
FW_ASSERT(m_protocol != nullptr);
|
||||
|
||||
// The number of remaining bytes in the ring buffer
|
||||
U32 remaining = 0;
|
||||
FwSizeType remaining = 0;
|
||||
// The protocol status
|
||||
DeframingProtocol::DeframingStatus status =
|
||||
DeframingProtocol::DEFRAMING_STATUS_SUCCESS;
|
||||
// The ring buffer capacity
|
||||
const NATIVE_UINT_TYPE ringCapacity = m_inRing.get_capacity();
|
||||
const FwSizeType ringCapacity = m_inRing.get_capacity();
|
||||
|
||||
// Process the ring buffer looking for at least the header
|
||||
for (U32 i = 0; i < ringCapacity; i++) {
|
||||
for (FwSizeType i = 0; i < ringCapacity; i++) {
|
||||
// Get the number of bytes remaining in the ring buffer
|
||||
remaining = m_inRing.get_allocated_size();
|
||||
// If there are none, we are done
|
||||
|
||||
@ -55,7 +55,7 @@ namespace Svc {
|
||||
Fw::FileNameString directories[DP_MAX_DIRECTORIES],
|
||||
FwSizeType numDirs,
|
||||
Fw::FileNameString& stateFile,
|
||||
NATIVE_UINT_TYPE memId,
|
||||
FwEnumStoreType memId,
|
||||
Fw::MemAllocator& allocator
|
||||
) {
|
||||
|
||||
@ -302,7 +302,10 @@ namespace Svc {
|
||||
// Should always fit
|
||||
FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat,serStat);
|
||||
// write the entry
|
||||
FwSignedSizeType size = entryBuffer.getBuffLength();
|
||||
FwSizeType unsignedSize = entryBuffer.getBuffLength();
|
||||
// Protect against overflow
|
||||
FW_ASSERT(unsignedSize < std::numeric_limits<FwSignedSizeType>::max(), static_cast<FwAssertArgType>(unsignedSize));
|
||||
FwSignedSizeType size = static_cast<FwSignedSizeType>(unsignedSize);
|
||||
stat = stateFile.write(buffer, size);
|
||||
if (stat != Os::File::OP_OK) {
|
||||
this->log_WARNING_HI_StateFileWriteError(this->m_stateFile, stat);
|
||||
@ -348,7 +351,10 @@ namespace Svc {
|
||||
// should fit
|
||||
FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK,serStat);
|
||||
// write the entry
|
||||
FwSignedSizeType size = entryBuffer.getBuffLength();
|
||||
FwSizeType unsignedSize = entryBuffer.getBuffLength();
|
||||
// Protect against overflow
|
||||
FW_ASSERT(unsignedSize < std::numeric_limits<FwSignedSizeType>::max(), static_cast<FwAssertArgType>(unsignedSize));
|
||||
FwSignedSizeType size = static_cast<FwSignedSizeType>(unsignedSize);
|
||||
stat = stateFile.write(buffer, size);
|
||||
if (stat != Os::File::OP_OK) {
|
||||
this->log_WARNING_HI_StateFileWriteError(this->m_stateFile, stat);
|
||||
|
||||
@ -49,7 +49,7 @@ namespace Svc {
|
||||
Fw::FileNameString directories[DP_MAX_DIRECTORIES],
|
||||
FwSizeType numDirs,
|
||||
Fw::FileNameString& stateFile,
|
||||
NATIVE_UINT_TYPE memId,
|
||||
FwEnumStoreType memId,
|
||||
Fw::MemAllocator& allocator
|
||||
);
|
||||
|
||||
@ -240,9 +240,9 @@ namespace Svc {
|
||||
DpDstateFileEntry* m_stateFileData; //!< DP state loaded from file
|
||||
FwSizeType m_stateFileEntries; //!< size of state file data
|
||||
|
||||
NATIVE_UINT_TYPE m_memSize; //!< size of allocated buffer
|
||||
FwSizeType m_memSize; //!< size of allocated buffer
|
||||
void* m_memPtr; //!< stored for shutdown
|
||||
NATIVE_UINT_TYPE m_allocatorId; //!< stored for shutdown
|
||||
FwEnumStoreType m_allocatorId; //!< stored for shutdown
|
||||
Fw::MemAllocator* m_allocator; //!< stored for shutdown
|
||||
|
||||
bool m_xmitInProgress; //!< set if DP files are in the process of being sent
|
||||
|
||||
@ -48,7 +48,8 @@ void Framer ::handle_framing(const U8* const data, const U32 size, Fw::ComPacket
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void Framer ::comIn_handler(const FwIndexType portNum, Fw::ComBuffer& data, U32 context) {
|
||||
this->handle_framing(data.getBuffAddr(), data.getBuffLength(), Fw::ComPacket::FW_PACKET_UNKNOWN);
|
||||
FW_ASSERT(data.getBuffLength() < std::numeric_limits<U32>::max(), static_cast<FwAssertArgType>(data.getBuffLength()));
|
||||
this->handle_framing(data.getBuffAddr(), static_cast<U32>(data.getBuffLength()), Fw::ComPacket::FW_PACKET_UNKNOWN);
|
||||
}
|
||||
|
||||
void Framer ::bufferIn_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) {
|
||||
|
||||
@ -50,7 +50,7 @@ void FprimeFraming::frame(const U8* const data, const U32 size, Fw::ComPacket::C
|
||||
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
|
||||
|
||||
// Calculate and add transmission hash
|
||||
Utils::Hash::hash(buffer.getData(), static_cast<NATIVE_INT_TYPE>(total - HASH_DIGEST_LENGTH), hash);
|
||||
Utils::Hash::hash(buffer.getData(), static_cast<FwSizeType>(total - HASH_DIGEST_LENGTH), hash);
|
||||
status = serializer.serialize(hash.getBuffAddr(), HASH_DIGEST_LENGTH, true);
|
||||
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
|
||||
|
||||
|
||||
@ -29,9 +29,9 @@ GenericHubComponentImpl ::GenericHubComponentImpl(const char* const compName) :
|
||||
GenericHubComponentImpl ::~GenericHubComponentImpl() {}
|
||||
|
||||
void GenericHubComponentImpl ::send_data(const HubType type,
|
||||
const NATIVE_INT_TYPE port,
|
||||
const FwIndexType port,
|
||||
const U8* data,
|
||||
const U32 size) {
|
||||
const FwSizeType size) {
|
||||
FW_ASSERT(data != nullptr);
|
||||
Fw::SerializeStatus status;
|
||||
// Buffer to send and a buffer used to write to it
|
||||
@ -44,7 +44,7 @@ void GenericHubComponentImpl ::send_data(const HubType type,
|
||||
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
|
||||
status = serialize.serialize(data, size);
|
||||
FW_ASSERT(status == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(status));
|
||||
outgoing.setSize(serialize.getBuffLength());
|
||||
outgoing.setSize(static_cast<U32>(serialize.getBuffLength()));
|
||||
dataOut_out(0, outgoing);
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ void GenericHubComponentImpl ::LogRecv_handler(const FwIndexType portNum,
|
||||
FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK);
|
||||
status = serializer.serialize(args);
|
||||
FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK);
|
||||
U32 size = serializer.getBuffLength();
|
||||
FwSizeType size = serializer.getBuffLength();
|
||||
this->send_data(HubType::HUB_TYPE_EVENT, portNum, buffer, size);
|
||||
|
||||
}
|
||||
@ -174,7 +174,7 @@ void GenericHubComponentImpl ::TlmRecv_handler(const FwIndexType portNum,
|
||||
FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK);
|
||||
status = serializer.serialize(val);
|
||||
FW_ASSERT(status == Fw::SerializeStatus::FW_SERIALIZE_OK);
|
||||
U32 size = serializer.getBuffLength();
|
||||
FwSizeType size = serializer.getBuffLength();
|
||||
this->send_data(HubType::HUB_TYPE_CHANNEL, portNum, buffer, size);
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ class GenericHubComponentImpl final : public GenericHubComponentBase {
|
||||
HUB_TYPE_MAX
|
||||
};
|
||||
|
||||
const static U32 GENERIC_HUB_DATA_SIZE = 1024;
|
||||
constexpr static FwSizeType GENERIC_HUB_DATA_SIZE = 1024;
|
||||
// ----------------------------------------------------------------------
|
||||
// Construction, initialization, and destruction
|
||||
// ----------------------------------------------------------------------
|
||||
@ -89,7 +89,7 @@ class GenericHubComponentImpl final : public GenericHubComponentBase {
|
||||
);
|
||||
|
||||
// Helpers and members
|
||||
void send_data(const HubType type, const NATIVE_INT_TYPE port, const U8* data, const U32 size);
|
||||
void send_data(const HubType type, const FwIndexType port, const U8* data, const FwSizeType size);
|
||||
};
|
||||
|
||||
} // end namespace Svc
|
||||
|
||||
@ -23,7 +23,7 @@ namespace Svc {
|
||||
class WorkingBuffer : public Fw::SerializeBufferBase {
|
||||
public:
|
||||
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const {
|
||||
FwSizeType getBuffCapacity() const {
|
||||
return sizeof(m_buff);
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ namespace Svc {
|
||||
FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat,static_cast<FwAssertArgType>(serStat));
|
||||
|
||||
// write record size
|
||||
writeSize = buff.getBuffLength();
|
||||
writeSize = static_cast<FwSignedSizeType>(buff.getBuffLength());
|
||||
stat = paramFile.write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
|
||||
if (stat != Os::File::OP_OK) {
|
||||
this->unLock();
|
||||
@ -201,7 +201,7 @@ namespace Svc {
|
||||
FW_ASSERT(Fw::FW_SERIALIZE_OK == serStat,static_cast<FwAssertArgType>(serStat));
|
||||
|
||||
// write parameter ID
|
||||
writeSize = buff.getBuffLength();
|
||||
writeSize = static_cast<FwSignedSizeType>(buff.getBuffLength());
|
||||
stat = paramFile.write(buff.getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
|
||||
if (stat != Os::File::OP_OK) {
|
||||
this->unLock();
|
||||
@ -221,7 +221,7 @@ namespace Svc {
|
||||
|
||||
// write serialized parameter value
|
||||
|
||||
writeSize = this->m_db[entry].val.getBuffLength();
|
||||
writeSize = static_cast<FwSignedSizeType>(this->m_db[entry].val.getBuffLength());
|
||||
stat = paramFile.write(this->m_db[entry].val.getBuffAddr(),writeSize,Os::File::WaitType::WAIT);
|
||||
if (stat != Os::File::OP_OK) {
|
||||
this->unLock();
|
||||
|
||||
@ -34,7 +34,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
Os::File::Status stat;
|
||||
Utils::Hash hash;
|
||||
U32 checksum;
|
||||
FwSignedSizeType int_file_size;
|
||||
FwSignedSizeType bytes_to_read;
|
||||
FwSignedSizeType bytes_to_write;
|
||||
Fw::FileNameString hashFilename;
|
||||
@ -46,8 +45,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
return FAILED_FILE_SIZE;
|
||||
}
|
||||
|
||||
int_file_size = filesize;
|
||||
|
||||
// Open file
|
||||
stat = f.open(fname, Os::File::OPEN_READ);
|
||||
if(stat != Os::File::OP_OK)
|
||||
@ -57,7 +54,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
|
||||
// Read file
|
||||
bytes_to_read = CRC_FILE_READ_BLOCK;
|
||||
blocks = int_file_size / CRC_FILE_READ_BLOCK;
|
||||
blocks = filesize / CRC_FILE_READ_BLOCK;
|
||||
for(i = 0; i < blocks; i++)
|
||||
{
|
||||
stat = f.read(block_data, bytes_to_read);
|
||||
@ -67,10 +64,10 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
return FAILED_FILE_READ;
|
||||
}
|
||||
|
||||
hash.update(block_data, static_cast<NATIVE_INT_TYPE>(bytes_to_read));
|
||||
hash.update(block_data, static_cast<FwSizeType>(bytes_to_read));
|
||||
}
|
||||
|
||||
remaining_bytes = int_file_size % CRC_FILE_READ_BLOCK;
|
||||
remaining_bytes = filesize % CRC_FILE_READ_BLOCK;
|
||||
bytes_to_read = remaining_bytes;
|
||||
if(remaining_bytes > 0)
|
||||
{
|
||||
@ -81,7 +78,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
return FAILED_FILE_READ;
|
||||
}
|
||||
|
||||
hash.update(block_data, static_cast<NATIVE_INT_TYPE>(remaining_bytes));
|
||||
hash.update(block_data, static_cast<FwSizeType>(remaining_bytes));
|
||||
}
|
||||
|
||||
// close file
|
||||
@ -150,7 +147,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
|
||||
FwSignedSizeType i;
|
||||
FwSignedSizeType blocks;
|
||||
PlatformIntType remaining_bytes;
|
||||
FwSignedSizeType remaining_bytes;
|
||||
FwSignedSizeType filesize;
|
||||
Os::File f;
|
||||
Os::FileSystem::Status fs_stat;
|
||||
@ -158,7 +155,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
Utils::Hash hash;
|
||||
U32 checksum;
|
||||
U32 checksum_from_file;
|
||||
FwSignedSizeType int_file_size;
|
||||
FwSignedSizeType bytes_to_read;
|
||||
U8 block_data[CRC_FILE_READ_BLOCK];
|
||||
|
||||
@ -168,12 +164,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
return FAILED_FILE_SIZE;
|
||||
}
|
||||
|
||||
int_file_size = static_cast<NATIVE_INT_TYPE>(filesize);
|
||||
if(static_cast<FwSignedSizeType>(int_file_size) != filesize)
|
||||
{
|
||||
return FAILED_FILE_SIZE_CAST;
|
||||
}
|
||||
|
||||
// Open file
|
||||
stat = f.open(fname, Os::File::OPEN_READ);
|
||||
if(stat != Os::File::OP_OK)
|
||||
@ -193,10 +183,10 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
return FAILED_FILE_READ;
|
||||
}
|
||||
|
||||
hash.update(block_data, static_cast<NATIVE_INT_TYPE>(bytes_to_read));
|
||||
hash.update(block_data, static_cast<FwSizeType>(bytes_to_read));
|
||||
}
|
||||
|
||||
remaining_bytes = static_cast<PlatformIntType>(int_file_size % CRC_FILE_READ_BLOCK);
|
||||
remaining_bytes = filesize % CRC_FILE_READ_BLOCK;
|
||||
bytes_to_read = remaining_bytes;
|
||||
if(remaining_bytes > 0)
|
||||
{
|
||||
@ -207,7 +197,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
return FAILED_FILE_READ;
|
||||
}
|
||||
|
||||
hash.update(block_data, remaining_bytes);
|
||||
hash.update(block_data, static_cast<FwSizeType>(remaining_bytes));
|
||||
}
|
||||
|
||||
// close file
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
namespace Utils {
|
||||
|
||||
static const NATIVE_INT_TYPE CRC_FILE_READ_BLOCK = 2048;
|
||||
static const FwSignedSizeType CRC_FILE_READ_BLOCK = 2048;
|
||||
static const U32 CRC_MAX_FILENAME_SIZE = 128; // TODO use a config variable
|
||||
|
||||
typedef enum
|
||||
|
||||
@ -49,7 +49,7 @@ namespace Utils {
|
||||
//! \param buffer: filled with resulting hash value
|
||||
static void hash(
|
||||
const void *data,
|
||||
const NATIVE_INT_TYPE len,
|
||||
const FwSizeType len,
|
||||
HashBuffer& buffer
|
||||
);
|
||||
|
||||
@ -74,7 +74,7 @@ namespace Utils {
|
||||
//! \param len: length of data to add to hash calculation
|
||||
void update(
|
||||
const void *const data,
|
||||
const NATIVE_INT_TYPE len
|
||||
const FwSizeType len
|
||||
);
|
||||
|
||||
//! Finalize an incremental computation and return the result
|
||||
@ -101,7 +101,7 @@ namespace Utils {
|
||||
|
||||
//! Get the length of the file extension string
|
||||
//!
|
||||
static NATIVE_UINT_TYPE getFileExtensionLength();
|
||||
static FwSizeType getFileExtensionLength();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class HashBuffer : public Fw::SerializeBufferBase {
|
||||
|
||||
//! Construct a HashBuffer object
|
||||
//!
|
||||
HashBuffer(const U8* args, NATIVE_UINT_TYPE size);
|
||||
HashBuffer(const U8* args, FwSizeType size);
|
||||
HashBuffer(const HashBuffer& other);
|
||||
HashBuffer();
|
||||
|
||||
@ -57,7 +57,7 @@ class HashBuffer : public Fw::SerializeBufferBase {
|
||||
|
||||
//! Get the total buffer length of a hash buffer
|
||||
//!
|
||||
NATIVE_UINT_TYPE getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
FwSizeType getBuffCapacity() const; // !< returns capacity, not current size, of buffer
|
||||
|
||||
//! Get a pointer to the buffer within the hash buffer
|
||||
//!
|
||||
|
||||
@ -9,7 +9,7 @@ namespace Utils {
|
||||
|
||||
HashBuffer::HashBuffer() {}
|
||||
|
||||
HashBuffer::HashBuffer(const U8* args, NATIVE_UINT_TYPE size) : Fw::SerializeBufferBase() {
|
||||
HashBuffer::HashBuffer(const U8* args, FwSizeType size) : Fw::SerializeBufferBase() {
|
||||
Fw::SerializeStatus stat = Fw::SerializeBufferBase::setBuff(args, size);
|
||||
FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<FwAssertArgType>(stat));
|
||||
}
|
||||
@ -51,7 +51,7 @@ U8* HashBuffer::getBuffAddr() {
|
||||
return this->m_bufferData;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE HashBuffer::getBuffCapacity() const {
|
||||
FwSizeType HashBuffer::getBuffCapacity() const {
|
||||
return sizeof(this->m_bufferData);
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Utils {
|
||||
extendedName.format("%s%s", baseName.toChar(), HASH_EXTENSION_STRING);
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE Hash ::
|
||||
FwSizeType Hash ::
|
||||
getFileExtensionLength()
|
||||
{
|
||||
// Size of returns the size including the '\0' character.
|
||||
|
||||
@ -26,13 +26,13 @@ namespace Utils {
|
||||
}
|
||||
|
||||
void Hash ::
|
||||
hash(const void *const data, const NATIVE_INT_TYPE len, HashBuffer& buffer)
|
||||
hash(const void *const data, const FwSizeType len, HashBuffer& buffer)
|
||||
{
|
||||
HASH_HANDLE_TYPE local_hash_handle;
|
||||
local_hash_handle = 0xffffffffL;
|
||||
FW_ASSERT(data);
|
||||
char c;
|
||||
for(int index = 0; index < len; index++) {
|
||||
for(FwSizeType index = 0; index < len; index++) {
|
||||
c = static_cast<const char*>(data)[index];
|
||||
local_hash_handle = static_cast<HASH_HANDLE_TYPE>(update_crc_32(local_hash_handle, c));
|
||||
}
|
||||
@ -50,11 +50,11 @@ namespace Utils {
|
||||
}
|
||||
|
||||
void Hash ::
|
||||
update(const void *const data, NATIVE_INT_TYPE len)
|
||||
update(const void *const data, FwSizeType len)
|
||||
{
|
||||
FW_ASSERT(data);
|
||||
char c;
|
||||
for(int index = 0; index < len; index++) {
|
||||
for(FwSizeType index = 0; index < len; index++) {
|
||||
c = static_cast<const char*>(data)[index];
|
||||
this->hash_handle = static_cast<HASH_HANDLE_TYPE>(update_crc_32(this->hash_handle, c));
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ namespace Utils {
|
||||
}
|
||||
|
||||
void Hash ::
|
||||
hash(const void *const data, const NATIVE_INT_TYPE len, HashBuffer& buffer)
|
||||
hash(const void *const data, const FwSizeType len, HashBuffer& buffer)
|
||||
{
|
||||
U8 out[SHA256_DIGEST_LENGTH];
|
||||
U8* ret = SHA256(static_cast<const U8*>(data), len, out);
|
||||
@ -43,7 +43,7 @@ namespace Utils {
|
||||
}
|
||||
|
||||
void Hash ::
|
||||
update(const void *const data, NATIVE_INT_TYPE len)
|
||||
update(const void *const data, FwSizeType len)
|
||||
{
|
||||
int ret = SHA256_Update(&this->hash_handle, static_cast<const U8*>(data), len);
|
||||
FW_ASSERT(ret == 1);
|
||||
|
||||
@ -28,7 +28,7 @@ CircularBuffer :: CircularBuffer() :
|
||||
|
||||
}
|
||||
|
||||
CircularBuffer :: CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size) :
|
||||
CircularBuffer :: CircularBuffer(U8* const buffer, const FwSizeType size) :
|
||||
m_store(nullptr),
|
||||
m_store_size(0),
|
||||
m_head_idx(0),
|
||||
@ -38,7 +38,7 @@ CircularBuffer :: CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size)
|
||||
setup(buffer, size);
|
||||
}
|
||||
|
||||
void CircularBuffer :: setup(U8* const buffer, const NATIVE_UINT_TYPE size) {
|
||||
void CircularBuffer :: setup(U8* const buffer, const FwSizeType size) {
|
||||
FW_ASSERT(size > 0);
|
||||
FW_ASSERT(buffer != nullptr);
|
||||
FW_ASSERT(m_store == nullptr && m_store_size == 0); // Not already setup
|
||||
@ -51,22 +51,22 @@ void CircularBuffer :: setup(U8* const buffer, const NATIVE_UINT_TYPE size) {
|
||||
m_high_water_mark = 0;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE CircularBuffer :: get_allocated_size() const {
|
||||
FwSizeType CircularBuffer :: get_allocated_size() const {
|
||||
return m_allocated_size;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE CircularBuffer :: get_free_size() const {
|
||||
FwSizeType CircularBuffer :: get_free_size() const {
|
||||
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
|
||||
FW_ASSERT(m_allocated_size <= m_store_size, static_cast<FwAssertArgType>(m_allocated_size));
|
||||
return m_store_size - m_allocated_size;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE CircularBuffer :: advance_idx(NATIVE_UINT_TYPE idx, NATIVE_UINT_TYPE amount) const {
|
||||
FwSizeType CircularBuffer :: advance_idx(FwSizeType idx, FwSizeType amount) const {
|
||||
FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
|
||||
return (idx + amount) % m_store_size;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const NATIVE_UINT_TYPE size) {
|
||||
Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const FwSizeType size) {
|
||||
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
|
||||
FW_ASSERT(buffer != nullptr);
|
||||
// Check there is sufficient space
|
||||
@ -74,7 +74,7 @@ Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const NA
|
||||
return Fw::FW_SERIALIZE_NO_ROOM_LEFT;
|
||||
}
|
||||
// Copy in all the supplied data
|
||||
NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, m_allocated_size);
|
||||
FwSizeType idx = advance_idx(m_head_idx, m_allocated_size);
|
||||
for (U32 i = 0; i < size; i++) {
|
||||
FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
|
||||
m_store[idx] = buffer[i];
|
||||
@ -86,34 +86,34 @@ Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const NA
|
||||
return Fw::FW_SERIALIZE_OK;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus CircularBuffer :: peek(char& value, NATIVE_UINT_TYPE offset) const {
|
||||
Fw::SerializeStatus CircularBuffer :: peek(char& value, FwSizeType offset) const {
|
||||
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
|
||||
return peek(reinterpret_cast<U8&>(value), offset);
|
||||
}
|
||||
|
||||
Fw::SerializeStatus CircularBuffer :: peek(U8& value, NATIVE_UINT_TYPE offset) const {
|
||||
Fw::SerializeStatus CircularBuffer :: peek(U8& value, FwSizeType offset) const {
|
||||
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
|
||||
// Check there is sufficient data
|
||||
if ((sizeof(U8) + offset) > m_allocated_size) {
|
||||
return Fw::FW_DESERIALIZE_BUFFER_EMPTY;
|
||||
}
|
||||
const NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, offset);
|
||||
const FwSizeType idx = advance_idx(m_head_idx, offset);
|
||||
FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
|
||||
value = m_store[idx];
|
||||
return Fw::FW_SERIALIZE_OK;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus CircularBuffer :: peek(U32& value, NATIVE_UINT_TYPE offset) const {
|
||||
Fw::SerializeStatus CircularBuffer :: peek(U32& value, FwSizeType offset) const {
|
||||
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
|
||||
// Check there is sufficient data
|
||||
if ((sizeof(U32) + offset) > m_allocated_size) {
|
||||
return Fw::FW_DESERIALIZE_BUFFER_EMPTY;
|
||||
}
|
||||
value = 0;
|
||||
NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, offset);
|
||||
FwSizeType idx = advance_idx(m_head_idx, offset);
|
||||
|
||||
// Deserialize all the bytes from network format
|
||||
for (NATIVE_UINT_TYPE i = 0; i < sizeof(U32); i++) {
|
||||
for (FwSizeType i = 0; i < sizeof(U32); i++) {
|
||||
FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
|
||||
value = (value << 8) | static_cast<U32>(m_store[idx]);
|
||||
idx = advance_idx(idx);
|
||||
@ -121,16 +121,16 @@ Fw::SerializeStatus CircularBuffer :: peek(U32& value, NATIVE_UINT_TYPE offset)
|
||||
return Fw::FW_SERIALIZE_OK;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset) const {
|
||||
Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, FwSizeType size, FwSizeType offset) const {
|
||||
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
|
||||
FW_ASSERT(buffer != nullptr);
|
||||
// Check there is sufficient data
|
||||
if ((size + offset) > m_allocated_size) {
|
||||
return Fw::FW_DESERIALIZE_BUFFER_EMPTY;
|
||||
}
|
||||
NATIVE_UINT_TYPE idx = advance_idx(m_head_idx, offset);
|
||||
FwSizeType idx = advance_idx(m_head_idx, offset);
|
||||
// Deserialize all the bytes from network format
|
||||
for (NATIVE_UINT_TYPE i = 0; i < size; i++) {
|
||||
for (FwSizeType i = 0; i < size; i++) {
|
||||
FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
|
||||
buffer[i] = m_store[idx];
|
||||
idx = advance_idx(idx);
|
||||
@ -138,7 +138,7 @@ Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, NATIVE_UINT_TYPE size, NA
|
||||
return Fw::FW_SERIALIZE_OK;
|
||||
}
|
||||
|
||||
Fw::SerializeStatus CircularBuffer :: rotate(NATIVE_UINT_TYPE amount) {
|
||||
Fw::SerializeStatus CircularBuffer :: rotate(FwSizeType amount) {
|
||||
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
|
||||
// Check there is sufficient data
|
||||
if (amount > m_allocated_size) {
|
||||
@ -149,12 +149,12 @@ Fw::SerializeStatus CircularBuffer :: rotate(NATIVE_UINT_TYPE amount) {
|
||||
return Fw::FW_SERIALIZE_OK;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE CircularBuffer ::get_capacity() const {
|
||||
FwSizeType CircularBuffer ::get_capacity() const {
|
||||
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
|
||||
return m_store_size;
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE CircularBuffer ::get_high_water_mark() const {
|
||||
FwSizeType CircularBuffer ::get_high_water_mark() const {
|
||||
return m_high_water_mark;
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ class CircularBuffer {
|
||||
* \param buffer: supplied buffer used as a data store.
|
||||
* \param size: the of the supplied data store.
|
||||
*/
|
||||
CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size);
|
||||
CircularBuffer(U8* const buffer, const FwSizeType size);
|
||||
|
||||
/**
|
||||
* Wraps the supplied buffer as the new data store. Buffer size is supplied in the 'size' argument. Cannot be
|
||||
@ -53,7 +53,7 @@ class CircularBuffer {
|
||||
* \param buffer: supplied buffer used as a data store.
|
||||
* \param size: the of the supplied data store.
|
||||
*/
|
||||
void setup(U8* const buffer, const NATIVE_UINT_TYPE size);
|
||||
void setup(U8* const buffer, const FwSizeType size);
|
||||
|
||||
/**
|
||||
* Serialize a given buffer into this circular buffer. Will not accept more data than
|
||||
@ -62,7 +62,7 @@ class CircularBuffer {
|
||||
* \param size: size of the supplied buffer.
|
||||
* \return Fw::FW_SERIALIZE_OK on success or something else on error
|
||||
*/
|
||||
Fw::SerializeStatus serialize(const U8* const buffer, const NATIVE_UINT_TYPE size);
|
||||
Fw::SerializeStatus serialize(const U8* const buffer, const FwSizeType size);
|
||||
|
||||
/**
|
||||
* Deserialize data into the given variable without moving the head index
|
||||
@ -70,21 +70,21 @@ class CircularBuffer {
|
||||
* \param offset: offset from head to start peak. Default: 0
|
||||
* \return Fw::FW_SERIALIZE_OK on success or something else on error
|
||||
*/
|
||||
Fw::SerializeStatus peek(char& value, NATIVE_UINT_TYPE offset = 0) const;
|
||||
Fw::SerializeStatus peek(char& value, FwSizeType offset = 0) const;
|
||||
/**
|
||||
* Deserialize data into the given variable without moving the head index
|
||||
* \param value: value to fill
|
||||
* \param offset: offset from head to start peak. Default: 0
|
||||
* \return Fw::FW_SERIALIZE_OK on success or something else on error
|
||||
*/
|
||||
Fw::SerializeStatus peek(U8& value, NATIVE_UINT_TYPE offset = 0) const;
|
||||
Fw::SerializeStatus peek(U8& value, FwSizeType offset = 0) const;
|
||||
/**
|
||||
* Deserialize data into the given variable without moving the head index
|
||||
* \param value: value to fill
|
||||
* \param offset: offset from head to start peak. Default: 0
|
||||
* \return Fw::FW_SERIALIZE_OK on success or something else on error
|
||||
*/
|
||||
Fw::SerializeStatus peek(U32& value, NATIVE_UINT_TYPE offset = 0) const;
|
||||
Fw::SerializeStatus peek(U32& value, FwSizeType offset = 0) const;
|
||||
|
||||
/**
|
||||
* Deserialize data into the given buffer without moving the head variable.
|
||||
@ -93,7 +93,7 @@ class CircularBuffer {
|
||||
* \param offset: offset from head to start peak. Default: 0
|
||||
* \return Fw::FW_SERIALIZE_OK on success or something else on error
|
||||
*/
|
||||
Fw::SerializeStatus peek(U8* buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset = 0) const;
|
||||
Fw::SerializeStatus peek(U8* buffer, FwSizeType size, FwSizeType offset = 0) const;
|
||||
|
||||
/**
|
||||
* Rotate the head index, deleting data from the circular buffer and making
|
||||
@ -101,31 +101,31 @@ class CircularBuffer {
|
||||
* \param amount: amount to rotate by (in bytes)
|
||||
* \return Fw::FW_SERIALIZE_OK on success or something else on error
|
||||
*/
|
||||
Fw::SerializeStatus rotate(NATIVE_UINT_TYPE amount);
|
||||
Fw::SerializeStatus rotate(FwSizeType amount);
|
||||
|
||||
/**
|
||||
* Get the number of bytes allocated in the buffer
|
||||
* \return number of bytes
|
||||
*/
|
||||
NATIVE_UINT_TYPE get_allocated_size() const;
|
||||
FwSizeType get_allocated_size() const;
|
||||
|
||||
/**
|
||||
* Get the number of free bytes, i.e., the number
|
||||
* of bytes that may be stored in the buffer without
|
||||
* deleting data and without exceeding the buffer capacity
|
||||
*/
|
||||
NATIVE_UINT_TYPE get_free_size() const;
|
||||
FwSizeType get_free_size() const;
|
||||
|
||||
/**
|
||||
* Get the logical capacity of the buffer, i.e., the number of available
|
||||
* bytes when the buffer is empty
|
||||
*/
|
||||
NATIVE_UINT_TYPE get_capacity() const;
|
||||
FwSizeType get_capacity() const;
|
||||
|
||||
/**
|
||||
* Return the largest tracked allocated size
|
||||
*/
|
||||
NATIVE_UINT_TYPE get_high_water_mark() const;
|
||||
FwSizeType get_high_water_mark() const;
|
||||
|
||||
/**
|
||||
* Clear tracking of the largest allocated size
|
||||
@ -139,18 +139,18 @@ class CircularBuffer {
|
||||
* \param amount: amount to advance
|
||||
* \return: new index value
|
||||
*/
|
||||
NATIVE_UINT_TYPE advance_idx(NATIVE_UINT_TYPE idx, NATIVE_UINT_TYPE amount = 1) const;
|
||||
FwSizeType advance_idx(FwSizeType idx, FwSizeType amount = 1) const;
|
||||
//! Physical store backing this circular buffer
|
||||
U8* m_store;
|
||||
//! Size of the physical store
|
||||
NATIVE_UINT_TYPE m_store_size;
|
||||
FwSizeType m_store_size;
|
||||
//! Index into m_store of byte zero in the logical store.
|
||||
//! When memory is deallocated, this index moves forward and wraps around.
|
||||
NATIVE_UINT_TYPE m_head_idx;
|
||||
FwSizeType m_head_idx;
|
||||
//! Allocated size (size of the logical store)
|
||||
NATIVE_UINT_TYPE m_allocated_size;
|
||||
FwSizeType m_allocated_size;
|
||||
//! Maximum allocated size
|
||||
NATIVE_UINT_TYPE m_high_water_mark;
|
||||
FwSizeType m_high_water_mark;
|
||||
};
|
||||
} //End Namespace Types
|
||||
#endif
|
||||
|
||||
@ -22,7 +22,7 @@ void Queue::setup(U8* const storage, const FwSizeType storage_size, const FwSize
|
||||
static_cast<FwAssertArgType>(storage_size),
|
||||
static_cast<FwAssertArgType>(depth),
|
||||
static_cast<FwAssertArgType>(message_size));
|
||||
m_internal.setup(storage, static_cast<NATIVE_UINT_TYPE>(total_needed_size));
|
||||
m_internal.setup(storage, total_needed_size);
|
||||
m_message_size = message_size;
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ Fw::SerializeStatus Queue::enqueue(const U8* const message, const FwSizeType siz
|
||||
m_message_size == size,
|
||||
static_cast<FwAssertArgType>(size),
|
||||
static_cast<FwAssertArgType>(m_message_size)); // Message size is as expected
|
||||
return m_internal.serialize(message, static_cast<NATIVE_UINT_TYPE>(m_message_size));
|
||||
return m_internal.serialize(message, m_message_size);
|
||||
}
|
||||
|
||||
Fw::SerializeStatus Queue::dequeue(U8* const message, const FwSizeType size) {
|
||||
@ -41,25 +41,25 @@ Fw::SerializeStatus Queue::dequeue(U8* const message, const FwSizeType size) {
|
||||
m_message_size <= size,
|
||||
static_cast<FwAssertArgType>(size),
|
||||
static_cast<FwAssertArgType>(m_message_size)); // Sufficient storage space for read message
|
||||
Fw::SerializeStatus result = m_internal.peek(message, static_cast<NATIVE_UINT_TYPE>(m_message_size), 0);
|
||||
Fw::SerializeStatus result = m_internal.peek(message, m_message_size, 0);
|
||||
if (result != Fw::FW_SERIALIZE_OK) {
|
||||
return result;
|
||||
}
|
||||
return m_internal.rotate(static_cast<NATIVE_UINT_TYPE>(m_message_size));
|
||||
return m_internal.rotate(m_message_size);
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE Queue::get_high_water_mark() const {
|
||||
FwSizeType Queue::get_high_water_mark() const {
|
||||
FW_ASSERT(m_message_size > 0, static_cast<FwAssertArgType>(m_message_size));
|
||||
return static_cast<NATIVE_UINT_TYPE>(m_internal.get_high_water_mark() / m_message_size);
|
||||
return m_internal.get_high_water_mark() / m_message_size;
|
||||
}
|
||||
|
||||
void Queue::clear_high_water_mark() {
|
||||
m_internal.clear_high_water_mark();
|
||||
}
|
||||
|
||||
NATIVE_UINT_TYPE Queue::getQueueSize() const {
|
||||
FwSizeType Queue::getQueueSize() const {
|
||||
FW_ASSERT(m_message_size > 0, static_cast<FwAssertArgType>(m_message_size));
|
||||
return static_cast<NATIVE_UINT_TYPE>(m_internal.get_allocated_size() / m_message_size);
|
||||
return m_internal.get_allocated_size() / m_message_size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -73,14 +73,14 @@ class Queue {
|
||||
/**
|
||||
* Return the largest tracked allocated size
|
||||
*/
|
||||
NATIVE_UINT_TYPE get_high_water_mark() const;
|
||||
FwSizeType get_high_water_mark() const;
|
||||
|
||||
/**
|
||||
* Clear tracking of the largest allocated size
|
||||
*/
|
||||
void clear_high_water_mark();
|
||||
|
||||
NATIVE_UINT_TYPE getQueueSize() const;
|
||||
FwSizeType getQueueSize() const;
|
||||
|
||||
private:
|
||||
CircularBuffer m_internal;
|
||||
|
||||
@ -43,7 +43,7 @@ The `CircularBuffer` type provides the following operations.
|
||||
### Constructor
|
||||
|
||||
```c++
|
||||
CircularBuffer(U8* const buffer, const NATIVE_UINT_TYPE size)
|
||||
CircularBuffer(U8* const buffer, const FwSizeType size)
|
||||
```
|
||||
|
||||
Construct a circular buffer with the given physical store,
|
||||
@ -52,7 +52,7 @@ specified as a starting pointer and a size in bytes.
|
||||
### Adding Data
|
||||
|
||||
```c++
|
||||
Fw::SerializeStatus serialize(const U8* const buffer, const NATIVE_UINT_TYPE size);
|
||||
Fw::SerializeStatus serialize(const U8* const buffer, const FwSizeType size);
|
||||
```
|
||||
|
||||
If the current logical store size plus `size` exceeds
|
||||
@ -67,7 +67,7 @@ No data is actually serialized (the data is copied byte for byte).
|
||||
### Reading Data
|
||||
|
||||
```c++
|
||||
Fw::SerializeStatus peek(char& value, NATIVE_UINT_TYPE offset = 0) const;
|
||||
Fw::SerializeStatus peek(char& value, FwSizeType offset = 0) const;
|
||||
```
|
||||
|
||||
If `offset` is not a valid address of the logical store,
|
||||
@ -76,13 +76,13 @@ Otherwise read a `char` value at address `offset` of the logical store
|
||||
and store the result into `value`.
|
||||
|
||||
```c++
|
||||
Fw::SerializeStatus peek(U8& value, NATIVE_UINT_TYPE offset = 0) const;
|
||||
Fw::SerializeStatus peek(U8& value, FwSizeType offset = 0) const;
|
||||
```
|
||||
|
||||
Same as previous, but read a `U8` value.
|
||||
|
||||
```c++
|
||||
Fw::SerializeStatus peek(U32& value, NATIVE_UINT_TYPE offset = 0) const;
|
||||
Fw::SerializeStatus peek(U32& value, FwSizeType offset = 0) const;
|
||||
```
|
||||
|
||||
If `offset` through `offset` + 3 are not valid addresses
|
||||
@ -92,7 +92,7 @@ interpret them as an unsigned 32-bit integer in big endian order,
|
||||
and store the result into `value`.
|
||||
|
||||
```c++
|
||||
Fw::SerializeStatus peek(U8* buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset = 0) const;
|
||||
Fw::SerializeStatus peek(U8* buffer, FwSizeType size, FwSizeType offset = 0) const;
|
||||
```
|
||||
|
||||
If `offset` through `offset + size - 1` are not all valid
|
||||
@ -103,7 +103,7 @@ the memory starting at `buffer`.
|
||||
### Deleting Data
|
||||
|
||||
```c++
|
||||
Fw::SerializeStatus rotate(NATIVE_UINT_TYPE amount);
|
||||
Fw::SerializeStatus rotate(FwSizeType amount);
|
||||
```
|
||||
|
||||
If the logical store size _s_ is less than `amount`, then
|
||||
@ -116,7 +116,7 @@ and set the logical store size to _s_ - `amount`.
|
||||
### Querying Buffer State
|
||||
|
||||
```c++
|
||||
NATIVE_UINT_TYPE get_allocated_size() const;
|
||||
FwSizeType get_allocated_size() const;
|
||||
```
|
||||
|
||||
Return the number of allocated bytes, i.e., the
|
||||
@ -125,7 +125,7 @@ This is the maximum number of bytes that may be read from
|
||||
the logical store without adding data.
|
||||
|
||||
```c++
|
||||
NATIVE_UINT_TYPE get_free_size() const;
|
||||
FwSizeType get_free_size() const;
|
||||
```
|
||||
|
||||
Return the number of free bytes, i.e., the
|
||||
@ -134,7 +134,7 @@ This is the number of bytes that may be added to the logical
|
||||
store without deleting data.
|
||||
|
||||
```c++
|
||||
NATIVE_UINT_TYPE get_capacity() const;
|
||||
FwSizeType get_capacity() const;
|
||||
```
|
||||
|
||||
Return the maximum logical store size (equal to the physical store size).
|
||||
|
||||
@ -70,7 +70,7 @@ namespace Types {
|
||||
|
||||
|
||||
bool PeekOkRule::precondition(const MockTypes::CircularState& state) {
|
||||
NATIVE_UINT_TYPE peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
FwSizeType peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
if (state.getPeekType() == 0 ) {
|
||||
return peek_available >= sizeof(I8) + state.getPeekOffset();
|
||||
}
|
||||
@ -120,7 +120,7 @@ namespace Types {
|
||||
ASSERT_TRUE(state.peek(buffer, state.getRandomSize(), state.getPeekOffset()));
|
||||
ASSERT_EQ(state.getTestBuffer().peek(peek_buffer, state.getRandomSize(), state.getPeekOffset()),
|
||||
Fw::FW_SERIALIZE_OK);
|
||||
for (NATIVE_UINT_TYPE i = 0; i < state.getRandomSize(); i++) {
|
||||
for (FwSizeType i = 0; i < state.getRandomSize(); i++) {
|
||||
ASSERT_EQ(buffer[i], peek_buffer[i]);
|
||||
}
|
||||
}
|
||||
@ -135,7 +135,7 @@ namespace Types {
|
||||
|
||||
|
||||
bool PeekBadRule::precondition(const MockTypes::CircularState& state) {
|
||||
NATIVE_UINT_TYPE peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
FwSizeType peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
if (state.getPeekType() == 0 ) {
|
||||
return peek_available < sizeof(I8) + state.getPeekOffset();
|
||||
}
|
||||
@ -181,7 +181,7 @@ namespace Types {
|
||||
|
||||
|
||||
bool RotateOkRule::precondition(const MockTypes::CircularState& state) {
|
||||
NATIVE_UINT_TYPE rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
FwSizeType rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
return rotate_available >= state.getRandomSize();
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ namespace Types {
|
||||
|
||||
|
||||
bool RotateBadRule::precondition(const MockTypes::CircularState& state) {
|
||||
NATIVE_UINT_TYPE rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
FwSizeType rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
return rotate_available < state.getRandomSize();
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user