printer improvements and fixes
tc packet stored getter function
This commit is contained in:
parent
e2418d61a6
commit
1aef000eff
@ -1,8 +1,8 @@
|
|||||||
#include <framework/globalfunctions/printer.h>
|
#include <framework/globalfunctions/printer.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
|
||||||
void printer::print(uint8_t *data, size_t size, OutputType type, bool printInfo,
|
void printer::print(const uint8_t *data, size_t size, OutputType type,
|
||||||
size_t maxCharPerLine) {
|
bool printInfo, size_t maxCharPerLine) {
|
||||||
if(printInfo) {
|
if(printInfo) {
|
||||||
sif::info << "Printing data with size " << size << ": ";
|
sif::info << "Printing data with size " << size << ": ";
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ void printer::print(uint8_t *data, size_t size, OutputType type, bool printInfo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printer::printHex(uint8_t *data, size_t size, size_t maxCharPerLine) {
|
void printer::printHex(const uint8_t *data, size_t size, size_t maxCharPerLine) {
|
||||||
sif::info << std::hex;
|
sif::info << std::hex;
|
||||||
for(size_t i = 0; i < size; i++) {
|
for(size_t i = 0; i < size; i++) {
|
||||||
sif::info << "0x" << static_cast<int>(data[i]);
|
sif::info << "0x" << static_cast<int>(data[i]);
|
||||||
@ -31,10 +31,10 @@ void printer::printHex(uint8_t *data, size_t size, size_t maxCharPerLine) {
|
|||||||
sif::info << "]" << std::endl;
|
sif::info << "]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printer::printDec(uint8_t *data, size_t size, size_t maxCharPerLine) {
|
void printer::printDec(const uint8_t *data, size_t size, size_t maxCharPerLine) {
|
||||||
sif::info << std::dec;
|
sif::info << std::dec;
|
||||||
for(size_t i = 0; i < size; i++) {
|
for(size_t i = 0; i < size; i++) {
|
||||||
sif::info << "0x" << static_cast<int>(data[i]);
|
sif::info << static_cast<int>(data[i]);
|
||||||
if(i < size - 1){
|
if(i < size - 1){
|
||||||
sif::info << " , ";
|
sif::info << " , ";
|
||||||
if(i > 0 and i % maxCharPerLine == 0) {
|
if(i > 0 and i % maxCharPerLine == 0) {
|
||||||
|
@ -10,10 +10,10 @@ enum class OutputType {
|
|||||||
HEX
|
HEX
|
||||||
};
|
};
|
||||||
|
|
||||||
void print(uint8_t* data, size_t size, OutputType type = OutputType::HEX,
|
void print(const uint8_t* data, size_t size, OutputType type = OutputType::HEX,
|
||||||
bool printInfo = true, size_t maxCharPerLine = 12);
|
bool printInfo = true, size_t maxCharPerLine = 12);
|
||||||
void printHex(uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
void printHex(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
||||||
void printDec(uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
void printDec(const uint8_t* data, size_t size, size_t maxCharPerLine = 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */
|
#endif /* FRAMEWORK_GLOBALFUNCTIONS_PRINTER_H_ */
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
#include <framework/tmtcpacket/pus/TcPacketStored.h>
|
#include <framework/tmtcpacket/pus/TcPacketStored.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
TcPacketStored::TcPacketStored(store_address_t setAddress) :
|
TcPacketStored::TcPacketStored(store_address_t setAddress) :
|
||||||
@ -20,6 +21,8 @@ TcPacketStored::TcPacketStored(uint8_t service, uint8_t subservice,
|
|||||||
ReturnValue_t returnValue = this->store->getFreeElement(&this->storeAddress,
|
ReturnValue_t returnValue = this->store->getFreeElement(&this->storeAddress,
|
||||||
(TC_PACKET_MIN_SIZE + size), &p_data);
|
(TC_PACKET_MIN_SIZE + size), &p_data);
|
||||||
if (returnValue != this->store->RETURN_OK) {
|
if (returnValue != this->store->RETURN_OK) {
|
||||||
|
sif::warning << "TcPacketStored: Could not get free element from store!"
|
||||||
|
<< std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->setData(p_data);
|
this->setData(p_data);
|
||||||
@ -30,6 +33,15 @@ TcPacketStored::TcPacketStored(uint8_t service, uint8_t subservice,
|
|||||||
this->setErrorControl();
|
this->setErrorControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReturnValue_t TcPacketStored::getData(const uint8_t ** dataPtr,
|
||||||
|
size_t* dataSize) {
|
||||||
|
auto result = this->store->getData(storeAddress, dataPtr, dataSize);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
sif::warning << "TcPacketStored: Could not get data!" << std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
TcPacketStored::TcPacketStored() :
|
TcPacketStored::TcPacketStored() :
|
||||||
TcPacketBase(NULL) {
|
TcPacketBase(NULL) {
|
||||||
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||||
|
@ -74,6 +74,9 @@ public:
|
|||||||
* @param Size size of the packet.
|
* @param Size size of the packet.
|
||||||
*/
|
*/
|
||||||
TcPacketStored( const uint8_t* data, uint32_t size);
|
TcPacketStored( const uint8_t* data, uint32_t size);
|
||||||
|
|
||||||
|
ReturnValue_t getData(const uint8_t ** dataPtr,
|
||||||
|
size_t* dataSize);
|
||||||
/**
|
/**
|
||||||
* This is a getter for the current store address of the packet.
|
* This is a getter for the current store address of the packet.
|
||||||
* @return The current store address. The (raw) value is \c StorageManagerIF::INVALID_ADDRESS if
|
* @return The current store address. The (raw) value is \c StorageManagerIF::INVALID_ADDRESS if
|
||||||
|
Loading…
Reference in New Issue
Block a user