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) {
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;
}
}
};

View File

@ -1,6 +1,7 @@
#include <framework/timemanager/Clock.h>
#include <framework/serviceinterface/ServiceInterfaceBuffer.h>
#include <cstring>
#include <inttypes.h>
// 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

View File

@ -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<uint8_t *>(&month), reinterpret_cast<uint8_t *>(&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;