CCSDS time possible bugfix for sscanf()
This commit is contained in:
parent
05c1330b68
commit
ea904642d1
@ -1,5 +1,6 @@
|
|||||||
#include <framework/timemanager/CCSDSTime.h>
|
#include <framework/timemanager/CCSDSTime.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
CCSDSTime::CCSDSTime() {
|
CCSDSTime::CCSDSTime() {
|
||||||
@ -161,8 +162,9 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
|
|||||||
uint8_t minute;
|
uint8_t minute;
|
||||||
float second;
|
float second;
|
||||||
//try Code A (yyyy-mm-dd)
|
//try Code A (yyyy-mm-dd)
|
||||||
int count = sscanf((char *) from, "%4hi-%2hhi-%2hiT%2hhi:%2hhi:%fZ", &year,
|
int count = sscanf((char *) from, "%4" SCNu16 "-%2" SCNu8 "-%2" SCNu16
|
||||||
&month, &day, &hour, &minute, &second);
|
"T%2" SCNu8 ":%2" SCNu8 ":%fZ", &year, &month, &day,
|
||||||
|
&hour, &minute, &second);
|
||||||
if (count == 6) {
|
if (count == 6) {
|
||||||
to->year = year;
|
to->year = year;
|
||||||
to->month = month;
|
to->month = month;
|
||||||
@ -175,8 +177,8 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
|
|||||||
}
|
}
|
||||||
|
|
||||||
//try Code B (yyyy-ddd)
|
//try Code B (yyyy-ddd)
|
||||||
count = sscanf((char *) from, "%4hi-%3hiT%2hhi:%2hhi:%fZ", &year, &day,
|
count = sscanf((char *) from, "%4" SCNu16 "-%3" SCNu16 "T%2" SCNu8
|
||||||
&hour, &minute, &second);
|
":%2" SCNu8 ":%fZ", &year, &day, &hour, &minute, &second);
|
||||||
if (count == 5) {
|
if (count == 5) {
|
||||||
uint8_t tempDay;
|
uint8_t tempDay;
|
||||||
ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year, &month,
|
ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year, &month,
|
||||||
@ -193,7 +195,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UNSUPPORTED_TIME_FORMAT;
|
return UNSUPPORTED_TIME_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user