From e26ea540e728f5cb9a7e935aea14dd4595f232ea Mon Sep 17 00:00:00 2001 From: empathicqubit Date: Mon, 26 Dec 2022 06:14:16 +0100 Subject: [PATCH] Add command line switch to disable/enable ack handling --- src/common/utils.c | 1 + src/tibridge.c | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/common/utils.c b/src/common/utils.c index e1469c4..e475b7c 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -42,6 +42,7 @@ void utils_parse_args(int argc, char *argv[]) { {0,0,0,0} }; + optind = 0; int opt_index = 0; int opt; while((opt = getopt_long(argc, argv, "L:", long_opts, &opt_index)) != -1) { diff --git a/src/tibridge.c b/src/tibridge.c index e6f17a9..48896da 100644 --- a/src/tibridge.c +++ b/src/tibridge.c @@ -1,12 +1,13 @@ #include #include #include -#include #include #include #include #include #include +#include +#include #include "common/utils.h" @@ -61,12 +62,31 @@ void retry_recv(unsigned char* recv, int recvCount) { int main(int argc, char *argv[]) { int err; + // z88dk-gdb doesn't like the ACKs -/+, so we just hide them + int handle_acks = 1; setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdin, NULL, _IONBF, 0); utils_parse_args(argc, argv); + const struct option long_opts[] = { + {"handle-acks", no_argument, &handle_acks, 1}, + {"no-handle-acks", no_argument, &handle_acks, 0}, + {0,0,0,0} + }; + + optind = 0; + int opt_index = 0; + int opt; + while((opt = getopt_long(argc, argv, "", long_opts, &opt_index)) != -1) { + if(opt == 0 && long_opts[opt_index].flag) { + // Do nothing + } + } + + log(LEVEL_DEBUG, "handle acks: %d\n", handle_acks); + ticables_library_init(); log(LEVEL_INFO, "PROCESS ID: %d\n", getpid()); @@ -77,7 +97,6 @@ int main(int argc, char *argv[]) { return 1; } - // BEGIN DON'T DO THIS FOR TICALCS err = ticables_cable_open(handle); if(err) { log(LEVEL_ERROR, "Could not open cable: %d\n", err); @@ -92,9 +111,7 @@ int main(int argc, char *argv[]) { } log(LEVEL_INFO, "INFO: Model %d, Port:%d, Family %d, Variant %d\n", model, port, info.family, info.variant); - // END DON'T DO THIS FOR TICALCS - bool handle_acks = true; bool handled_first_recv = false; while(true) {