Remove unneeded code & includes. On Windows, when performing config dumps, found that packets were being lost but we were not detecting this. Added code to check the sequence numbers of the incoming packets. Additionally, added a check after the loop to ensure that the read did not time out.
Signed-off-by: Scott Talbert <s...@techie.net> --- concordance/concordance.c | 26 -------------------------- libconcord/remote.cpp | 2 -- libconcord/remote_mh.cpp | 12 +++++++++++- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/concordance/concordance.c b/concordance/concordance.c index e3cd32b..3486f44 100644 --- a/concordance/concordance.c +++ b/concordance/concordance.c @@ -32,8 +32,6 @@ #include <conio.h> #include <winsock.h> -HANDLE con; - /* * (see below) Windows does not need this, since _getch already * does what we need - just make set_canon do nothing @@ -152,11 +150,6 @@ void cb_print_percent_status(uint32_t stage_id, uint32_t count, uint32_t curr, uint32_t total, uint32_t counter_type, void *arg, const uint32_t *stages) { - -#ifdef _WIN32 - CONSOLE_SCREEN_BUFFER_INFO sbi; -#endif - if (stage_id == LC_CB_STAGE_NUM_STAGES) { #if _DEBUG printf("Num stages: %d\n", count); @@ -165,16 +158,7 @@ void cb_print_percent_status(uint32_t stage_id, uint32_t count, uint32_t curr, } if (count != 0) { -#ifdef _WIN32 - GetConsoleScreenBufferInfo(con, &sbi); - sbi.dwCursorPosition.X -= 14; - if (sbi.dwCursorPosition.X < 0) { - sbi.dwCursorPosition.X = 0; - } - SetConsoleCursorPosition(con, sbi.dwCursorPosition); -#else printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); -#endif } else { print_stage_name(stage_id); } @@ -937,20 +921,10 @@ int main(int argc, char *argv[]) char *file_name; int mode, file_mode, err; -#ifdef _WIN32 - con=GetStdHandle(STD_OUTPUT_HANDLE); - SetConsoleTextAttribute(con,FOREGROUND_BLUE|FOREGROUND_INTENSITY); -#endif - printf("Concordance %s\n", VERSION); printf("Copyright 2007 Kevin Timmerman and Phil Dibowitz\n"); printf("This software is distributed under the GPLv3.\n\n"); -#ifdef _WIN32 - SetConsoleTextAttribute(con, - FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); -#endif - file_name = NULL; mode = MODE_UNSET; diff --git a/libconcord/remote.cpp b/libconcord/remote.cpp index f531805..c2ec316 100644 --- a/libconcord/remote.cpp +++ b/libconcord/remote.cpp @@ -24,8 +24,6 @@ #include <string.h> #include <errno.h> -#include <iostream> - #include "libconcord.h" #include "lc_internal.h" #include "hid.h" diff --git a/libconcord/remote_mh.cpp b/libconcord/remote_mh.cpp index 6a4162c..88d5b45 100644 --- a/libconcord/remote_mh.cpp +++ b/libconcord/remote_mh.cpp @@ -23,7 +23,6 @@ #include "remote.h" #include <string.h> -#include <iostream> #include <stdlib.h> #include "libconcord.h" @@ -254,11 +253,19 @@ int CRemoteMH::ReadFile(const char *filename, uint8_t *rd, const uint32_t rdlen, debug("msg_ack"); debug_print_packet(rsp); + uint8_t exp_seq = rsp[2] & 0x3F; int pkt_count = 0; *data_read = 0; uint8_t *rd_ptr = rd; while(!(err = HID_ReadReport(rsp, MH_TIMEOUT))) { debug_print_packet(rsp); + get_seq(exp_seq); + uint8_t rcv_seq = rsp[0] & 0x3F; + if (exp_seq != rcv_seq) { + debug("ERROR: unexpected sequence # - packet lost! %02x %02x", + exp_seq, rcv_seq); + return LC_ERROR_READ; + } // Ignore 1st two bits on 2nd byte for length. uint8_t len = rsp[1] & 0x3F; // Skip 1st two bytes, read up to packet length. "len" @@ -298,12 +305,15 @@ int CRemoteMH::ReadFile(const char *filename, uint8_t *rd, const uint32_t rdlen, debug("Failed to read from remote"); return LC_ERROR_READ; } + exp_seq = rsp[2] & 0x3F; debug("ack"); debug_print_packet(rsp); pkt_count = 0; } } debug("data_read=%d", *data_read); + if (err) + return err; if ((err = reset_sequence(get_seq(seq), param))) return err; -- 1.8.5.3 ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk _______________________________________________ concordance-devel mailing list concordance-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/concordance-devel