aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-05-26 11:28:24 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-05-26 11:28:24 +0200
commitcad919018ed72005d2bc110247087201b0dea7ab (patch)
tree69857b1111fb3e5cb4f5a826985338f39aaec449 /client
parentc3491119759462aeb3eed4b39aa34f6f98ab8a4f (diff)
fix silly typo
Diffstat (limited to 'client')
-rw-r--r--client/cmd.cpp8
-rw-r--r--client/parse.cpp3
-rw-r--r--client/xxd.c8
3 files changed, 9 insertions, 10 deletions
diff --git a/client/cmd.cpp b/client/cmd.cpp
index 78a6c3c..a098a14 100644
--- a/client/cmd.cpp
+++ b/client/cmd.cpp
@@ -5,7 +5,6 @@
#include "cmd.h"
#include "sock.h"
#include "parse.h"
-#include "xxd.h"
char* consume_token(char* input, const char* ifs) {
strtok(input, ifs);
@@ -56,11 +55,8 @@ void cmd_send(char* addr_str) {
return;
}
- printf("char data[%lu = 0x%02lx]:\n", data_size, data_size);
- xxd(data, data_size);
-
- // printf("(0x%02x) -> \"%.*s\"\n", addr, data_size, data);
- // i2c_send(addr, data, data_size);
+ printf("sending char data[%lu = 0x%02lx] to 0x%02x\n", data_size, data_size, addr);
+ i2c_send(addr, data, data_size);
free(data);
}
diff --git a/client/parse.cpp b/client/parse.cpp
index 5672ff2..300df7c 100644
--- a/client/parse.cpp
+++ b/client/parse.cpp
@@ -115,12 +115,15 @@ static int parse_number(const char * str, char * data, size_t * offset) {
unsigned long number = strtol(str + i, NULL, base);
long long mask = (1 << 8 * size) - 1;
number &= mask;
+ // NOTE: the hton? functions are used to convert host endianness to network
+ // endianness (big), and are required
switch (size) {
case 1:
data[*offset] = number & 0xff;
break;
case 2:
number = htons(number);
+ // TODO: check if the endianness is OK, or reverse these *offset indices*
data[*offset + 1] = (number) & 0xff;
data[*offset + 0] = (number >>= 8) & 0xff;
break;
diff --git a/client/xxd.c b/client/xxd.c
index 06b9960..5d83635 100644
--- a/client/xxd.c
+++ b/client/xxd.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <ctype.h>
-#include "parse.h"
+#include "xxd.h"
void xxd(const char * data, size_t size) {
size_t fake_size = size + (16 - size % 16) % 16;
@@ -20,7 +20,7 @@ void xxd(const char * data, size_t size) {
continue;
}
- printf("%02x ", data[size]);
+ printf("%02x ", data[i] & 0xff);
}
// print ascii representation
@@ -33,8 +33,8 @@ void xxd(const char * data, size_t size) {
continue;
}
- if (isprint(data[size]))
- printf("%c", data[size]);
+ if (isprint(data[i]))
+ printf("%c", data[i]);
else
printf(".");
}