X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=low-can-binding%2Futils%2Fconverter.cpp;fp=low-can-binding%2Futils%2Fconverter.cpp;h=56625742c47a2371fdac2a86b4e4a74fa55d3a38;hb=e8c14d2baa8841f13beefaa1fb662a280ea8eb96;hp=c6c2f5e15acfa1710df878ca8add198044584ab1;hpb=74acfee2361a04f5ea389b31c4defecc30d8fc6b;p=apps%2Fagl-service-can-low-level.git 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 /** - * @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) { @@ -38,6 +38,21 @@ std::string converter_t::to_hex(const uint8_t data[], const size_t length) return stream.str(); } +/** + * @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 *