fsfw/src/fsfw/globalfunctions/AsciiConverter.h

37 lines
1.4 KiB
C
Raw Normal View History

#ifndef ASCIICONVERTER_H_
#define ASCIICONVERTER_H_
2022-08-16 12:48:22 +02:00
#include "../returnvalues/returnvalue.h"
2022-08-15 20:28:16 +02:00
class AsciiConverter {
2022-02-02 10:29:30 +01:00
public:
static const uint8_t INTERFACE_ID = CLASS_ID::ASCII_CONVERTER;
static const ReturnValue_t TOO_LONG_FOR_TARGET_TYPE = MAKE_RETURN_CODE(1);
static const ReturnValue_t INVALID_CHARACTERS = MAKE_RETURN_CODE(2);
static const ReturnValue_t BUFFER_TOO_SMALL = MAKE_RETURN_CODE(0x3);
2022-02-02 10:29:30 +01:00
template <typename T>
static ReturnValue_t scanAsciiDecimalNumber(const uint8_t **dataPtr, uint8_t len, T *value);
2022-02-02 10:29:30 +01:00
static ReturnValue_t scanAsciiHexByte(const uint8_t **dataPtr, uint8_t *value);
2022-02-02 10:29:30 +01:00
static ReturnValue_t printFloat(uint8_t *buffer, uint32_t bufferLength, float value,
uint8_t decimalPlaces, uint32_t *printedSize);
2022-02-02 10:29:30 +01:00
static ReturnValue_t printInteger(uint8_t *buffer, uint32_t bufferLength, uint32_t value,
uint32_t *printedSize, bool leadingZeros = false);
2022-02-02 10:29:30 +01:00
static ReturnValue_t printSignedInteger(uint8_t *buffer, uint32_t bufferLength, int32_t value,
uint32_t *printedSize);
2022-02-02 10:29:30 +01:00
private:
AsciiConverter();
static ReturnValue_t scanAsciiDecimalNumber_(const uint8_t **dataPtr, uint8_t len, double *value);
2022-02-02 10:29:30 +01:00
static int8_t convertHexChar(const uint8_t *character);
2022-02-02 10:29:30 +01:00
static const uint8_t *clearSpace(const uint8_t *data, uint8_t len);
};
#endif /* ASCIICONVERTER_H_ */