# Olivier Fauchon <olivier@aixmarseille.com>
#
# Digital Dream Enigma 1.3 protocol
#
# 30/07/04


Camera storage medias
---------------------


Query:  c1 28 00 00 01 00 01 00
             |
             +----------> 01 : Flash Ram  0x02: SmartMedia Card

Answer: 0x01 -> storage type present, 0x00h -> No storage of this type



Get number of pictures
----------------------

Query:  04 00
Answer: c1 54 00 00 00 00 02 00

NB: The camera returns a number of photo x 2, because for each picture you
take, the camera holds both the picture and its thrumbnail.
On the example above, i took only 2 snapshots.


Download the Table of Contents (or file directory)
--------------------------------------------------

This camera provides you a directory containing the name of the picture,
the size of the picture (maybe the size, i 'll have a look)

Each entry (so each photo) is composed of 16 bytes for its name, and 16 bytes for
 

41 54 08 00 01 00 00 00        (USB_WRITE COMMAND TO REQUEST THE TOC)

<- 41
-> c1 21 00 00 00 00 01 00     (SETUP PACKET READ. don't know what for)

<- 01
->c1 21 00 00 02 00 01 00a     (SETUP PACKET READ. don't know what for)



Then you can read (32* number_of_images)

    00000000: 53 55 4e 50 30 30 30 31 4a 50 47 20 00 00 00 00
    00000010: 00 00 c3 0b 00 00 7d 1a c3 0b 04 00 8e 75 03 00
    00000020: 53 55 4e 50 30 30 30 31 54 48 4d 20 00 00 00 00
    00000030: 00 00 c3 0b 00 00 7d 1a c3 0b 20 00 00 a0 00 00
    00000040: 53 55 4e 50 30 30 30 32 4a 50 47 20 00 00 00 00
    00000050: 00 00 c3 0b 00 00 7d 1a c3 0b 25 00 c5 85 03 00
    00000060: 53 55 4e 50 30 30 30 32 54 48 4d 20 00 00 00 00
    00000070: 00 00 c3 0b 00 00 7d 1a c3 0b 42 00 00 a0 00 00
    00000080: 53 55 4e 50 30 30 30 33 4a 50 47 20 00 00 00 00
    00000090: 00 00 c3 0b 00 00 7d 1a c3 0b 47 00 03 d9 00 00
    000000a0: 53 55 4e 50 30 30 30 33 54 48 4d 20 00 00 00 00
    000000b0: 00 00 c3 0b 00 00 7d 1a c3 0b 4e 00 80 25 00 00
    000000c0: 53 55 4e 50 30 30 30 34 4a 50 47 20 00 00 00 00
    000000d0: 00 00 c3 0b 00 00 7d 1a c3 0b 50 00 22 3c 03 00
    000000e0: 53 55 4e 50 30 30 30 34 54 48 4d 20 00 00 00 00
    000000f0: 00 00 c3 0b 00 00 7d 1a c3 0b 6a 00 00 a0 00 00

Toc entry description:

This is the 1st picture :

    00000000: 53 55 4e 50 30 30 30 31 4a 50 47 20 00 00 00 00
    00000010: 00 00 c3 0b 00 00 7d 1a c3 0b 04 00 8e 75 03 00

the name is SUNP0001JPG ( 53 55 4e 50 30 30 30 31 4a 50 47 20 ) in ASCII
the size is 0x03<<10000 +  0x75<<100 +  08e  =0x03758e  == 226702 bytes



Download image
--------------


USB_WRITE :41 54 01 00 03 00 00 00
                 |     |
                 |     +----------------> 0x03 for thrumbnail, 0x02 for the real photo
                 +----------------------> Image number (01 is the first, NO zero index)

HERE, YOU CAN SLEEP 300 MILLISECOND


There follows 3 packets with the cam (don't know what they are used for) but i play them.
<- 41
-> c1 21 00 00 00 00 01 00

<- 01
-> c1 21 00 00 02 00 01 00

<- 01
-> c1 21 00 00 02 00 01 00

AH, it's TIME to download

Size to read is the size you extracted from the table of content .... BUT, you need to align
this size to the media block size :


SIZE_TO_READ_ = (REAL_SIZE_FROM_TOC / ALIGNEMENT) * ALIGNEMENT 


- If the image is on FLASH, alignement is 0x2000
- If the image is on SmartMedia card, alignment is 0x4000




