aboutsummaryrefslogtreecommitdiff
path: root/robot/sim.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-27 13:49:35 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-27 13:49:35 +0200
commitdef257fcd9769d3572dbf5bdd076e4ce470fc8ec (patch)
tree4fd442954b5c6ff6319c20da03a28406f1bbf5ad /robot/sim.c
parent4c4d045329c4a149bae0b53952c39c14243e1870 (diff)
remove windows sim compatibility and fix 0xff byte handling
Diffstat (limited to 'robot/sim.c')
-rw-r--r--robot/sim.c35
1 files changed, 3 insertions, 32 deletions
diff --git a/robot/sim.c b/robot/sim.c
index 4efdc4d..6283694 100644
--- a/robot/sim.c
+++ b/robot/sim.c
@@ -3,17 +3,7 @@
#include <string.h>
#include <stdint.h>
#include <unistd.h>
-
-#ifdef W2_HOST_LINUX
#include <termios.h>
-#endif
-
-#ifdef W2_HOST_WIN32
-// garbage os compatibility
-#include <windows.h>
-#include <timeapi.h>
-#define STDIN_FILENO 0
-#endif
#include "sim.h"
#include "../shared/consts.h"
@@ -21,12 +11,7 @@
#include "sercomm.h"
#include "errcatch.h"
-#ifdef W2_HOST_LINUX
struct timespec reference_time; // NOLINT
-#endif
-#ifdef W2_HOST_WIN32
-DWORD reference_time; // NOLINT
-#endif
bool g_w2_sim_headless = false;
static const char* const W2_CMD_NAMES[] = {
@@ -96,16 +81,11 @@ void serial_send(char* message, unsigned int length) {
return;
}
- if (DBG_ENABLE_PRINTFUNC) simprintfunc("serial_send", "<see below>, %u", length);
-
- if (!DBG_ENABLE_SERIAL) return;
- w2_s_bin *bin = w2_bin_s_alloc(length, (uint8_t*) message);
- w2_sim_print_serial(bin);
- free(bin);
+ if (DBG_ENABLE_PRINTFUNC) simprintfunc("serial_send", "<%u byte%s>", length, length == 1 ? "" : "s");
}
void serial_receive_ring(char* buffer, unsigned char size) {
- simprintfunc("serial_receive_ring", PTR_FMT ", %u", (uint64_t) buffer, size);
+ simprintfunc("serial_receive_ring", "0x%016lx, %u", (uint64_t) buffer, size);
}
unsigned char serial_get_received_bytes() {
@@ -118,21 +98,12 @@ void w2_sim_setup(int argc, char **argv) {
g_w2_sim_headless = true;
// disable echo and enable raw mode
-#ifdef W2_HOST_LINUX
struct termios term;
tcgetattr(STDIN_FILENO, &term);
term.c_lflag &= ~(ECHO | ICANON);
term.c_cc[VTIME] = 0;
term.c_cc[VMIN] = 0;
tcsetattr(STDIN_FILENO, 0, &term);
-#endif
-#ifdef W2_HOST_WIN32
- DWORD mode;
- HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
-
- GetConsoleMode(console, &mode);
- SetConsoleMode(console, mode & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT));
-#endif
// debug error
// w2_errcatch_throw(W2_E_WARN_BATTERY_LOW);
@@ -170,7 +141,7 @@ unsigned char get_single_debounced_button_press(unsigned char buttons) {
}
void qtr_read(unsigned int* sensor_values, unsigned char read_mode) {
- simprintfunc("qtr_read", PTR_FMT ", %s", (uint64_t) sensor_values, read_mode == QTR_EMITTERS_ON ? "QTR_EMITTERS_ON" : "???");
+ simprintfunc("qtr_read", "0x%016lx, %s", (uint64_t) sensor_values, read_mode == QTR_EMITTERS_ON ? "QTR_EMITTERS_ON" : "???");
sensor_values[0] = 0;
sensor_values[1] = 0;
sensor_values[2] = 0;