diff options
author | Arthur Guyader <arthur.guyader@iot.bzh> | 2019-12-13 15:23:27 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2020-01-09 16:25:36 +0100 |
commit | e8c14d2baa8841f13beefaa1fb662a280ea8eb96 (patch) | |
tree | a063203c055c957aac8ea60dbe440c90f6d200cd /low-can-binding/utils/converter.cpp | |
parent | 74acfee2361a04f5ea389b31c4defecc30d8fc6b (diff) |
decoder: Add new decoders: ascii, date, time
Change-Id: I392bff2c1f4062aee186875335786fcda9cc0649
Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh>
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'low-can-binding/utils/converter.cpp')
-rw-r--r-- | low-can-binding/utils/converter.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/low-can-binding/utils/converter.cpp b/low-can-binding/utils/converter.cpp index c6c2f5e1..56625742 100644 --- a/low-can-binding/utils/converter.cpp +++ b/low-can-binding/utils/converter.cpp @@ -22,11 +22,11 @@ #include <climits> /** - * @brief Convert hex data to string + * @brief Convert data to hex string * * @param data An array of data * @param length The length of the data - * @return std::string The string data + * @return std::string The hex string */ std::string converter_t::to_hex(const uint8_t data[], const size_t length) { @@ -39,6 +39,21 @@ std::string converter_t::to_hex(const uint8_t data[], const size_t length) } /** + * @brief Convert data to ascii string + * + * @param data An array of data + * @param length The length of the data + * @return std::string The ascii string + */ +std::string converter_t::to_ascii(const uint8_t data[], const size_t length) +{ + std::stringstream stream; + for(int i = 0; i < length; i++) + stream << ((char) data[i]); + return stream.str(); +} + +/** * @brief Translate bit_position and bit_size * * |