summaryrefslogtreecommitdiff
path: root/camlibs/agfa-cl20/protocol2.txt
blob: e5df662be7b3957e28f7173b411d28d3b48c912a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
Okay,

this is the second approach for the Protocol.

What I believe the "commands" are, I have put in a list in the file "commands.txt".

There seem to be fundamental differecs in the data and command set, when using a flash card or no flash card.
When the pictures are saved on the internal camera memory, they come over in a strange format, from which I have no idea, what it is. Additionally the commands used to retrieve pictures are different.

I will now try to specify the commands used for the basic operation of the camera.

When using a Flash Card, the pictures are coming over in EXIF Format. EXIF is a JPEG format developed for DSC (digital still cameras).

---------------
Digital Still Camera Image File Format Standard (Exchangeable image file format for Digital Still Cameras: Exif) Version 2.1
----------------

The specs can be found here:
http://www.pima.net/standards/it10/PIMA15740/Exif_2-1.PDF

This is a special format which INCLUDES THUMBNAILS. This means, that the picture and the thmbnail are ONE file.
So what basicallly happens in the windows driver:

It retrieves the EXIF File complete, for example 173kb. I calculated it. It fits. I had 685 Bulk Transfers, 256Bytes each, which makes a total of 175360 Bytes --> my picture (Exif=Thumbnail+picture).
The Windows driver then extracts the Thumbnail out of the Exif, saves i as JFIF (JPEG) and displays it in the thumbnail overview.

So, if you have the Exif you automatically have the Thumbnail AND the picture. So there is only one transfer for both.

Interesting is also, that the actual picture, the Exif File, comes in BIG ENDIAN Format. you can see this from the 4d 4d (MM) in the EXIF header.


Okay, let's tell something about the protocoll:

Everything can be looked up in the USB 1.1 secification!
That's where I have everything from.

All the communication consists of three usb command types:
It seems that all the packages have a little endian byte order (least significant byte first?)
I always cofuse that. Well, If I have 0x0001 then it sends 01 00, so turned around.

1. control packages with direction "in"
2. control packages with direction "out"
3. bulk transfers with direction "in"

1. These control packages are always 8 Bytes long. The first
   Byte is the reqest Type. this is always 0xc1 for direction "in".
  The c1 is a Bitmap:
7 1     means that the direction is device to host
6 1     Bits 6 and 5 mean that the "Type" is "Vendor"
5 0
4 0     the first 5 Bits (0-4) define the recipient. In this case an "Interface"
3 0
2 0
1 0
0 1

the last two Bytes are always 01 00 the length of the camera reply, so 0x0001 - one Byte.
The camera always replys with 0x00.


2. Similar to 1. just the direction is "out".
   The first byte is always 0x41 (just changing the last bit to 0 - direction "out")
   The last two bytes are 00 00, because we don't await an answer of the camera.


3. these semm to be standard bulk transfers. you just open one, and the camera sends data.
   The direction of this transfer is "in".
   The trnsfer buffer length is always 0x100.



-----------------


So, what happens now on the bus:

First we send a standard USB Device request, to get the device descriptor:
direction is "in" (80) length of answer is 0x0012 (12 00)

SetupPacket          : 80 06 00 01 00 00 12 00

We get as an answer the device descriptor:

    0000:       
      12 01 00 01 00 00 00 08 bd 06 04 04 90 00 00 00        
    0010:       
      00 01  

What this means is in the USB specs.


Then we want the "configuration descriptor" from the device. I think this is done by sending:

SetupPacket          : 80 06 00 02 00 00 09 02


As answer we should get:
   0000:
09 02 27 00 01 01 00 80 fa 09 04 01 00 03 ff 00
   0010:
00 00 07 05 82 02 40 00 00 07 05 03 02 40 00 00
   0020:
07 05 84 03 01 00 08


Now it's time to choose a configuration. I believe the camera just has one, but without setting it exlicitly, the camera does not
hing!

So we choose configuration 0x01.

I think this is done by sending:

SetupPacket          : 00 09 01 00 00 00 00 00
Note, that the direction is "out" now (00) and the length 0x0000 (00 00).

        
That was the setup process. Now the camera should talk to us.



SetupPacket          : c1 00 00 00 21 05 01 00
        answer:         00
SetupPacket          : 41 02 00 00 07 00 00 00
SetupPacket          : 41 0a 00 00 00 00 00 00
SetupPacket          : 41 02 00 00 07 00 00 00
SetupPacket          : 41 0a 00 00 01 00 00 00   This is the command for getting
                                                 a basic directory

Bulk Transfer "in":
***********************************************************************8
this output is very different if you use a flash card or not.
These are the first rows with a flash card:


   0000:                   1  .  1  6            
01 00 00 10 00 00 00 00 00 31 2e 31 36 00 00 00 
   0010:                                       
00 00 00 00 00 00 02 00 00 02 00 00 00 00 06 0a  The first 02 is the number of
   0020:                                         pictures plus one. In this case
1e 79 01 69 02 28 06 50 01 e0 00 60 00 c0 0f 00  one piture.
   0030:       
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00        
   0040:       
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00        


These are the first rows without a flash card:

   0000:
00 00 00 10 00 ff ff ff ff 31 2e 31 36 ff ff ff
   0010:
ff ff ff ff 00 03 00 00 00 02 00 00 ff ff 05 09 Maybe the 03 is the nubmer of pictures, but I don't
   0020:                                        think so..
1b 00 00 00 00 00 00 50 01 e0 00 60 00 17 0f 00
   0030:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

  UPDATE: dennis, 09.09.02
  The 03 IS the number of pictures. I have tried it several times and it always represents the 
  number of pictures. Funny how you don't have to subtract 1 here!



Next thing that happens is to get information on the picture. This is done for EACH picture.

So, if I have 5 pictures I will get 5 commands:

                          flash-card                   no flash card
SetupPacket          : 41 0a 01 00 08 00 00 00    41 03 ff 0f 00 00 00 00
SetupPacket          : 41 0a 02 00 08 00 00 00    41 03 fe 0f 00 00 00 00
SetupPacket          : 41 0a 03 00 08 00 00 00    41 03 fd 0f 00 00 00 00
SetupPacket          : 41 0a 04 00 08 00 00 00    41 03 fc 0f 00 00 00 00
SetupPacket          : 41 0a 05 00 08 00 00 00    41 03 fb 0f 00 00 00 00

Each time I get back a picture information package, looing like (for pic 4 for ex)

   0000:                                          
01 00 00 10 00 90 01 01 05 31 2e 31 36 01 08 01		01 74 00 ff ff 35 00 02 20 18 90 78 34 00 00 00
   0010:
09 05 0a 01 00 03 06 00 00 02 00 00 0f 01 05 09		1b 01 00 00 17 0f 00 5c 66 40 3c ff ff ff ff ff
   0020:
1b 74 01 62 02 11 06 50 01 e0 00 60 00 17 0f 01		ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
   0030:
19 01 1a 01 1b 01 1c 01 1d 01 1e 01 1f 01 20 01		and mor ffs...
   0040:
21 01 22 01 23 01 24 01 25 01 26 01 27 01 28 01
   0050:
29 01 2a 01 2b 01 2c 01 2d 01 2e 01 2f 01 30 01
   0060:
31 01 32 01 33 01 34 01 35 01 36 01 37 01 38 01
   0070:
39 01 3a 01 3b 01 3c 01 3d 01 3e 01 3f 01 40 01
   0080:
41 01 42 01 43 01 44 01 45 01 46 01 47 01 48 01
   0090:
49 01 ff ff 4b 01 4c 01 4d 01 4e 01 4f 01 50 01
   00a0:
51 01 52 01 53 01 54 01 55 01 56 01 57 01 58 01
   00b0:
59 01 5a 01 5b 01 5c 01 5d 01 5e 01 5f 01 60 01
   00c0:
61 01 62 01 63 01 64 01 65 01 66 01 67 01 68 01
   00d0:
69 01 6a 01 6b 01 6c 01 6d 01 6e 01 6f 01 70 01
   00e0:
71 01 72 01 73 01 74 01 75 01 76 01 77 01 78 01
   00f0:
79 01 7a 01 7b 01 7c 01 7d 01 7e 01 7f 01 80 01

I don't know yet, what information is in there, and what it is used for.
Also a clear difference between the flash card and the non flash card.




Then, the Exif files (in case of the flash card - in non flash card mode I don't know, what is going to be transferred)
are transferred, one after the other. In order.


                          flash card                        non flash card
SetupPacket          : 41 0a 01 00 0a 00 00 00		41 03 ff 0f 08 00 00 00


   0000:
ff d8 ff e1 61 a5 45 78 69 66 00 00 4d 4d 00 2a		ef a8 a2 8a 00 28 a2 8a 00 28 a2 8a 00 28 a2 8a
   0010:
00 00 00 08 00 07 01 1a 00 05 00 00 00 01 00 00		00 28 a2 8a 00 28 a2 8a 00 28 a2 8a 00 28 a2 8a
   0020:
01 0e 01 1b 00 05 00 00 00 01 00 00 01 16 01 28		00 28 a2 8a 00 28 a2 8a 00 28 a2 8a 00 28 a4 a5
   0030:
00 03 00 00 00 01 00 02 00 00 02 13 00 03 00 00		a0 02 8a 28 a0 02 8a 28 a0 02 8a 28 a0 02 8a 28
   0040:
50 49 43 54 30 30 30 31 4a 50 47 20 00 00 00 00		and so on....
   0050:
00 00 00 00 00 00 00 00 00 00 02 00 00 ac 02 00
   0060:
50 49 43 54 30 30 30 32 4a 50 47 20 00 00 00 00
   0070:
00 00 00 00 00 00 00 00 00 00 ad 00 00 74 02 00
   0080:
50 49 43 54 30 30 30 33 4a 50 47 20 00 00 00 00
   0090:
00 00 00 00 00 00 00 00 00 00 4a 01 00 60 03 00
   00a0:
50 49 43 54 30 30 30 34 4a 50 47 20 00 00 00 00
   00b0:
00 00 00 00 00 00 00 00 00 00 22 02 00 90 01 00
   00c0:
50 49 43 54 30 30 30 35 4a 50 47 20 00 00 00 00
   00d0:
00 00 00 00 00 00 00 00 00 00 86 02 00 c0 02 00
   00e0:
02 00 04 00 00 00 01 00 00 04 00 a0 03 00 04 00
   00f0:
00 00 01 00 00 03 00 00 00 00 00 00 0e 01 00 00


This is an exif File. It has a clear header, This I don't know what it
is. I cannot and conforms to the spec. I reckon, you can just find a
header nor other readable characters.  save it and use it. Maybe it is
just compressed jpg data.  I don't know.
----------------------------------------------------------------------