From 6b4663444b653acff256ab5ddfe38470707f65d2 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 20 Feb 2009 12:12:16 +0000 Subject: [PATCH] Added event notifications for the Mares Nemo. --- src/mares_nemo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mares_nemo.c b/src/mares_nemo.c index 10e448a..99dad93 100644 --- a/src/mares_nemo.c +++ b/src/mares_nemo.c @@ -170,6 +170,11 @@ mares_nemo_device_dump (device_t *abstract, unsigned char data[], unsigned int s return DEVICE_STATUS_MEMORY; } + // Enable progress notifications. + device_progress_t progress = DEVICE_PROGRESS_INITIALIZER; + progress.maximum = MARES_NEMO_MEMORY_SIZE + 20; + device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + // Receive the header of the package. unsigned char header = 0x00; for (unsigned int i = 0; i < 20;) { @@ -185,6 +190,10 @@ mares_nemo_device_dump (device_t *abstract, unsigned char data[], unsigned int s } } + // Update and emit a progress event. + progress.current += 20; + device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + unsigned int nbytes = 0; while (nbytes < MARES_NEMO_MEMORY_SIZE) { // Read the packet. @@ -220,6 +229,10 @@ mares_nemo_device_dump (device_t *abstract, unsigned char data[], unsigned int s return DEVICE_STATUS_PROTOCOL; } + // Update and emit a progress event. + progress.current += MARES_NEMO_PACKET_SIZE; + device_event_emit (abstract, DEVICE_EVENT_PROGRESS, &progress); + nbytes += MARES_NEMO_PACKET_SIZE; }