summaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-19 12:17:31 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-08-19 12:17:31 +0000
commit8d0e3395a0ec1082872df71d0f982ede60e17bfb (patch)
tree32b6383d849c3c1278a8a4050d27948e2f20c2b5 /src/helper
parent91b6460671671a4052feaed04de74ec73bc7f851 (diff)
downloadopenocd_libswd-8d0e3395a0ec1082872df71d0f982ede60e17bfb.tar.gz
openocd_libswd-8d0e3395a0ec1082872df71d0f982ede60e17bfb.tar.bz2
openocd_libswd-8d0e3395a0ec1082872df71d0f982ede60e17bfb.tar.xz
openocd_libswd-8d0e3395a0ec1082872df71d0f982ede60e17bfb.zip
added alive_sleep() function to let GDB alive packets be sent
git-svn-id: svn://svn.berlios.de/openocd/trunk@938 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/log.c17
-rw-r--r--src/helper/log.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/src/helper/log.c b/src/helper/log.c
index ef1a6bb0..efe5d5bb 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -385,3 +385,20 @@ void kept_alive()
current_time=timeval_ms();
last_time=current_time;
}
+
+/* if we sleep for extended periods of time, we must invoke keep_alive() intermittantly */
+void alive_sleep(int ms)
+{
+ int i;
+ for (i=0; i<ms; i+=500)
+ {
+ int sleep_a_bit=ms-i;
+ if (sleep_a_bit>500)
+ {
+ sleep_a_bit=500;
+ }
+ keep_alive();
+ usleep(sleep_a_bit*1000);
+ keep_alive();
+ }
+}
diff --git a/src/helper/log.h b/src/helper/log.h
index c329fb58..b6f166be 100644
--- a/src/helper/log.h
+++ b/src/helper/log.h
@@ -61,6 +61,7 @@ extern int log_init(struct command_context_s *cmd_ctx);
extern int set_log_output(struct command_context_s *cmd_ctx, FILE *output);
extern void keep_alive(void);
extern void kept_alive(void);
+extern void alive_sleep(int ms);
typedef void (*log_callback_fn)(void *priv, const char *file, int line,
const char *function, const char *string);