35
35
36
36
#define MAXRETRIES 4
37
37
38
- #define SZ_PACKET 0x80
39
- #define SZ_PAGE (SZ_PACKET / 4)
38
+ #define SZ_PAGE 32
40
39
41
40
#define SZ_HEADER 32
42
41
42
+ #define ARCHIMEDE 0x01
43
43
#define IQ700 0x05
44
44
#define EDY 0x08
45
45
@@ -60,6 +60,7 @@ typedef struct cressi_edy_device_t {
60
60
const cressi_edy_layout_t * layout ;
61
61
unsigned char fingerprint [SZ_PAGE / 2 ];
62
62
unsigned int model ;
63
+ unsigned int packetsize ;
63
64
} cressi_edy_device_t ;
64
65
65
66
static dc_status_t cressi_edy_device_set_fingerprint (dc_device_t * abstract , const unsigned char data [], unsigned int size );
@@ -247,6 +248,7 @@ cressi_edy_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_t
247
248
device -> iostream = iostream ;
248
249
device -> layout = NULL ;
249
250
device -> model = 0 ;
251
+ device -> packetsize = 0 ;
250
252
memset (device -> fingerprint , 0 , sizeof (device -> fingerprint ));
251
253
252
254
// Set the serial communication protocol (1200 8N1).
@@ -284,19 +286,26 @@ cressi_edy_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_t
284
286
// Send the init commands.
285
287
cressi_edy_init1 (device );
286
288
cressi_edy_init2 (device );
287
- cressi_edy_init3 (device );
289
+ if (device -> model != ARCHIMEDE ) {
290
+ cressi_edy_init3 (device );
291
+ }
292
+
293
+ device -> packetsize = device -> model == ARCHIMEDE ?
294
+ SZ_PAGE : SZ_PAGE * 4 ;
288
295
289
- if (device -> model == IQ700 ) {
296
+ if (device -> model == IQ700 || device -> model == ARCHIMEDE ) {
290
297
device -> layout = & tusa_iq700_layout ;
291
298
} else {
292
299
device -> layout = & cressi_edy_layout ;
293
300
}
294
301
295
- // Set the serial communication protocol (4800 8N1).
296
- status = dc_iostream_configure (device -> iostream , 4800 , 8 , DC_PARITY_NONE , DC_STOPBITS_ONE , DC_FLOWCONTROL_NONE );
297
- if (status != DC_STATUS_SUCCESS ) {
298
- ERROR (context , "Failed to set the terminal attributes." );
299
- goto error_free ;
302
+ if (device -> model != ARCHIMEDE ) {
303
+ // Set the serial communication protocol (4800 8N1).
304
+ status = dc_iostream_configure (device -> iostream , 4800 , 8 , DC_PARITY_NONE , DC_STOPBITS_ONE , DC_FLOWCONTROL_NONE );
305
+ if (status != DC_STATUS_SUCCESS ) {
306
+ ERROR (context , "Failed to set the terminal attributes." );
307
+ goto error_free ;
308
+ }
300
309
}
301
310
302
311
// Make sure everything is in a sane state.
@@ -337,22 +346,33 @@ cressi_edy_device_read (dc_device_t *abstract, unsigned int address, unsigned ch
337
346
cressi_edy_device_t * device = (cressi_edy_device_t * ) abstract ;
338
347
339
348
if ((address % SZ_PAGE != 0 ) ||
340
- (size % SZ_PACKET != 0 ))
349
+ (size % device -> packetsize != 0 ))
341
350
return DC_STATUS_INVALIDARGS ;
342
351
343
352
unsigned int nbytes = 0 ;
344
353
while (nbytes < size ) {
345
354
// Read the package.
346
355
unsigned int number = address / SZ_PAGE ;
347
- unsigned char command [3 ] = {0x52 ,
348
- (number >> 8 ) & 0xFF , // high
349
- (number ) & 0xFF }; // low
350
- status = cressi_edy_transfer (device , command , sizeof (command ), data + nbytes , SZ_PACKET , 1 );
356
+ unsigned char command [3 ] = {0 };
357
+ if (device -> model == ARCHIMEDE ) {
358
+ command [0 ] = 0x45 ;
359
+ command [1 ] = 0x52 ;
360
+ command [2 ] = number & 0xFF ;
361
+ } else {
362
+ command [0 ] = 0x52 ;
363
+ command [1 ] = (number >> 8 ) & 0xFF ; // high;
364
+ command [2 ] = (number ) & 0xFF ; // low
365
+ }
366
+ status = cressi_edy_transfer (device , command , sizeof (command ), data + nbytes , device -> packetsize , 1 );
351
367
if (status != DC_STATUS_SUCCESS )
352
368
return status ;
353
369
354
- nbytes += SZ_PACKET ;
355
- address += SZ_PACKET ;
370
+ nbytes += device -> packetsize ;
371
+ address += device -> packetsize ;
372
+ }
373
+
374
+ if (device -> model == ARCHIMEDE ) {
375
+ array_reverse_nibbles (data , size );
356
376
}
357
377
358
378
return status ;
@@ -395,7 +415,7 @@ cressi_edy_device_dump (dc_device_t *abstract, dc_buffer_t *buffer)
395
415
device_event_emit (abstract , DC_EVENT_DEVINFO , & devinfo );
396
416
397
417
return device_dump_read (abstract , 0 , dc_buffer_get_data (buffer ),
398
- dc_buffer_get_size (buffer ), SZ_PACKET );
418
+ dc_buffer_get_size (buffer ), device -> packetsize );
399
419
}
400
420
401
421
@@ -407,7 +427,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
407
427
408
428
// Enable progress notifications.
409
429
dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER ;
410
- progress .maximum = SZ_PACKET +
430
+ progress .maximum = 4 * SZ_PAGE +
411
431
(layout -> rb_profile_end - layout -> rb_profile_begin );
412
432
device_event_emit (abstract , DC_EVENT_PROGRESS , & progress );
413
433
@@ -419,7 +439,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
419
439
device_event_emit (abstract , DC_EVENT_DEVINFO , & devinfo );
420
440
421
441
// Read the logbook data.
422
- unsigned char logbook [SZ_PACKET ] = {0 };
442
+ unsigned char logbook [4 * SZ_PAGE ] = {0 };
423
443
dc_status_t rc = cressi_edy_device_read (abstract , layout -> rb_logbook_offset , logbook , sizeof (logbook ));
424
444
if (rc != DC_STATUS_SUCCESS ) {
425
445
ERROR (abstract -> context , "Failed to read the logbook data." );
@@ -481,13 +501,13 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
481
501
}
482
502
483
503
// Update and emit a progress event.
484
- progress .current += SZ_PACKET ;
485
- progress .maximum = SZ_PACKET + total ;
504
+ progress .current += 4 * SZ_PAGE ;
505
+ progress .maximum = 4 * SZ_PAGE + total ;
486
506
device_event_emit (abstract , DC_EVENT_PROGRESS , & progress );
487
507
488
508
// Create the ringbuffer stream.
489
509
dc_rbstream_t * rbstream = NULL ;
490
- rc = dc_rbstream_new (& rbstream , abstract , SZ_PAGE , SZ_PACKET , layout -> rb_profile_begin , layout -> rb_profile_end , eop , DC_RBSTREAM_BACKWARD );
510
+ rc = dc_rbstream_new (& rbstream , abstract , SZ_PAGE , device -> packetsize , layout -> rb_profile_begin , layout -> rb_profile_end , eop , DC_RBSTREAM_BACKWARD );
491
511
if (rc != DC_STATUS_SUCCESS ) {
492
512
ERROR (abstract -> context , "Failed to create the ringbuffer stream." );
493
513
return rc ;
0 commit comments