diff --git a/.cache/clangd/index/main.cpp.6C7D4E708A9CF215.idx b/.cache/clangd/index/main.cpp.6C7D4E708A9CF215.idx index dd3f3fe..a967e37 100644 Binary files a/.cache/clangd/index/main.cpp.6C7D4E708A9CF215.idx and b/.cache/clangd/index/main.cpp.6C7D4E708A9CF215.idx differ diff --git a/.cache/clangd/index/p_serial_bus.cpp.ABEC82C874071671.idx b/.cache/clangd/index/p_serial_bus.cpp.ABEC82C874071671.idx index 2f6dc1d..73df55a 100644 Binary files a/.cache/clangd/index/p_serial_bus.cpp.ABEC82C874071671.idx and b/.cache/clangd/index/p_serial_bus.cpp.ABEC82C874071671.idx differ diff --git a/.cache/clangd/index/p_serial_bus.h.48DDA2AACC6854FD.idx b/.cache/clangd/index/p_serial_bus.h.48DDA2AACC6854FD.idx index 23e736a..da31c74 100644 Binary files a/.cache/clangd/index/p_serial_bus.h.48DDA2AACC6854FD.idx and b/.cache/clangd/index/p_serial_bus.h.48DDA2AACC6854FD.idx differ diff --git a/bin/sbm b/bin/sbm index 5c2f543..811c567 100644 Binary files a/bin/sbm and b/bin/sbm differ diff --git a/build/main.o b/build/main.o index 3ce9329..27dd328 100644 Binary files a/build/main.o and b/build/main.o differ diff --git a/build/p_serial_bus.o b/build/p_serial_bus.o index 20387af..5ad4aa1 100644 Binary files a/build/p_serial_bus.o and b/build/p_serial_bus.o differ diff --git a/build/p_serial_packet.o b/build/p_serial_packet.o index a40b500..e21916c 100644 Binary files a/build/p_serial_packet.o and b/build/p_serial_packet.o differ diff --git a/compile_commands.json b/compile_commands.json index 88a123b..52f3b6f 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -17,62 +17,5 @@ ], "directory": "/storage/Shared/Projects/Penguinator/pi_serial_bus_manager", "file": "src/p_serial_bus.cpp" - }, - { - "arguments": [ - "g++", - "-c", - "-Og", - "-Wall", - "-fdata-sections", - "-ffunction-sections", - "-g3", - "-DDEBUG", - "-Icfg", - "-Iinc", - "-o", - "build/p_serial_packet.o", - "src/p_serial_packet.cpp" - ], - "directory": "/storage/Shared/Projects/Penguinator/pi_serial_bus_manager", - "file": "src/p_serial_packet.cpp" - }, - { - "arguments": [ - "g++", - "-c", - "-Og", - "-Wall", - "-fdata-sections", - "-ffunction-sections", - "-g3", - "-DDEBUG", - "-Icfg", - "-Iinc", - "-o", - "build/main.o", - "src/main.cpp" - ], - "directory": "/storage/Shared/Projects/Penguinator/pi_serial_bus_manager", - "file": "src/main.cpp" - }, - { - "arguments": [ - "g++", - "-c", - "-Og", - "-Wall", - "-fdata-sections", - "-ffunction-sections", - "-g3", - "-DDEBUG", - "-Icfg", - "-Iinc", - "-o", - "build/p_idp.o", - "src/p_idp.cpp" - ], - "directory": "/storage/Shared/Projects/Penguinator/pi_serial_bus_manager", - "file": "src/p_idp.cpp" } ] \ No newline at end of file diff --git a/inc/p_serial_packet.h b/inc/p_serial_packet.h index ca0d856..4cad629 100644 --- a/inc/p_serial_packet.h +++ b/inc/p_serial_packet.h @@ -34,7 +34,7 @@ public: static ps_packet from_xy(int x, int y); static ps_packet test_packet(); #ifdef DEBUG - void show_packet(); + void show_packet() const; #endif private: diff --git a/src/p_serial_bus.cpp b/src/p_serial_bus.cpp index 6a6c82c..10a45a7 100644 --- a/src/p_serial_bus.cpp +++ b/src/p_serial_bus.cpp @@ -44,11 +44,6 @@ ps_bus::ps_bus(const char* dev) /* Set this flag if you want to receive data even while sending data */ // rs485conf.flags |= SER_RS485_RX_DURING_TX; - if (ioctl(dev_fd, TIOCSRS485, &rs485conf) < 0) - { - printf("ERROR\n"); - /* Error handling. See errno. */ - } memset(&toptions, 0, sizeof(toptions)); tcgetattr(dev_fd, &toptions); toptions.c_cflag &= ~(CSIZE | PARENB); @@ -69,6 +64,11 @@ ps_bus::ps_bus(const char* dev) tcflush(dev_fd, TCIFLUSH); // apply tcsetattr(dev_fd, TCSANOW, &toptions); + if (ioctl(dev_fd, TIOCSRS485, &rs485conf) < 0) + { + printf("ERROR\n"); + /* Error handling. See errno. */ + } } ps_bus::~ps_bus() @@ -83,10 +83,13 @@ ps_bus::~ps_bus() bool ps_bus::send_pkt(const ps_packet* const pkt) { bool ret = true; + pkt->show_packet(); if (write(dev_fd, pkt->data, pkt->msg_len) != pkt->msg_len) { ret = false; } + tcflush(dev_fd, TCIFLUSH); + usleep(1000); return ret; } bool ps_bus::recv_pkt(ps_packet* const pkt) diff --git a/src/p_serial_packet.cpp b/src/p_serial_packet.cpp index 4a9460b..1a66e3b 100644 --- a/src/p_serial_packet.cpp +++ b/src/p_serial_packet.cpp @@ -144,7 +144,7 @@ ps_packet ps_packet::test_packet() } #ifdef DEBUG -void ps_packet::show_packet() +void ps_packet::show_packet() const { printf("Start Byte:\t\t0x%02x\n", data[0]); printf("Source Address:\t\t0x%02x\n", *src_addr);