aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/CMakeLists.txt2
-rw-r--r--client/cmd.cpp22
-rw-r--r--client/i2c.cpp37
3 files changed, 17 insertions, 44 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index d838266..b1cfbaf 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -11,7 +11,7 @@ add_compile_definitions(DEBUG)
project(puzzlebox_client C CXX)
include(../i2ctcp/include.cmake)
-include(../shared/include.cmake)
+include(../shared/pb.cmake)
add_executable(pbc
main.cpp
diff --git a/client/cmd.cpp b/client/cmd.cpp
index 5ac2ff3..e7d42d0 100644
--- a/client/cmd.cpp
+++ b/client/cmd.cpp
@@ -4,12 +4,12 @@
#include <string.h>
#include "cmd.h"
-#include "pb/types.h"
+// #include "pb/types.h"
#include "rl.h"
#include "i2c.h"
#include "parse.h"
-#include "pb/bus.h"
+// #include "pb/bus.h"
char* consume_token(char* input, const char* ifs) {
strtok(input, ifs);
@@ -68,30 +68,12 @@ void cmd_send(char * addr_str) {
}
void cmd_reset(char*) {
- const char msg[] = {
- PB_CMD_WRITE,
- 0x00,
- PB_GS_IDLE,
- };
- i2c_send(BUSADDR_MAIN, msg, sizeof(msg));
}
void cmd_skip(char*) {
- const char msg[] = {
- PB_CMD_WRITE,
- 0x00,
- PB_GS_SOLVED,
- };
- i2c_send(BUSADDR_MAIN, msg, sizeof(msg));
}
void cmd_ls(char*) {
- return;
- const char msg[] = {
- PB_CMD_READ,
- // TODO: which address is this?
- };
- i2c_send(BUSADDR_MAIN, msg, sizeof(msg));
}
extern bool i2c_dump_send;
diff --git a/client/i2c.cpp b/client/i2c.cpp
index ee57e20..951f654 100644
--- a/client/i2c.cpp
+++ b/client/i2c.cpp
@@ -8,7 +8,7 @@
#include "pb/bus.h"
#include "pb/types.h"
-#include "pb/mod/main.h"
+// #include "pb/mod/main.h"
bool i2c_dump_send = false;
bool i2c_dump_recv = true;
@@ -40,28 +40,19 @@ void i2c_recv(uint16_t addr, const char * data, size_t data_size) {
printf("[%s] addr(0x%02x) data(0x%02lx):\n", __FUNCTION__, addr, data_size);
xxd(data, data_size);
}
-
- if (data_size == 0) return;
- enum pb_cmd cmd = (enum pb_cmd) data[0];
- data++; data_size--;
-
- switch (cmd) {
- case PB_CMD_READ: return i2c_handle_cmd_read(addr, data, data_size);
- default: return;
- }
}
-static void i2c_handle_cmd_read(uint16_t i2c_addr, const char * buf, size_t sz) {
- if (sz < 2) return; // require data address + 1 byte of data
- pb_cmd_read_t * cmd = (pb_cmd_read_t *) buf;
- sz--; // sz now represents size of cmd->data
-
- if (i2c_addr == BUSADDR_MAIN && cmd->address == 0x01) {
- if (sz % 2 != 0) return; // invalid data
- for (size_t offset = 0; offset < sz; offset += sizeof(pb_mod_main_mod_t)) {
- pb_mod_main_mod_t * mod = (pb_mod_main_mod_t *) (cmd->data + offset);
- printf("module at addr 0x%02x with state %d\n", mod->addr, mod->state);
- }
- }
-}
+// static void i2c_handle_cmd_read(uint16_t i2c_addr, const char * buf, size_t sz) {
+// if (sz < 2) return; // require data address + 1 byte of data
+// pb_cmd_read_t * cmd = (pb_cmd_read_t *) buf;
+// sz--; // sz now represents size of cmd->data
+//
+// if (i2c_addr == BUSADDR_MAIN && cmd->address == 0x01) {
+// if (sz % 2 != 0) return; // invalid data
+// for (size_t offset = 0; offset < sz; offset += sizeof(pb_mod_main_mod_t)) {
+// pb_mod_main_mod_t * mod = (pb_mod_main_mod_t *) (cmd->data + offset);
+// printf("module at addr 0x%02x with state %d\n", mod->addr, mod->state);
+// }
+// }
+// }