From 06cf4fe68ad096961b4b9c653ba2bc31d270f009 Mon Sep 17 00:00:00 2001 From: Wolfgang Wiedmeyer Date: Fri, 21 Jul 2017 20:58:35 +0200 Subject: use static counter for hello requests Signed-off-by: Wolfgang Wiedmeyer --- boot.c | 3 +-- sahara.c | 5 +++-- sahara.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boot.c b/boot.c index 4198f90..f762659 100644 --- a/boot.c +++ b/boot.c @@ -69,7 +69,6 @@ int main() int mdm_dev, tty_dev; int mode; struct sah_data_end_ack data_end_ack; - int hellos = 0; int rc; mdm_dev = open(MDM_DEVICE, O_RDONLY | O_NONBLOCK); @@ -142,7 +141,7 @@ int main() } while (1) { - rc = handle_memory_debug(tty_dev, &hellos); + rc = handle_memory_debug(tty_dev); if (rc < 0) { printf("error during modem operation\n"); return -1; diff --git a/sahara.c b/sahara.c index 939b58c..5862f45 100644 --- a/sahara.c +++ b/sahara.c @@ -399,10 +399,11 @@ int efs_sync(int tty_fd) return 0; } -int handle_memory_debug(int tty_fd, int *hellos) +int handle_memory_debug(int tty_fd) { struct sah_header header; struct sah_hello_req hello_req; + static int i = 0; int rc; rc = read(tty_fd, &header, sizeof(header)); @@ -416,7 +417,7 @@ int handle_memory_debug(int tty_fd, int *hellos) printf("received hello\n"); // Modem doesn't like it if the second hello is // answered, so only read data and keep quiet. - if (++(*hellos) == 2) { + if (++i == 2) { rc = read_hello_data(tty_fd, SAH_MODE_MEMORY_DEBUG, &hello_req); diff --git a/sahara.h b/sahara.h index f7efc3d..65e9eb7 100644 --- a/sahara.h +++ b/sahara.h @@ -99,6 +99,6 @@ struct sah_memory_table { } __attribute__((__packed__)); int send_file(int tty_fd, struct sah_data_end_ack *data_end_ack); -int handle_memory_debug(int tty_fd, int *hellos); +int handle_memory_debug(int tty_fd); #endif -- cgit v1.2.3