Added event notifications for the Mares Nemo.

This commit is contained in:
Jef Driesen 2009-02-20 12:12:16 +00:00
parent 204c83c150
commit 6b4663444b

View File

@ -170,6 +170,11 @@ mares_nemo_device_dump (device_t *abstract, unsigned char data[], unsigned int s
return DEVICE_STATUS_MEMORY; 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. // Receive the header of the package.
unsigned char header = 0x00; unsigned char header = 0x00;
for (unsigned int i = 0; i < 20;) { 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; unsigned int nbytes = 0;
while (nbytes < MARES_NEMO_MEMORY_SIZE) { while (nbytes < MARES_NEMO_MEMORY_SIZE) {
// Read the packet. // Read the packet.
@ -220,6 +229,10 @@ mares_nemo_device_dump (device_t *abstract, unsigned char data[], unsigned int s
return DEVICE_STATUS_PROTOCOL; 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; nbytes += MARES_NEMO_PACKET_SIZE;
} }