diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-05-30 14:02:51 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-05-30 14:02:51 +0200 |
commit | d1f5291f82f5e13db756adc919883e310cc537de (patch) | |
tree | a396b8649b4cc71c552ff9bdf0998baf633737b7 /client/sock.cpp | |
parent | 2f443639c159f510b121fb8b3d7ce6aae61b06fb (diff) |
implement message dumping
Diffstat (limited to 'client/sock.cpp')
-rw-r--r-- | client/sock.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/client/sock.cpp b/client/sock.cpp index 2d5787d..f5bd564 100644 --- a/client/sock.cpp +++ b/client/sock.cpp @@ -13,6 +13,7 @@ #include "i2ctcpv1.h" #include "sock.h" #include "rl.h" +#include "xxd.h" using std::logic_error; using std::thread; @@ -105,6 +106,9 @@ void PBSocket::sock_task() { sock_close(); } +bool i2c_dump_send = false; +bool i2c_dump_recv = true; + void i2c_send(uint16_t addr, const char * data, size_t data_size) { i2ctcp_msg_t msg = { .addr = addr, @@ -117,9 +121,16 @@ void i2c_send(uint16_t addr, const char * data, size_t data_size) { if (!i2ctcp_write(&msg, &packed, &size)) return; sock->send(packed, size); + if (i2c_dump_send) { + printf("[i2c send] data(0x%02lx):\n", data_size); + xxd(data, data_size); + } } void i2c_recv(uint16_t addr, const char * data, size_t data_size) { - rl_printf("[0x%02x]: %.*s\n", addr, data_size, data); + if (i2c_dump_recv) { + printf("[i2c recv] data(0x%02lx):\n", data_size); + xxd(data, data_size); + } } |