diff --git a/serialize/SerialBufferAdapter2.h b/serialize/SerialBufferAdapter2.h index 59c79dc2..98e2d187 100644 --- a/serialize/SerialBufferAdapter2.h +++ b/serialize/SerialBufferAdapter2.h @@ -131,6 +131,7 @@ private: void determineLengthInBytes(uint8_t typeSize) { switch(typeSize) { + case(1): break; case(2): bufferLength *= 2; break; case(4): @@ -138,7 +139,8 @@ private: case(8): bufferLength *= 8; break; default: - warning << "Invalid type size, assuming regular uint8_t." << std::endl; + error << "Serial Buffer Adapter 2: Invalid type size, assuming regular uint8_t." << std::endl; + error << "Detected type size: " << (int) typeSize << std::endl; } } }; diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index d5ce6056..6798b776 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -1,6 +1,7 @@ #include #include #include +#include // to be implemented by bsp extern "C" void printChar(const char*); @@ -21,18 +22,17 @@ int ServiceInterfaceBuffer::overflow(int c) { return 0; } -// custom stdio.c library for at91sam9g20 chip which does not support unsigned long -// So I cast (unsigned int) on loggerTimes int ServiceInterfaceBuffer::sync(void) { if (this->isActive) { Clock::TimeOfDay_t loggerTime; Clock::getDateAndTime(&loggerTime); char preamble[96] = { 0 }; - sprintf(preamble, "%s: | %u:%02u:%02u.%03u | ", - this->log_message.c_str(), (unsigned int) loggerTime.hour, - (unsigned int) loggerTime.minute, - (unsigned int) loggerTime.second, - (unsigned int) loggerTime.usecond /1000); + sprintf(preamble, "%s: | %" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%03" PRIu32 " | ", + this->log_message.c_str(), + loggerTime.hour, + loggerTime.minute, + loggerTime.second, + loggerTime.usecond /1000); // Write log_message and time this->putChars(preamble, preamble + sizeof(preamble)); // Handle output diff --git a/timemanager/CCSDSTime.cpp b/timemanager/CCSDSTime.cpp index a81f5596..8a123f85 100644 --- a/timemanager/CCSDSTime.cpp +++ b/timemanager/CCSDSTime.cpp @@ -155,8 +155,9 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* if (length < 19) { return RETURN_FAILED; } -// Newlib can't parse uint8 (there is a configure option but I still need to figure out how to make it work..) -#ifdef NEWLIB_NO_C99_IO +// Newlib nano can't parse uint8, see SCNu8 documentation and https://sourceware.org/newlib/README +// Suggestion: use uint16 all the time. This should work on all systems. +#ifdef NEWLIB_NANO_NO_C99_IO uint16_t year; uint16_t month; uint16_t day; @@ -181,8 +182,8 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* &hour, &minute, &second); if (count == 5) { uint8_t tempDay; - ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year,(uint8_t *) &month, - &tempDay); + ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year, + reinterpret_cast(&month), reinterpret_cast(&tempDay)); if (result != RETURN_OK) { return RETURN_FAILED; } @@ -195,6 +196,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* to->usecond = (second - floor(second)) * 1000000; return RETURN_OK; } +// Warning: Compiler/Linker fails ambiguously if library does not implement C99 I/O #else uint16_t year; uint8_t month;