A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
add methods to parse data to ascii rep
Geo7b503813abc5
diff --git a/src/Transformers/ArgTransformer.cpp b/src/Transformers/ArgTransformer.cppindex 85efc346..43f7eca9 100644--- a/src/Transformers/ArgTransformer.cpp+++ b/src/Transformers/ArgTransformer.cpp@@ -268,4 +268,60 @@ std::string ArgTransformer::formatFloat(double value, int decimals) {char buf[32];snprintf(buf, sizeof(buf), ("%." + std::to_string(decimals) + "f").c_str(), value);return std::string(buf);+}++std::string ArgTransformer::toAsciiLine(uint32_t address, const std::vector<uint8_t>& line) {+ std::stringstream ss;++ // Address+ ss << std::hex << std::uppercase << std::setfill('0')+ << std::setw(6) << address << ": ";++ // Hex+ for (size_t i = 0; i < 16; ++i) {+ if (i < line.size()) {+ ss << std::setw(2) << (int)line[i] << " ";+ } else {+ ss << " ";+ }+ }++ // ASCII+ ss << " ";+ for (size_t i = 0; i < line.size(); ++i) {+ char c = static_cast<char>(line[i]);+ ss << (isprint(c) ? c : '.');+ }++ return ss.str();+}++std::string ArgTransformer::toAsciiLine(uint32_t startAddr, const std::vector<uint16_t>& words) {+ std::stringstream line;++ // Adress+ line << std::hex << std::uppercase << std::setfill('0')+ << std::setw(6) << startAddr << ": ";++ // HEX : 8 x 16-bit (4 hex digits)+ for (size_t i = 0; i < words.size(); ++i) {+ line << std::setw(4) << words[i] << " ";+ }++ // Padding+ for (size_t i = words.size(); i < 8; ++i) {+ line << " ";+ }++ // ASCII+ line << " ";+ for (uint16_t word : words) {+ char high = (word >> 8) & 0xFF;+ char low = word & 0xFF;++ line << (isprint(high) ? high : '.');+ line << (isprint(low) ? low : '.');+ }++ return line.str();}\ No newline at end of filediff --git a/src/Transformers/ArgTransformer.h b/src/Transformers/ArgTransformer.hindex 1c57d1e6..aec9a638 100644--- a/src/Transformers/ArgTransformer.h+++ b/src/Transformers/ArgTransformer.h@@ -30,4 +30,6 @@ public:bool isValidSignedNumber(const std::string& input);std::string toHex(uint32_t value, int width = 2);std::string formatFloat(double value, int decimals);+ std::string toAsciiLine(uint32_t address, const std::vector<uint8_t>& line);+ std::string toAsciiLine(uint32_t startAddr, const std::vector<uint16_t>& words);};