Serial Buffer dapter changes reverted

CCSDS time bugfixes in separate section (for C98)
Serial buffer adapter 2 bugfixes
This commit is contained in:
Robin Müller 2020-01-31 00:54:34 +01:00
parent 09144b18c4
commit 5190e4c16e
3 changed files with 16 additions and 12 deletions

View File

@ -131,6 +131,7 @@ private:
void determineLengthInBytes(uint8_t typeSize) { void determineLengthInBytes(uint8_t typeSize) {
switch(typeSize) { switch(typeSize) {
case(1): break;
case(2): case(2):
bufferLength *= 2; break; bufferLength *= 2; break;
case(4): case(4):
@ -138,7 +139,8 @@ private:
case(8): case(8):
bufferLength *= 8; break; bufferLength *= 8; break;
default: 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;
} }
} }
}; };

View File

@ -1,6 +1,7 @@
#include <framework/timemanager/Clock.h> #include <framework/timemanager/Clock.h>
#include <framework/serviceinterface/ServiceInterfaceBuffer.h> #include <framework/serviceinterface/ServiceInterfaceBuffer.h>
#include <cstring> #include <cstring>
#include <inttypes.h>
// to be implemented by bsp // to be implemented by bsp
extern "C" void printChar(const char*); extern "C" void printChar(const char*);
@ -21,18 +22,17 @@ int ServiceInterfaceBuffer::overflow(int c) {
return 0; 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) { int ServiceInterfaceBuffer::sync(void) {
if (this->isActive) { if (this->isActive) {
Clock::TimeOfDay_t loggerTime; Clock::TimeOfDay_t loggerTime;
Clock::getDateAndTime(&loggerTime); Clock::getDateAndTime(&loggerTime);
char preamble[96] = { 0 }; char preamble[96] = { 0 };
sprintf(preamble, "%s: | %u:%02u:%02u.%03u | ", sprintf(preamble, "%s: | %" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%03" PRIu32 " | ",
this->log_message.c_str(), (unsigned int) loggerTime.hour, this->log_message.c_str(),
(unsigned int) loggerTime.minute, loggerTime.hour,
(unsigned int) loggerTime.second, loggerTime.minute,
(unsigned int) loggerTime.usecond /1000); loggerTime.second,
loggerTime.usecond /1000);
// Write log_message and time // Write log_message and time
this->putChars(preamble, preamble + sizeof(preamble)); this->putChars(preamble, preamble + sizeof(preamble));
// Handle output // Handle output

View File

@ -155,8 +155,9 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
if (length < 19) { if (length < 19) {
return RETURN_FAILED; 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..) // Newlib nano can't parse uint8, see SCNu8 documentation and https://sourceware.org/newlib/README
#ifdef NEWLIB_NO_C99_IO // Suggestion: use uint16 all the time. This should work on all systems.
#ifdef NEWLIB_NANO_NO_C99_IO
uint16_t year; uint16_t year;
uint16_t month; uint16_t month;
uint16_t day; uint16_t day;
@ -181,8 +182,8 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
&hour, &minute, &second); &hour, &minute, &second);
if (count == 5) { if (count == 5) {
uint8_t tempDay; uint8_t tempDay;
ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year,(uint8_t *) &month, ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year,
&tempDay); reinterpret_cast<uint8_t *>(&month), reinterpret_cast<uint8_t *>(&tempDay));
if (result != RETURN_OK) { if (result != RETURN_OK) {
return RETURN_FAILED; return RETURN_FAILED;
} }
@ -195,6 +196,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
to->usecond = (second - floor(second)) * 1000000; to->usecond = (second - floor(second)) * 1000000;
return RETURN_OK; return RETURN_OK;
} }
// Warning: Compiler/Linker fails ambiguously if library does not implement C99 I/O
#else #else
uint16_t year; uint16_t year;
uint8_t month; uint8_t month;