Shopping Cart

Posts

Digital camera control using Arduino USB Host Shield. Part 1 - basics.

Arduino taking picture of itself

Arduino taking picture of itself

I’m starting new series of articles describing exciting field of digital camera control. In modern cameras, USB port can be used not only for transferring images to a PC, but also for sending control commands to the camera. It is often possible to send commands which “press” the shutter button, modify shutter and aperture values, some cameras are even capable of doing focus control. At the same time, new shooting techniques, such as HDR and stacked focus, require that a photographer makes several shots, slightly modifying one or several shooting parameters from shot to shot. Even age-old time lapse technique could use some automation. Since camera manufacturers are, as always slow to implement there cool features, Arduino comes to the rescue.

I am announcing new code developed for Arduino USB Host shield which implements digital camera control functions via PTP. Alex Glushchenko, a developer from my native Russia, recently joined camera control project and code shown here and in the future articles is mainly his. He did most of reverse engineering and code development and my contributions to this project were mainly code testing, camera borrowing, and blogging. Code is hosted on github separately from USB Host library. Be warned – this source is preliminary and will be changed many times before it becomes stable! It is also expected to grow quite a bit – different cameras use different commands and developing universal code supporting all manufacturers (or even every camera from one manufacturer) is not possible due to the modest resources of Arduino platform. Therefore, several libraries have been developed, each covering specific set of cameras. The cameras supporting functions of a certain library are listed in library’s header file. The list of cameras is currently quite small but I’m hoping to get more cameras supported in the future.

Digital camera as USB peripheral is much more complex and less standard than a keyboard. The complexity starts at the very first level – device configuration. Very often , several different configurations are supported on a device and the default configuration is not the one we need. Therefore, the first step would naturally be learning how to recognize configuration which supports camera control commands.

There are 3 specifications describing USB digital camera works. Still Image Device specifies USB requests, descriptors and endpoints. The protocol structure is described in Media Transfer Protocol (MTP), which is better known by its previous name, “Picture Transfer Protocol” (PTP). The most interesting document, which actually lists commands supported by camera class, is known as “PIMA 15740-2000″. It is available for a fee from I3A, however, second-hand pdf copy can be obtained for free after some googling. Camera manufacturers implement their own functions, expanding PIMA definitions. In addition to that, some older cameras use their proprietary protocols instead of PTP; support for such cameras will be added eventually.

USB specification defines a class called “Still Image Capture Device”. According to it, such device has ’06′ in “Class” field of interface descriptor of the configuration. Therefore, one way to find necessary configuration is to look at configuration descriptor contents. Let’s take a look at the device descriptor (in case you are curious, it’s an iPhone). When we look at the last line, the number of configurations is 4. Older cameras may have 2 configurations and the first one is often a disk drive – this arrangement was made in pre-PTP times so you could offload pictures to a PC even if you didn’t have a driver for the camera installed. Modern cameras rely on PTP to transfer files to PC and often come with just one configuration – so far, all cameras used so to check the PTP code for the shield were of this variety.

Device descriptor:
Descriptor Length:      12
Descriptor type:        01
USB version:            0200
Device class:           00
Device Subclass:        00
Device Protocol:        00
Max.packet size:        40
Vendor  ID:             05AC
Product ID:             1292
Revision ID:            0001
Mfg.string index:       01
Prod.string index:      02
Serial number index:    03
Number of conf.:        04

A sketch which prints device descriptor was posted several articles back, make yourself a copy of it if you haven’t already. A sketch printing configuration descriptor was also posted not long ago; however, it was written to output only first configuration of the device – don’t use it. Instead, download this multiple configuration capable sketch from examples section of USB_Host_Shield repo. The following table shows all four configurations of the iPhone:

Configuration: 0

Configuration descriptor:
Total length:     0027
Num.intf:         01
Conf.value:       01
Conf.string:      05
Attr.:            C0
Max.pwr:          FA

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        03
Class:            06
Subclass:         01
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 02
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 81
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0040
Polling interval: 40
Configuration: 1

Configuration descriptor:
Total length:     0095
Num.intf:         03
Conf.value:       02
Conf.string:      06
Attr.:            C0
Max.pwr:          FA

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        00
Class:            01
Subclass:         01
Protocol:         00
Intf.string:      00

Unknown descriptor:
Length:           09
Type:             24
Contents:
0100011E0001010C24

Unknown descriptor:
Length:           0C
Type:             24
Contents:
020101020202030000000924

Unknown descriptor:
Length:           09
Type:             24
Contents:
030201010101000904

Interface descriptor:
Intf.number:      01
Alt.:             00
Endpoints:        00
Class:            01
Subclass:         02
Protocol:         00
Intf.string:      00

Interface descriptor:
Intf.number:      01
Alt.:             01
Endpoints:        01
Class:            01
Subclass:         02
Protocol:         00
Intf.string:      00

Unknown descriptor:
Length:           07
Type:             24
Contents:
01020101002324

Unknown descriptor:
Length:           23
Type:             24
Contents:
020102021009401F00112
B00E02E00803E00225600
C05D00007D0044AC0080B
B000905

Endpoint descriptor:
Endpoint address: 81
Attr.:            01
Max.pkt size:     00C0
Polling interval: 01

Unknown descriptor:
Length:           07
Type:             25
Contents:
01010000000904

Interface descriptor:
Intf.number:      02
Alt.:             00
Endpoints:        01
Class:            03
Subclass:         00
Protocol:         00
Intf.string:      00

Unknown descriptor:
Length:           09
Type:             21
Contents:
110100012260000705

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0040
Polling interval: 01
Configuration: 2

Configuration descriptor:
Total length:     003E
Num.intf:         02
Conf.value:       03
Conf.string:      07
Attr.:            C0
Max.pwr:          FA

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        03
Class:            06
Subclass:         01
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 02
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 81
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0040
Polling interval: 40

Interface descriptor:
Intf.number:      01
Alt.:             00
Endpoints:        02
Class:            FF
Subclass:         FE
Protocol:         02
Intf.string:      00

Endpoint descriptor:
Endpoint address: 04
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 85
Attr.:            02
Max.pkt size:     0040
Polling interval: 00
Configuration:    3

Configuration descriptor:
Total length:     005E
Num.intf:         03
Conf.value:       04
Conf.string:      08
Attr.:            C0
Max.pwr:          FA

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        03
Class:            06
Subclass:         01
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 02
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 81
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0040
Polling interval: 40

Interface descriptor:
Intf.number:      01
Alt.:             00
Endpoints:        02
Class:            FF
Subclass:         FE
Protocol:         02
Intf.string:      00

Endpoint descriptor:
Endpoint address: 04
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 85
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Interface descriptor:
Intf.number:      02
Alt.:             00
Endpoints:        00
Class:            FF
Subclass:         FD
Protocol:         01
Intf.string:      00

Interface descriptor:
Intf.number:      02
Alt.:             01
Endpoints:        02
Class:            FF
Subclass:         FD
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 86
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 05
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

The key here is Class field in interface descriptor – we know that still image capture device is identified by class 6. As we can see, configurations 0, 2 and 3 have potential. However, after much testing I found that none of these configurations support camera control commands. Here is another example of “Class 6 device” configuration, taken from Canon XSi camera – :

Configuration: 0
Configuration descriptor:
Total length:     0027
Num.intf:         01
Conf.value:       01
Conf.string:      00
Attr.:            C0
Max.pwr:          01

Interface descriptor:
Intf.number:      00
Alt.:             00
Endpoints:        03
Class:            06
Subclass:         01
Protocol:         01
Intf.string:      00

Endpoint descriptor:
Endpoint address: 81
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 02
Attr.:            02
Max.pkt size:     0040
Polling interval: 00

Endpoint descriptor:
Endpoint address: 83
Attr.:            03
Max.pkt size:     0008
Polling interval: 20

Number 6 in interface Class field doesn’t guarantee functionality but at least this configuration can then be activated and checked with PTP queries. It’s worth mentioning that in some cameras different configurations can be activated via camera menu and very often configuration which has “PTP” in it’s name is not the one we need. For example, Canon 5D has “PC Connection” configuration containing FF in interface class field and “PTP/Print” one with class 06. Even though both configurations talk PTP, PC Connection configuration is the one that supports remote control. This strangeness can be explained by the fact that Canon had proprietary camera control long before PTP and their first PTP implementation was written in order to be able to interact with third-party picture printers.

Let’s talk briefly about PTP protocol. A unit of information exchange in PTP protocol is called a transaction. Camera commands, requests and responses travel inside transactions. In turn, transactions are exchanged within sessions – to send something to the camera, a session would have to be opened first (one exception being “Get Device Info” request, more about it later). Many times several responses are given to a single request, the first one meaning camera understood the request, the second one generated when requested command has been executed, and then another one reflecting camera changes resulted in command execution, like image file apperared after a picture has been taken. Some types of responses have specific meaning and are called events. In order to make a shot, program needs to open a session to the camera, set PC connection mode, send shutter release command, wait for “Shutter released” event, then wait until a new file appears on the memory card (another event) and only after that consider the job done and close the session. Data flow of other commands is similar; to change aperture we need to send aperture value and wait for “aperture changed” event. Skipping commands or requests for new events in the sequence usually causes camera to hang – it would execute a command or two and then become unresponsive and would have to be power cycled. Hanging of the camera is harmless and shall be anticipated during development.

Another piece of PTP device is properties. In digital camera, most properties contain shooting parameters. Typical example of a property is shutter speed value – this property can be changed. Another property is battery level. We won’t be able to change it directly but can request it’s value. There are also properties which both change by itself and can be changed externally; one good example is camera’s real-time clock.

Lastly, there are objects contained in storages. For cameras, this is mainly files on memory card and their significance in Arduino-based applications is minor.

It’s now time to start controlling our cameras. The very first piece of software is a sketch that queries PTP device and prints out it’s capabilities. It uses GetDeviceInfo command (or operation) to output device capabilities. GetDeviceInfo is the only PTP operation which can be sent to the device without opening a session first. You will need al 3 files from this directory as well as files from ptp directory copied into %arduino%/hardware/libraries/ptp directory. This sketch is not camera-specific – it shall work with any class 6 device (as well as some proprietary ones, see note about Canon 5D above). Regretfully, this sketch won’t fit into 16K Arduinos – parser strings eat too much memory and more strings will be added in the future when more vendor-specific commands become known.

Here is PTPDevInfo output of an iPhone:

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
iPhone
Start
 
Device configured.: 0x0000
 
0000:ED 00 00 00 02 00 01 10 01 00 00 00 64 00 00 00
0010:00 00 00 00 20 44 00 65 00 76 00 69 00 63 00 65
0020:00 20 00 68 00 61 00 73 00 20 00 6E 00 6F 00 20
0030:00 76 00 65 00 6E 00 64 00 6F 00 72 00 20 00 65
0040:00 78 00 74 00 65 00 6E 00 73 00 69 00 6F 00 6E
0050:00 73 00 00 00 00 00 0E 00 00 00 01 10 02 10 03
0060:10 04 10 05 10 06 10 07 10 08 10 09 10 0A 10 0B
0070:10 14 10 15 10 1B 10 01 00 00 00 06 40 00 00 00
0080:00 03 00 00 00 01 38 0B 38 0D 38 03 00 00 00 01
0090:38 0B 38 0D 38 0B 41 00 70 00 70 00 6C 00 65 00
00A0:20 00 49 00 6E 00 63 00 2E 00 00 00 0D 41 00 70
00B0:00 70 00 6C 00 65 00 20 00 69 00 50 00 68 00 6F
00C0:00 6E 00 65 00 00 00 06 33 00 2E 00 31 00 2E 00
00D0:33 00 00 00 0C 38 00 36 00 38 00 33 00 30 00 50
00E0:00 45 00 32 00 59 00 37 00 48 00 00 00
 
Std. Ver.:  0x100
Vendor ID:  0x0(Unknown)
 
Vend.Ext.Ver.:  0x0
Device has no vendor extensionsFunc.Mode: 0x8C7
 
 
 
Operations supported:
 
1001  GetDeviceInfo
1002  OpenSession
1003  CloseSession
1004  GetStorageIDs
1005  GetStorageInfo
1006  GetNumObjects
1007  GetObjectHandles
1008  GetObjectInfo
1009  GetObject
100A  GetThumb
100B  DeleteObject
1014  GetDevicePropDesc
1015  GetDevicePropValue
101B  GetPartialObject
 
Events supported:
 
4006  DevicePropChanged
 
Device properties supported:
 
Capture formats:
 
3801  EXIF_JPEG
380B  PNG
380D  TIFF
 
Image Formats:
 
3801  EXIF_JPEG
380B  PNG
380D  TIFF
 
Manufacturer: Apple Inc.
 
Model:  Apple iPhone
Device version: 3.1.3
Serial number:  86830PE2Y7H

The output starts with hex dump of the response and device operations start at line 31. The first operation, 1001 or GetDeviceInfo, it the very operation that was used to retrieve this information. The “OpenSession” and “Close Session”, as you may have guessed, are used to open and close a session with the device, the rest are used for file manipulation – not very useful. Let’s now take a look at GetDeviceInfo of a real camera, in this case, Canon 400D:

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
Canon 400D
Start
Device configured.: 0x0000
Opening session #: : 0x0001
OpenSession: Session opened.: 0x2001
0000:5D 01 00 00 02 00 01 10 02 00 00 00 64 00 0B 00
0010:00 00 C8 00 00 00 00 38 00 00 00 14 10 16 10 15
0020:10 01 10 02 10 03 10 13 90 04 10 05 10 06 10 07
0030:10 08 10 0A 10 09 10 1B 10 0C 10 0D 10 0B 10 01
0040:91 02 91 03 91 04 91 07 91 05 91 17 91 18 91 16
0050:91 0F 91 15 91 10 91 14 91 13 91 06 91 0A 91 0B
0060:91 0C 91 0E 91 1A 91 1B 91 1C 91 1D 91 08 91 1F
0070:91 09 91 1E 91 20 91 21 91 0F 10 01 98 02 98 03
0080:98 04 98 05 98 FE 91 FF 91 1F 90 04 00 00 00 09
0090:40 04 40 05 40 01 C1 06 00 00 00 45 D0 02 D4 07
00A0:D4 06 D4 49 D0 4A D0 01 00 00 00 01 38 09 00 00
00B0:00 01 30 02 30 0A 30 08 30 01 38 01 B1 03 B1 02
00C0:BF 00 38 0B 43 00 61 00 6E 00 6F 00 6E 00 20 00
00D0:49 00 6E 00 63 00 2E 00 00 00 17 43 00 61 00 6E
00E0:00 6F 00 6E 00 20 00 45 00 4F 00 53 00 20 00 34
00F0:00 30 00 30 00 44 00 20 00 44 00 49 00 47 00 49
0100:00 54 00 41 00 4C 00 00 00 08 33 00 2D 00 31 00
0110:2E 00 31 00 2E 00 31 00 00 00 21 30 00 30 00 30
0120:00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30
0130:00 30 00 30 00 30 00 30 00 30 00 30 00 30 00 30
0140:00 30 00 30 00 30 00 30 00 30 00 31 00 39 00 61
0150:00 33 00 32 00 37 00 66 00 39 00 00 00
 
Std.Ver.:	0x100
Vendor Ext. ID:	0xB(Canon)
 
Vend.Ext.Ver.:	0xC8
 
Func.Mode:	0x8C7
 
Operations supported:
1014	GetDevicePropDesc
1016	SetDevicePropValue
1015	GetDevicePropValue
1001	GetDeviceInfo
1002	OpenSession
1003	CloseSession
9013	PS_CheckEvent
1004	GetStorageIDs
1005	GetStorageInfo
1006	GetNumObjects
1007	GetObjectHandles
1008	GetObjectInfo
100A	GetThumb
1009	GetObject
101B	GetPartialObject
100C	SendObjectInfo
100D	SendObject
100B	DeleteObject
9101	EOS_GetStorageIDs
9102	EOS_GetStorageInfo
9103	Vendor defined
9104	Vendor defined
9107	EOS_GetObject
9105	Vendor defined
9117	Vendor defined
9118	Vendor defined
9116	EOS_GetEvent
910F	EOS_Capture
9115	EOS_SetExtendedEventInfo
9110	EOS_SetDevicePropValue
9114	EOS_SetPCConnectMode
9113	Vendor defined
9106	Vendor defined
910A	Vendor defined
910B	Vendor defined
910C	Vendor defined
910E	Vendor defined
911A	Vendor defined
911B	Vendor defined
911C	Vendor defined
911D	Vendor defined
9108	EOS_GetDeviceInfo
911F	Vendor defined
9109	EOS_GetObjectIDs
911E	Vendor defined
9120	Vendor defined
9121	Vendor defined
100F	FormatStore
9801	GetObjectPropsSupported
9802	GetObjectPropDesc
9803	GetObjectPropValue
9804	SetObjectPropValue
9805	GetObjectPropList
91FE	Vendor defined
91FF	Vendor defined
901F	Vendor defined
 
Events supported:
4009	RequestObjectTransfer
4004	StoreAdded
4005	StoreRemoved
C101	Vendor defined
 
Device properties supported:
D045	Vendor defined
D402	Device_Friendly_Name
D407	Perceived_Device_Type
D406	Session_Initiator_Version_Info
D049	Vendor defined
D04A	Vendor defined
 
Capture formats:
3801	EXIF_JPEG
 
Image Formats:
3001	Association
3002	Script
300A	AVI
3008	WAV
3801	EXIF_JPEG
B101	Vendor defined
B103	Vendor defined
BF02	Vendor defined
3800	Undefined
 
Manufacturer:	Canon Inc.
Model:		Canon EOS 400D DIGITAL
Device ver.:	3-1.1.1
Serial num.:	00000000000000000000000019a327f9
 
Closing session #: : 0x0001
Session closed.: 0x2001

This output lists many vendor-specific functions, some of which are used for camera control. Even though standard PTP contains many camera control commands, vendors tend to write their own, sometimes duplicating even non-camera control functions. The functions which name starts with “EOS” are Canon-specific.”Vendor defined” functions are also Canon-specific functions whose purpose is yet unknown.

GetDeviceInfo is a powerful tool to compare functionality of different cameras from the same vendor. Functions with the same number often perform identical actions. For example, the following output taken from Canon xSi camera shows the same EOS_Capture command as in 400D (910f, line 64 in 400D output, line 75 in xSi output). Indeed, shutter release code for 400D works identically on xSi.

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
Canon xSi
Start
 
Device configured.: 0x0000
Opening session #: : 0x0001
OpenSession: Session opened.: 0x2001
 
0000:7B 01 00 00 02 00 01 10 02 00 00 00 64 00 06 00
0010:00 00 C8 00 00 00 00 41 00 00 00 14 10 15 10 16
0020:10 01 10 02 10 03 10 06 10 04 10 01 91 05 10 02
0030:91 07 10 08 10 03 91 09 10 04 91 0A 10 1B 10 07
0040:91 0C 10 0D 10 0B 10 05 91 0F 10 06 91 10 91 27
0050:91 0B 91 08 91 09 91 0C 91 0E 91 0F 91 25 91 26
0060:91 15 91 14 91 13 91 16 91 17 91 20 91 F0 91 18
0070:91 21 91 F1 91 1D 91 0A 91 1B 91 1C 91 1E 91 1A
0080:91 53 91 54 91 55 91 57 91 58 91 59 91 1F 91 FE
0090:91 FF 91 01 98 02 98 03 98 04 98 05 98 07 00 00
00A0:00 09 40 04 40 05 40 03 40 02 40 07 40 01 C1 03
00B0:00 00 00 02 D4 07 D4 06 D4 01 00 00 00 01 38 0A
00C0:00 00 00 01 30 02 30 06 30 0A 30 08 30 01 38 01
00D0:B1 03 B1 02 BF 00 38 0B 43 00 61 00 6E 00 6F 00
00E0:6E 00 20 00 49 00 6E 00 63 00 2E 00 00 00 1C 43
00F0:00 61 00 6E 00 6F 00 6E 00 20 00 45 00 4F 00 53
0100:00 20 00 44 00 49 00 47 00 49 00 54 00 41 00 4C
0110:00 20 00 52 00 45 00 42 00 45 00 4C 00 20 00 58
0120:00 53 00 69 00 00 00 08 33 00 2D 00 31 00 2E 00
0130:31 00 2E 00 30 00 00 00 21 62 00 36 00 32 00 31
0140:00 30 00 66 00 66 00 64 00 31 00 32 00 37 00 39
0150:00 34 00 66 00 32 00 63 00 61 00 33 00 61 00 64
0160:00 32 00 33 00 64 00 31 00 32 00 39 00 36 00 63
0170:00 32 00 31 00 35 00 38 00 00 00
 
 
Std.Ver.:	0x100
Vendor Ext. ID:	0x6(Microsoft)
 
Vend.Ext.Ver.:	0xC8
 
Func.Mode:	0x8C7
 
Operations supported:
 
1014	GetDevicePropDesc
1015	GetDevicePropValue
1016	SetDevicePropValue
1001	GetDeviceInfo
1002	OpenSession
1003	CloseSession
1006	GetNumObjects
1004	GetStorageIDs
9101	EOS_GetStorageIDs
1005	GetStorageInfo
9102	EOS_GetStorageInfo
1007	GetObjectHandles
1008	GetObjectInfo
9103	Vendor defined
1009	GetObject
9104	Vendor defined
100A	GetThumb
101B	GetPartialObject
9107	EOS_GetObject
100C	SendObjectInfo
100D	SendObject
100B	DeleteObject
9105	Vendor defined
100F	FormatStore
9106	Vendor defined
9110	EOS_SetDevicePropValue
9127	Vendor defined
910B	Vendor defined
9108	EOS_GetDeviceInfo
9109	EOS_GetObjectIDs
910C	Vendor defined
910E	Vendor defined
910F	EOS_Capture
9125	Vendor defined
9126	Vendor defined
9115	EOS_SetExtendedEventInfo
9114	EOS_SetPCConnectMode
9113	Vendor defined
9116	EOS_GetEvent
9117	Vendor defined
9120	Vendor defined
91F0	Vendor defined
9118	Vendor defined
9121	Vendor defined
91F1	Vendor defined
911D	Vendor defined
910A	Vendor defined
911B	Vendor defined
911C	Vendor defined
911E	Vendor defined
911A	Vendor defined
9153	EOS_GetLiveViewPicture
9154	Vendor defined
9155	EOS_MoveFocus
9157	Vendor defined
9158	Vendor defined
9159	Vendor defined
911F	Vendor defined
91FE	Vendor defined
91FF	Vendor defined
9801	GetObjectPropsSupported
9802	GetObjectPropDesc
9803	GetObjectPropValue
9804	SetObjectPropValue
9805	GetObjectPropList
 
Events supported:
 
4009	RequestObjectTransfer
4004	StoreAdded
4005	StoreRemoved
4003	ObjectRemoved
4002	ObjectAdded
4007	ObjectInfoChanged
C101	Vendor defined
 
Device properties supported:
 
D402	Device_Friendly_Name
D407	Perceived_Device_Type
D406	Session_Initiator_Version_Info
 
Capture formats:
 
3801	EXIF_JPEG
 
Image Formats:
 
3001	Association
3002	Script
3006	DPOF
300A	AVI
3008	WAV
3801	EXIF_JPEG
B101	Vendor defined
B103	Vendor defined
BF02	Vendor defined
3800	Undefined
 
 
Manufacturer:	Canon Inc.
Model:		Canon EOS DIGITAL REBEL XSi
Device ver.:	3-1.1.0
Serial num.:	b6210ffd12794f2ca3ad23d1296c2158
 
Closing session #: : 0x0001
Session closed.: 0x2001

Modern Canon EOS cameras have function set similar to the one above. However, if we look into older cameras, they give very different output. Below is GetDeviceInfo output from my old trusty Canon 5D. As you can see, it has no resemblance to xSi or 400D. In fact, it looks like Canon Powershot A640 output, which is posted just below this one.

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
Canon 5D
Start
Device configured.: 0x0000
Opening session #: : 0x0001
OpenSession: Session opened.: 0x2001
0000:0B 01 00 00 02 00 01 10 02 00 00 00 01 00 0B 00
0010:00 00 64 00 00 00 00 1D 00 00 00 14 10 15 10 16
0020:10 17 10 01 10 02 10 03 10 13 90 04 10 05 10 06
0030:10 07 10 08 10 09 10 0A 10 1B 10 0C 10 0D 10 0B
0040:10 01 90 02 90 06 90 0E 90 1B 90 1C 90 1E 90 21
0050:90 0F 10 1F 90 16 00 00 00 01 40 02 40 03 40 04
0060:40 05 40 06 40 07 40 08 40 09 40 0A 40 0C 40 0D
0070:40 01 C0 05 C0 06 C0 07 C0 08 C0 09 C0 0A C0 0B
0080:C0 0C C0 0D C0 10 00 00 00 45 D0 02 D0 03 D0 2C
0090:D0 2D D0 49 D0 32 D0 31 D0 34 D0 33 D0 2E D0 2F
00A0:D0 46 D0 47 D0 30 D0 4A D0 01 00 00 00 01 38 08
00B0:00 00 00 02 30 06 30 0A 30 08 30 01 38 01 B1 03
00C0:B1 02 BF 0B 43 00 61 00 6E 00 6F 00 6E 00 20 00
00D0:49 00 6E 00 63 00 2E 00 00 00 0D 43 00 61 00 6E
00E0:00 6F 00 6E 00 20 00 45 00 4F 00 53 00 20 00 35
00F0:00 44 00 00 00 0A 33 00 2D 00 30 00 2E 00 30 00
0100:2E 00 30 00 2E 00 31 00 00 00 00
 
Std.Ver.:       0x1
Vendor Ext. ID: 0xB(Canon)
 
Vend.Ext.Ver.:  0x64
 
Func.Mode:      0x8C7
 
Operations supported:
1014    GetDevicePropDesc
1015    GetDevicePropValue
1016    SetDevicePropValue
1017    ResetDevicePropValue
1001    GetDeviceInfo
1002    OpenSession
1003    CloseSession
9013    PS_CheckEvent
1004    GetStorageIDs
1005    GetStorageInfo
1006    GetNumObjects
1007    GetObjectHandles
1008    GetObjectInfo
1009    GetObject
100A    GetThumb
101B    GetPartialObject
100C    SendObjectInfo
100D    SendObject
100B    DeleteObject
9001    PS_GetObjectSize
9002    Vendor defined
9006    Vendor defined
900E    Vendor defined
901B    PS_GetPartialObject
901C    Vendor defined
901E    Vendor defined
9021    PS_GetFolderEntries
100F    FormatStore
901F    Vendor defined
 
Events supported:
4001    CancelTransaction
4002    ObjectAdded
4003    ObjectRemoved
4004    StoreAdded
4005    StoreRemoved
4006    DevicePropChanged
4007    ObjectInfoChanged
4008    DeviceInfoChanged
4009    RequestObjectTransfer
400A    StoreFull
400C    StorageInfoChanged
400D    CaptureComplete
C001    Vendor defined
C005    Vendor defined
C006    Vendor defined
C007    Vendor defined
C008    Vendor defined
C009    Vendor defined
C00A    Vendor defined
C00B    Vendor defined
C00C    Vendor defined
C00D    Vendor defined
 
Device properties supported:
D045    Vendor defined
D002    Vendor defined
D003    Vendor defined
D02C    Vendor defined
D02D    Vendor defined
D049    Vendor defined
D032    Vendor defined
D031    Vendor defined
D034    Vendor defined
D033    Vendor defined
D02E    Vendor defined
D02F    Vendor defined
D046    Vendor defined
D047    Vendor defined
D030    Vendor defined
D04A    Vendor defined
 
Capture formats:
3801    EXIF_JPEG
 
Image Formats:
3002    Script
3006    DPOF
300A    AVI
3008    WAV
3801    EXIF_JPEG
B101    Vendor defined
B103    Vendor defined
BF02    Vendor defined
 
Manufacturer:   Canon Inc.
Model:          Canon EOS 5D
Device ver.:    3-0.0.0.1
Serial num.:
 
Closing session #: : 0x0001
Session closed.: 0x2001
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
Canon Powershot A640
Start
Device configured.: 0x0000
Opening session #: : 0x0001
OpenSession: Session opened.: 0x2001
0000:AD 01 00 00 02 00 01 10 02 00 00 00 64 00 06 00
0010:00 00 64 00 00 00 00 3E 00 00 00 14 10 15 10 16
0020:10 17 10 01 10 02 10 03 10 13 90 1F 90 04 10 05
0030:10 06 10 07 10 08 10 09 10 0A 10 1B 10 0C 10 0D
0040:10 0B 10 0F 10 12 10 01 90 21 90 1B 90 1E 90 19
0050:90 06 90 1C 90 02 90 2C 90 2D 90 2E 90 24 90 25
0060:90 0E 90 0F 90 10 90 11 90 28 90 23 90 29 90 2A
0070:90 2B 90 34 90 0E 10 08 90 1A 90 09 90 0B 90 1D
0080:90 0D 90 0C 90 14 90 15 90 18 90 12 90 01 98 02
0090:98 03 98 04 98 05 98 1A 00 00 00 01 40 02 40 03
00A0:40 04 40 05 40 06 40 07 40 08 40 09 40 0A 40 0B
00B0:40 0C 40 0D 40 0E 40 01 C0 05 C0 08 C0 09 C0 0A
00C0:C0 0B C0 0C C0 0D C0 0E C0 0F C0 11 C0 13 C0 13
00D0:00 00 00 45 D0 4A D0 2E D0 2F D0 02 D0 03 D0 34
00E0:D0 47 D0 46 D0 2D D0 48 D0 2C D0 30 D0 49 D0 32
00F0:D0 33 D0 31 D0 02 D4 07 D4 01 00 00 00 01 38 08
0100:00 00 00 01 30 02 30 06 30 0A 30 08 30 01 38 01
0110:B1 01 BF 0B 43 00 61 00 6E 00 6F 00 6E 00 20 00
0120:49 00 6E 00 63 00 2E 00 00 00 15 43 00 61 00 6E
0130:00 6F 00 6E 00 20 00 50 00 6F 00 77 00 65 00 72
0140:00 53 00 68 00 6F 00 74 00 20 00 41 00 36 00 34
0150:00 30 00 00 00 0A 31 00 2D 00 33 00 2E 00 32 00
0160:2E 00 31 00 2E 00 30 00 00 00 21 46 00 32 00 31
0170:00 44 00 42 00 35 00 38 00 31 00 44 00 46 00 37
0180:00 44 00 34 00 38 00 30 00 43 00 39 00 41 00 34
0190:00 32 00 33 00 37 00 37 00 39 00 43 00 39 00 38
01A0:00 46 00 33 00 39 00 38 00 32 00 00 00
 
Std.Ver.:       0x100
Vendor Ext. ID: 0x6(Microsoft)
 
Vend.Ext.Ver.:  0x64
 
Func.Mode:      0x8C7
 
Operations supported:
1014    GetDevicePropDesc
1015    GetDevicePropValue
1016    SetDevicePropValue
1017    ResetDevicePropValue
1001    GetDeviceInfo
1002    OpenSession
1003    CloseSession
9013    PS_CheckEvent
901F    Vendor defined
1004    GetStorageIDs
1005    GetStorageInfo
1006    GetNumObjects
1007    GetObjectHandles
1008    GetObjectInfo
1009    GetObject
100A    GetThumb
101B    GetPartialObject
100C    SendObjectInfo
100D    SendObject
100B    DeleteObject
100F    FormatStore
1012    SetObjectProtection
9001    PS_GetObjectSize
9021    PS_GetFolderEntries
901B    PS_GetPartialObject
901E    Vendor defined
9019    Vendor defined
9006    Vendor defined
901C    Vendor defined
9002    Vendor defined
902C    Vendor defined
902D    Vendor defined
902E    Vendor defined
9024    Vendor defined
9025    Vendor defined
900E    Vendor defined
900F    Vendor defined
9010    Vendor defined
9011    Vendor defined
9028    Vendor defined
9023    Vendor defined
9029    Vendor defined
902A    Vendor defined
902B    Vendor defined
9034    Vendor defined
100E    InitiateCapture
9008    PS_StartShootingMode
901A    PS_InitiateCaptureInMemory
9009    PS_EndShootingMode
900B    PS_ViewfinderOn
901D    PS_GetViewfinderImage
900D    PS_ReflectChanges
900C    PS_ViewfinderOff
9014    PS_FocusLock
9015    PS_FocusUnlock
9018    Vendor defined
9012    Vendor defined
9801    GetObjectPropsSupported
9802    GetObjectPropDesc
9803    GetObjectPropValue
9804    SetObjectPropValue
9805    GetObjectPropList
 
Events supported:
4001    CancelTransaction
4002    ObjectAdded
4003    ObjectRemoved
4004    StoreAdded
4005    StoreRemoved
4006    DevicePropChanged
4007    ObjectInfoChanged
4008    DeviceInfoChanged
4009    RequestObjectTransfer
400A    StoreFull
400B    DeviceReset
400C    StorageInfoChanged
400D    CaptureComplete
400E    UnreportedStatus
C001    Vendor defined
C005    Vendor defined
C008    Vendor defined
C009    Vendor defined
C00A    Vendor defined
C00B    Vendor defined
C00C    Vendor defined
C00D    Vendor defined
C00E    Vendor defined
C00F    Vendor defined
C011    Vendor defined
C013    Vendor defined
 
Device properties supported:
D045    Vendor defined
D04A    Vendor defined
D02E    Vendor defined
D02F    Vendor defined
D002    Vendor defined
D003    Vendor defined
D034    Vendor defined
D047    Vendor defined
D046    Vendor defined
D02D    Vendor defined
D048    Vendor defined
D02C    Vendor defined
D030    Vendor defined
D049    Vendor defined
D032    Vendor defined
D033    Vendor defined
D031    Vendor defined
D402    Device_Friendly_Name
D407    Perceived_Device_Type
 
Capture formats:
3801    EXIF_JPEG
 
Image Formats:
3001    Association
3002    Script
3006    DPOF
300A    AVI
3008    WAV
3801    EXIF_JPEG
B101    Vendor defined
BF01    Vendor defined
 
Manufacturer:   Canon Inc.
Model:          Canon PowerShot A640
Device ver.:    1-3.2.1.0
Serial num.:    F21DB581DF7D480C9A423779C98F3982
 
Closing session #: : 0x0001
Session closed.: 0x2001

When analyzing output posted above, we can see that this camera actually supports standard PTP “Initiate Capture” command (100E, line 87) as well as “Capture Complete” event (400D, line 118).

Here is a bonus for those who managed to get to this point – a sketch that performs shutter release on Canon EOS camera. It had been tested on 400D and xSi and will most likely work on cameras with the same 910f EOS_Capture command listed in GetDeviceInfo output. The sketch is available in the PTP examples on github, and copied below for your viewing pleasure:
[EDIT] This code doesn’t work with current PTP/EOS library. The correct code is here

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
/* EOS Capture Example. Works on cameras listed in canoneos.h */
#include <inttypes.h>
#include <avr/pgmspace.h>
 
#include <spi.h>
#include <max3421e.h>
#include <max3421e_constants.h>
#include <max_LCD.h>
#include <usb.h>
 
#include <ptp.h>
#include <canoneos.h>
 
#define DEV_ADDR        1
 
// Canon EOS 400D
#define DATA_IN_EP      1
#define DATA_OUT_EP     2
#define INTERRUPT_EP    3
#define CONFIG_NUM      1
 
#define MAX_USB_STRING_LEN 64
 
void setup();
void loop();
void ptpmain();
 
CanonEOS  Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, (PTPMAIN)&ptpmain);
 
void setup() {
  Serial.begin( 9600 );
  Serial.println("Start");
  Eos.Setup();
  delay( 200 );
}
 
void loop() {
    Eos.Task();
}
 
void ptpmain()
{
    if (Eos.OpenSession() == PTP_RC_OK)
    {
                Eos.Initialize(true);
                Eos.Capture();
                delay(2000);
                Eos.Initialize(false);
		Eos.CloseSession();
    }
}

As you can see, the sketch is quite short for the amount of work it is doing and simple to understand thanks to Alex’s library structure design. Main functionality is presented on lines 41-51 – Open Session, Capture, Close Session. Delay is inserted to give camera time to save captured image; in real life applications it’s necessary to poll camera for “Object Created” event instead.

Due to the amount of material, writing about camera control can be challenging. Many things are much easier to the writer to present rather than explain; presentation style is also easier for the reader to digest. I’m currently working on simple camera controller design consisting of USB Host Shield, LCD display, rotary encoder plus a button or two and will be using it to present ways to use the library in various automatic shooting applications. I’m hoping to finish it in the next week or two, weather permitting, and publish the next program. Stay tuned!

Oleg.

No related posts.

186 comments to Digital camera control using Arduino USB Host Shield. Part 1 – basics.

  • nolan

    Hello all, I’m using an UNO and a sparkfun shield. I am returning this “Start
    Error: OSCOKIRQ failed to assert” in the serial monitor. I know this error is associated with the use of the VIN pin instead of the 5V. I tried connecting the UNO to a 9 volt and I am still returning this error. Could someone post the proper pin set up for this unit. I can see in the forum that some people have incurred this problem and solved it.
    A side note, I already switched the 7 and 8 pin in the code. Thank you for any help in advance.

    • lenny4d

      Had the same problem with the brand new usb2.0 hostboard on my Mega. As I was using the standard config and the board was brand new I knew had to be something simple. After some troubleshooting with a multimeter I found I hadn’t soldered the 3.3V pin well enough and it didn’t get to the board. Fixed it, problem solved, works like a train now :-)

  • karsten

    Hello nolan,

    I had the same error at first due to an insufficient soldering of the headers, if I had to remember I’d say pin 13 in my case …

    • blackhawk1793

      My link between usb shield and arduino pin 13 was damaged.

      The shield could not “assert”. But not always, it seemed to work sometimes, so i searched around and found many people commenting about checking soldering points and link betweend arduino and shield.

      I doubled checked every link and conductivity by moving/touching cables around and all to make sure there was any wasn’t faulty ones only to find that pin 13 was faulty.

      Replaced, connected, turned on and off i was coding at last.

      Thanks Karsten for the reminding us to check our soldering points!!

  • lenny4d

    Awesome work, both the hw and the usb/ptp libraries! Got my usb2.0 board a week ago and started tinkering trying to control my D500 camera for a start. Controlling aperture, mode, shutter etc all fine :-) but struggling with bulb mode, like some others above. Eos.StartBulb() works fine, camera starts taking image in bulb mode. But Eos.StopBulb is just ignored, nothing happens. After this the camera usb interface just hangs, getting errors on getevent etc. Any ideas? How to troubleshoot this?

  • lenny4d

    Following on from prev post – I also got the MoveFocus to work on my D500, as others mentioned I have to turn on Liveview manually. Works with focus switch in Manual or Auto which is good as I normally need Manual. At the smallest step 0×0001 (decreasing focus distance) or 0×8001 (increasing focus distance) on my EFS17-55mm lens it takes about 95 steps from 0.35m to 3m that’s just perfect. I am making timelapses, and this is going to be awesome. Totally awesome. Thanks to Oleg/Alex for the hard work behind the scenes. Now I just need to get Bulb to work and read out the exposure value in some way. This is going to be more difficult.

    • Alex

      Bulb functionality may or may not be available via PTP on EOS cameras such as EOS400D for example. You should check this by running EOSEventLab.pde sketch first and checking shutter speed values. Bulb is 0x0C. All device properties such as shutter speed and aperture are available from EOS cameras as events. When the camera is initialized and events are enabled the first event you receive is a huge bunch of current device property values and their acceptable values or value ranges (you should see EOSCamController sketch for more details). Then you have to monitor device property value changes polling events from the camera. That’s how it works in EOSCamController sketch.

      • lenny4d

        I can set bulb via Eos.SetProperty(EOS_DPC_Shutterspeed,0x0c) allright (in manual mode, lcd display changes to “BULB”) and Eos.StartBulb() starts bulb mode capture, but then I can’t stop it with Eos.StopBulb(). I have not been successfull with EOSEventlab, it hangs the camera after the first big packet (USB Fatal Error). Generally I don’t have any/much success with Eos.Eventcheck. This blog/documentation suggest lots events should be generated after image capture but none in my case (but an image IS taken). I guess it’s just a learning curve :-)

        • Alex

          Unfortunately, I don’t have the same camera at hands to find out what is wrong. There might be either a bug in the code or your camera behaves differently then other Canon models I tried the code on. If you could install Snoopy Pro sniffer and make a dump of USB session during bulb capture with Canon or some other software, properly working with your camera, and send it to me, I would probably find what the problem is and fix the code.

        • My XSi also breaks EOSEventLab. The trick is not to parse this first packet, but start parsing and printing all subsequent packets.

  • lenny4d

    Ok, I made a lot of progress with my D500 – this is all pretty awesome. I added an EOS.EventCheck(NULL) in the startup initialisation (e.g., eventmonitor example) that skipped the first big packet. But it still bombed on changing the mode dial… Later I changed to your eventparser function, which seems more robust, it never bombs. Cool because this gives me access to the settings (I am not great with C++ so would not be able to write this myself). Then in order to get bulb and half-push-release-button to work I had to resort to SnoopyPro usb sniffer to figure what packets the EOS Utility programme sends to the camera for these functions. Since I am a newbie to USB it tok me some time to figure it all out. It’s the out.down packets that need to be studied. From there it was easy, now it works like a train (tested). The code that works for a D500 is below, it’s generates an exact copy of what EOS utility sends to the camera. In canoneos.cpp:

    uint16_t CanonEOS::StartBulb() // tested on D500
    {
    uint32_ params[2];
    params[0] = 0×00000001;
    params[1] = 0×00000002;

    Operation(0×9128, 1, params );
    Operation(0×9128, 1, params+1);

    return PTP_RC_OK;
    }

    uint16_t CanonEOS::StopBulb() // tested on D500
    {
    uint32_t params[1];
    params[0] = 0×00000003;

    Operation(0×9129, 1, params);
    return PTP_RC_OK;
    }

    uint16_t CanonEOS::HalfPush() // tested on D500
    {
    uint32_t params[2];

    params[0] = 0×00000001;
    params[1] = 0×00000000;

    Operation(0×9128, 2, params);
    delay(500);
    Operation(0×9129, 1, params);
    return PTP_RC_OK;
    }

    You will also need to add uint16_t HalfPush() to the CanonEOS class in canoneos.h HalfPush generates an event with the desired aperture (in T mode) or shutterspeed (in A mode). The delay will make the values appear on the LCD of the camera, if you leave it out you get the same response but won’t see the values on the camera’s LCD.

    I hope this is useful to someone. This all very great stuff. Now I will move to getting my Canon G6 to work as well :-)

    ~lenny4d

    • When you change mode dial you’ll get the same large packet again since all property values change (like in Av you don’t have property value for shutter speed). Good find about Event Parser and Bulb settings, I need to check it on my cameras. Let me know if you have any issues with G6.

    • kkbuddy

      Long time ago …. I know. But thanks for sharing this. It works also for Canon EOS 70D. Thanks!

    • kkbuddy

      Hi … were you able to get the Bulb mode running accuratly with bulb duration in the range of ~100ms. I noticed bulb start and stop events timing is not accurate and sometimes it jumps and even misses events. Would be interesting what experience you had on that bulb mode topic?

  • muthm

    Hi oleg – sorry for naive questions but i wanted to get your insight:
    I am trying to do the following:
    Move the focus to a starting position
    Shoot
    Wait for thr shoot to complete (can be worked out by the tv set)
    Move thr focus one step up
    Repeat from shoot until a set focus position
    Wait a set time and repeat fro. Step 1

    I know about the missing ack after the focus move, but i am looking for how i would code this (sry complete new) i use a 5d mk ii

  • Sai

    Hi,

    Is this possible to implement only when the camera is capable for USB based controls?

  • Jason

    I have a few questions….

    1) Anyone have any luck trying to set the ShootingMode property? My 60D always reports back as busy. I am guessing that it’s not possible since the EOSUtility application won’t even allow changing of the mode dial. Do I really have to manually rotate the dial to go between auto and manual?

    2) I can’t seem to get anything back from operation code EOS_OC_GetDevicePropValue on my 60D. Anyone else note this?

    3) When using EOS_OC_GetDeviceInfoEx and PTP_OC_GetDeviceInfo I get two completely different sets of data. The PTP_OC_GetDeviceInfo operation code returns something similar to what you have here ( https://www.circuitsathome.com/?s=60d#EOS60D ) but your canoneos.cpp sends the EOS_OC_GetDeviceInfoEx which returns data nothing like what you report on the page noted above. Can you explain the difference?

    Thanks!

  • Alex

    1) You can set shooting mode on your 60D only by turning mode dial manually.
    2) The only correct way of getting device property value is to obtain it from the first event packet and monitor its changes later checking events. There is a class EOSEventParser in the second version of PTP library written to handle different events, especially events dealing with device properties. Check latest version of EOSRemote sketch to get the idea of how you can use it. If you have questions feel free to ask me.
    3) EOS_OC_GetDeviceInfoEx is the Canon proprietary method of getting device information. It works only for Canon EOS cameras. PTP_OC_GetDeviceInfo is PTP-standard method supported by absolutely every PTP capable camera. I suggest you to use EOS_OC_GetDeviceInfoEx only when it’s absolutely necessary for your application.

    • Jason

      Thank you very much for the prompt response. Your answers are very helpful… unfortunate (with respect to manually turning mode dial) but helpful!

    • Jason

      I just had a thought…

      Is there any exposure metering data contained in events? I am trying to accomplish both manual and automatic exposure control with the EOS series. If I left the dial in manual shooting mode AND I could obtain some exposure metering data then I could intelligently set the exposure settings (f-stop, shutter, iso) in manual mode. Definitely not as good as having control over the shooting mode but a very good workaround for my purposes. Any thoughts?

      • Alex

        It could be true for some newer models. Old EOS cameras, such as EOS 400D, don’t send any exposure metering data in events. I am not sure about 60D because I had no chance to test it with the PTP code. the workaround could be keeping EOS in manual mode while measuring exposure with some extra circuit connected to Arduino and then set the exposure settings programmatically.

  • Jason

    I assume these device property values would be in the canoneos.h file if they were known but I thought I’d ask anyway as they may just not be present because they aren’t commonly used. Any idea what 0xD1D3 and 0xD1C0 represent? They are both device properties changed events (0xC189). They seem to be common after a half push or release event.

    Thanks!

    • Alex

      0xD1D3 seems to represent focus info. About 0xD1C0 I have no idea. I will probably be able to make some assumptions if you send me a dump taken by EOSEventLab or EOSEventMonitor with a short description of what had initiated the event.

  • Karl

    I am currently basing a project of mine with this project as a skeleton.
    When the camera takes a picture acre you able to direct where the photo goes? Like can you command it to save into a specific folder?
    I’m sorry if my question sounds stupid but i am trying to create an interface to be able to view, sort,delete and etc. the photos.

  • meilenstein

    Hi
    Where can I buy this USB-Host-Shield in Europe ? ( Germany )

  • ricky

    hi oleg
    I have read source code of arduino camera control on https://github.com/felis/Arduino_Camera_Control , I cannot find the source code of 3 focus move speed, where is it?
    For example:
    felis-Arduino_Camera_Control-4f5b1bf\examples\EOSFocus\EOSFocus.pde
    row 71 to 81
    if (i > 4)
    Eos.MoveFocus(3); //question: what is the meaning of number 3?
    else
    Eos.MoveFocus(0×8003); //question: what is the meaning of 0×8003?

    Thanks for your reply
    ricky

  • Chris

    Hi Oleg,

    probably you can help me with my problem. I am playing around with arduino controlling my 7D. Communication from Arduino to 7D works great – but in the other direction 7D -> Arduino I have a lot of problems.
    How can I read for example the current Shutterspeed?

    regards
    Chris

  • Geordie

    Can the Arduino controller be used to send real time images to a PC?

    Why? Most simple compact cameras don’t allow live shooting – seeing the image in real time on the PC. Now that the Philips SPC900 webcam is more or less unobtainable, there is a gap in the market of CCD based webcams,for use in astroimaging. But some compact cameras do use CCD imaging chips, so if these cameras could be controlled to send the real time image to a PC it’s a whole new board game.

    • PTP file operations are supported; you can read an image and transfer it via serial port. Not quite real-time though: reading 16MP image into NULL takes 24 sec., sending it out using RN-131 module takes 14 minutes.

  • mikec

    I’m getting errors when compiling PTPDevInfo. I get similar errors when trying other examples too.

    In file included from devinfoparser.cpp:1:
    devinfoparser.h:237: error: expected class-name before ‘{‘ token
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintFunctMode(uint8_t**, uint16_t&)’:
    devinfoparser.cpp:194: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:194: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp:194: error: ‘HEX’ was not declared in this scope
    devinfoparser.cpp: In member function ‘void DevInfoParser::PrintOperation(uint16_t)’:
    devinfoparser.cpp:202: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp:202: error: ‘HEX’ was not declared in this scope
    devinfoparser.cpp:203: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:216: error: ‘PTP_VENDOR_MICROSOFT’ was not declared in this scope
    devinfoparser.cpp:217: error: ‘PTP_VENDOR_CANON’ was not declared in this scope
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintPTPOperation(uint16_t)’:
    devinfoparser.cpp:234: error: ‘PTP_OC_InitiateOpenCapture’ was not declared in this scope
    devinfoparser.cpp:236: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintMTPOperation(uint16_t)’:
    devinfoparser.cpp:244: error: ‘MTP_OC_SendObjectPropList’ was not declared in this scope
    devinfoparser.cpp:245: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:250: error: ‘MTP_OC_GetObjectReferences’ was not declared in this scope
    devinfoparser.cpp:251: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:253: error: ‘MTP_OC_SetObjectReferences’ was not declared in this scope
    devinfoparser.cpp:256: error: ‘MTP_OC_Skip’ was not declared in this scope
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintPSOperation(uint16_t)’:
    devinfoparser.cpp:317: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintEOSOperation(uint16_t)’:
    devinfoparser.cpp:365: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp: In member function ‘void DevInfoParser::PrintEvent(uint16_t)’:
    devinfoparser.cpp:371: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp:371: error: ‘HEX’ was not declared in this scope
    devinfoparser.cpp:372: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:374: error: ‘PTP_EC_UnreportedStatus’ was not declared in this scope
    devinfoparser.cpp:377: error: ‘MTP_EC_ObjectReferencesChanged’ was not declared in this scope
    devinfoparser.cpp: In member function ‘void DevInfoParser::PrintDevProp(uint16_t)’:
    devinfoparser.cpp:386: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp:386: error: ‘HEX’ was not declared in this scope
    devinfoparser.cpp:387: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:389: error: ‘PTP_DPC_CopyrightInfo’ was not declared in this scope
    devinfoparser.cpp:394: error: ‘MTP_DPC_Perceived_Device_Type’ was not declared in this scope
    devinfoparser.cpp:400: error: ‘MTP_DPC_Playback_Rate’ was not declared in this scope
    devinfoparser.cpp:403: error: ‘MTP_DPC_Playback_Object’ was not declared in this scope
    devinfoparser.cpp:406: error: ‘MTP_DPC_Playback_Container’ was not declared in this scope
    devinfoparser.cpp: In member function ‘void DevInfoParser::PrintFormat(uint16_t)’:
    devinfoparser.cpp:422: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp:422: error: ‘HEX’ was not declared in this scope
    devinfoparser.cpp:423: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:425: error: ‘PTP_OFC_QT’ was not declared in this scope
    devinfoparser.cpp:428: error: ‘PTP_OFC_JPX’ was not declared in this scope
    devinfoparser.cpp:434: error: ‘MTP_OFC_Undefined_Firmware’ was not declared in this scope
    devinfoparser.cpp:437: error: ‘MTP_OFC_Windows_Image_Format’ was not declared in this scope
    devinfoparser.cpp:440: error: ‘MTP_OFC_Undefined_Audio’ was not declared in this scope
    devinfoparser.cpp:443: error: ‘MTP_OFC_WMA’ was not declared in this scope
    devinfoparser.cpp:446: error: ‘MTP_OFC_OGG’ was not declared in this scope
    devinfoparser.cpp:449: error: ‘MTP_OFC_AAC’ was not declared in this scope
    devinfoparser.cpp:452: error: ‘MTP_OFC_Audible’ was not declared in this scope
    devinfoparser.cpp:455: error: ‘MTP_OFC_FLAC’ was not declared in this scope
    devinfoparser.cpp:458: error: ‘MTP_OFC_Undefined_Video’ was not declared in this scope
    devinfoparser.cpp:461: error: ‘MTP_OFC_WMV’ was not declared in this scope
    devinfoparser.cpp:464: error: ‘MTP_OFC_MP4_Container’ was not declared in this scope
    devinfoparser.cpp:467: error: ‘MTP_OFC_MP2′ was not declared in this scope
    devinfoparser.cpp:470: error: ‘MTP_OFC_3GP_Container’ was not declared in this scope
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintVendor(uint8_t**, uint16_t&)’:
    devinfoparser.cpp:482: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:483: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp:483: error: ‘HEX’ was not declared in this scope
    devinfoparser.cpp:487: error: ‘PTP_VENDOR_EASTMAN_KODAK’ was not declared in this scope
    devinfoparser.cpp:490: error: ‘PTP_VENDOR_SEIKO_EPSON’ was not declared in this scope
    devinfoparser.cpp:493: error: ‘PTP_VENDOR_AGILENT’ was not declared in this scope
    devinfoparser.cpp:496: error: ‘PTP_VENDOR_POLAROID’ was not declared in this scope
    devinfoparser.cpp:499: error: ‘PTP_VENDOR_AGFA_GEVAERT’ was not declared in this scope
    devinfoparser.cpp:502: error: ‘PTP_VENDOR_MICROSOFT’ was not declared in this scope
    devinfoparser.cpp:505: error: ‘PTP_VENDOR_EQUINOX’ was not declared in this scope
    devinfoparser.cpp:508: error: ‘PTP_VENDOR_VIEWQUEST’ was not declared in this scope
    devinfoparser.cpp:511: error: ‘PTP_VENDOR_STMICROELECTRONICS’ was not declared in this scope
    devinfoparser.cpp:514: error: ‘PTP_VENDOR_NIKON’ was not declared in this scope
    devinfoparser.cpp:517: error: ‘PTP_VENDOR_CANON’ was not declared in this scope
    devinfoparser.cpp:520: error: ‘PTP_VENDOR_FOTONATION’ was not declared in this scope
    devinfoparser.cpp:523: error: ‘PTP_VENDOR_PENTAX’ was not declared in this scope
    devinfoparser.cpp:526: error: ‘PTP_VENDOR_FUJI’ was not declared in this scope
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintString(uint8_t**, uint16_t&)’:
    devinfoparser.cpp:558: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp: At global scope:
    devinfoparser.cpp:563: error: ‘NULL’ was not declared in this scope
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintWordArray(uint8_t**, uint16_t&, void (DevInfoParser::*)(uint16_t))’:
    devinfoparser.cpp:590: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp:590: error: ‘HEX’ was not declared in this scope
    devinfoparser.cpp: In member function ‘virtual void DevInfoParser::Parse(uint16_t, const uint8_t*, const uint32_t&)’:
    devinfoparser.cpp:614: error: ‘Notify’ was not declared in this scope
    devinfoparser.cpp:614: error: ‘Serial’ was not declared in this scope
    devinfoparser.cpp:614: error: ‘DEC’ was not declared in this scope
    devinfoparser.cpp:620: error: ‘HEX’ was not declared in this scope

  • Peter

    Hi
    1. Thanks for this work! I tryed similar functions with ftdi usb host but i was not successfull! :-(
    2. Sorry for my bad english
    3. Have i a question: Is there any code-snippet who shows me how to read an image from the camera to the arduino? Is this a complex code?
    The background of my question: I try to build a wireless webcam with a canon DSLR. The data were transmitted over GPRS to a webserver.

    Thanks and regadrs
    Peter

    • The image can be read using GetObject() method. PTPReadParser *parser is a callback which gets called upon receiving each data packet. You need to skip PTP header ( first 12 bytes ), the rest is your image.

      • Peter

        Now i recived my USB-Shield v2.0 and i made a first test with the example program PTPDevInfo.
        I use Arduino 0022 and have copied the usb and ptp lib from git to my arduino0022/libraries folder. I must rename the lib because of the special caracter in the filename. I opened the PTPDevInfo Sktech via file->Examples an Build it. It give me some errors:

        In file included from C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:18:
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\/SPP.h:109: error: expected ‘,’ or ‘…’ before ‘*’ token
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\/SPP.h:109: error: ISO C++ forbids declaration of ‘__FlashStringHelper’ with no type
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\/SPP.h:115: error: expected ‘,’ or ‘…’ before ‘*’ token
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\/SPP.h:115: error: ISO C++ forbids declaration of ‘__FlashStringHelper’ with no type
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:719: error: expected ‘,’ or ‘…’ before ‘*’ token
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:719: error: ISO C++ forbids declaration of ‘__FlashStringHelper’ with no type
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp: In member function ‘void SPP::print(int)’:
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:720: error: ‘ifsh’ was not declared in this scope
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp: At global scope:
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:756: error: expected ‘,’ or ‘…’ before ‘*’ token
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:756: error: ISO C++ forbids declaration of ‘__FlashStringHelper’ with no type
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp: In member function ‘void SPP::println(int)’:
        C:\Users\Peter\Documents\Arduino\arduino22\arduino22\libraries\USB\SPP.cpp:757: error: ‘ifsh’ was not declared in this scope

        I’m new with the arduino but have some experience with avr and arm cortex m3, programming with avr studio and keil. I don’t like the arduino IDE until this moment ;-)

        Is this a knwon error or have i lost to install/do something?

        Thanks and greez
        Peter

  • rogier

    Hi Oleg,

    When i try to compile the program i get the following errors
    I have tried almost all examples but all give problems.
    Can you tell me what i do wrong?

    In file included from EOSEventLab.cpp:19:
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:77: error: expected class-name before ‘{‘ token
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:79: error: ‘PTP’ has not been declared
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:83: error: expected class-name before ‘{‘ token
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:94: error: expected class-name before ‘{‘ token
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:130: error: ‘PTPStateHandlers’ has not been declared
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:143: error: ‘PTPReadParser’ has not been declared
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:145: error: ‘PTPReadParser’ has not been declared
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:148: error: ‘PTPReadParser’ has not been declared
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:152: error: ‘PTPReadParser’ has not been declared
    In file included from /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:22,
    from EOSEventLab.cpp:20:
    /Users/user/Documents/Arduino/libraries/PTP/ptpcallback.h:38: error: expected initializer before ‘<' token
    In file included from EOSEventLab.cpp:20:
    /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:38: error: 'MultiByteValueParser' does not name a type
    /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:39: error: 'MultiValueBuffer' does not name a type
    /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h: In constructor 'EOSEventDump::EOSEventDump()':
    /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:43: error: 'valueBuffer' was not declared in this scope
    /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h: In member function 'void EOSEventDump::Initialize()':
    /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:44: error: 'valueParser' was not declared in this scope
    /Users/user/Documents/Arduino/libraries/PTP/eoseventdump.h:44: error: 'valueBuffer' was not declared in this scope
    EOSEventLab.cpp: At global scope:
    EOSEventLab.pde:-1: error: 'PTP' has not been declared
    EOSEventLab.pde:-1: error: 'PTP' has not been declared
    EOSEventLab.pde:-1: error: 'PTPStateHandlers' has not been declared
    EOSEventLab.cpp: In member function 'virtual uint8_t CanonEos::Poll()':
    EOSEventLab.pde:-1: error: 'PTP' has not been declared
    EOSEventLab.pde:-1: error: no matching function for call to 'CanonEos::EventCheck(EOSEventDump*)'
    /Users/user/Documents/Arduino/libraries/PTP/canoneos.h:152: note: candidates are: virtual uint16_t CanonEOS::EventCheck(int*)
    EOSEventLab.cpp: At global scope:
    EOSEventLab.pde:-1: error: 'USBHub' does not name a type
    EOSEventLab.pde:-1: error: no matching function for call to 'CanonEos::CanonEos(USB*, CamStateHandlers*)'
    EOSEventLab.cpp:44: note: candidates are: CanonEos::CanonEos(USB*, int*)
    EOSEventLab.cpp:38: note: CanonEos::CanonEos(const CanonEos&)
    EOSEventLab.pde:-1: error: variable or field 'OnDeviceDisconnectedState' declared void
    EOSEventLab.pde:-1: error: 'PTP' was not declared in this scope
    EOSEventLab.pde:-1: error: 'ptp' was not declared in this scope

  • Dan

    Oleg,

    I am currently in the design phase of a project where data is taken from the human eye and read into a computer. These outputs are then to be analyzed and sent to a camera to adjust the ISO (exposure) setting. As well as change the focal points based on iris tracking. Everything up to giving commands to a camera has worked very well. We had assumed that telling a camera to change ISO to 400 and move the focal point 3 mm left would be easy… learning now not so much.

    With your knowledge I am wondering if it is possible to use what methods you have shown here to send these commands to a camera (digital, canon).

    Thanks,

    Dan

    • Which Canon? Most (relatively) modern EOS and some Powershots support what you need controlling. In the ‘examples’ directory there are examples, called EOSRemote and PSRemote, which demonstrate changing ISO, among other things. I remember seeing a property for focus point but I can’t find it at the moment – try asking on gphoto mailing list or find it yourself.

  • Oliver

    Hello there!
    Great work!!

    I´m trying to compile the given exmples of the ptp2 lib but with no success. I´ve got an Arduino Duemilanove and an Tinyos USB shield. After finding (hopefully) all relevant libs, I got follwoing errors. Would be great if someone could give me a hint! Thanks a lot for your great work! Compiling the “EOSFocus” sketch gives me this for example:
    In file included from C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\/ptpdebug.h:24,
    from C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:18:
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\/../USBHost/message.h: In function ‘void ErrorMessage(const char*, ERROR_TYPE)’:
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\/../USBHost/message.h:31: warning: only initialized variables can be placed into program memory area
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\/../USBHost/message.h:33: warning: only initialized variables can be placed into program memory area
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp: At global scope:
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:20: error: ‘MultiByteValueParser’ has not been declared
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp: In function ‘bool Parse(uint8_t**, uint16_t*)’:
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:22: error: ‘pBuf’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:24: warning: only initialized variables can be placed into program memory area
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:27: error: ‘countDown’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:28: error: ‘pBuf’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:28: error: ‘valueSize’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:30: error: ‘countDown’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:33: error: ‘countDown’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:33: error: ‘valueSize’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp: At global scope:
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:37: error: ‘PTPListParser’ has not been declared
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:37: error: ‘PTP_ARRAY_EL_FUNC’ has not been declared
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp: In function ‘bool Parse(uint8_t**, uint16_t*, int, const void*)’:
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:39: error: ‘nStage’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:42: error: ‘pBuf’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:42: error: ‘lenSize’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:43: error: ‘theParser’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:50: error: ‘arLen’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:52: error: ‘arLenCntdn’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:56: error: ‘valSize’ was not declared in this scope
    C:\Users\SpeedLine Rocket\Desktop\arduino-1.0.1\libraries\ptp2\ptpcallback.cpp:67: error: ‘pf’ cannot be used as a function

    Thanks for help..!

    cheers,
    oliver

  • Peter

    Hello Oleg

    Still i try to read out a image from the camera. I tryed a lot, made pictures and compared the outputs, produced usb-errors and so on…
    First i don’t realy now, how to use GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser). Therefor need an object_id.
    The output of the PTPObjectHandles without any pic on the camera (5dMkII) is:

    00000000: 1C 00 00 00 02 00 07 10 02 00 00 00 03 00 00 00
    00000010: 00 00 00 50 00 00 90 51 00 00 08 60
    0 D5D5D5D5
    1 D5D5D5D5
    2 D5D5D5D5

    I know:
    1. 4 Bytes are the total-lenght of the data-packet.
    2. 4 Bytes
    3. 4 Byets
    4. 4 Bytes are the number of objects on the camera (Seams to bee 3)
    5. 4 Bytes
    6. 4 Bytes
    7. 4 Bytes have already the same value

    The output with one picture on the camera is:
    00000000: 20 00 00 00 02 00 07 10 02 00 00 00 04 00 00 00
    00000010: 00 00 00 50 00 00 90 51 B2 73 90 51 00 00 08 60

    0 D5D5D5D5
    1 D5D5D5D5
    2 D5D5D5D5
    3 D5D5D5D5

    Also one Object (=the picture) more. Now which one is the object_id? Or is the id not visible on this output?

    Second: What ist the parent_id?
    Third: Confusion with the PTPReadParser. This is a pionter to a function which process the returning data?!? Can i create an function like the PTPObjHandleParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset)? whitch contain:
    len = length of the retuning datas
    *pbuf = Pointer to the data
    &offset = 12 (PTP-header)?

    Sorry for this (dummy)-questions. I have experience with c but not really c++. I know the idea behind oop, but there are a lot of classes.
    Am i on the right way?
    Thanks for help

    Peter

    PS: I can you deliver PTP-Outputs of G1X and 1dMkIIn for compelment the supported cameralists

    • Image on a camera are accessed by so-called ‘handles’. You can get a handle of an image after a shot if you’re monitoring camera events or you can get a list of handles by issuing GetObjectHandles(). Then you call GetObject() with this handle as a parameter. Here is an example which extracts handles from a camera -> https://github.com/felis/PTP_2.0/tree/master/examples/ptpsketches/PTPObjectHandles. There is also a simpler example below.

      Almost any command output from a camera is too big to store on Arduino, therefore it needs to be processed on the fly. A parser is called on each packet received. For example, this is the minimal parser for GetObjectHandles():

      class PTPObjIndexParser : public PTPReadParser {
        uint32_t idx;     //number of elements in object array
        uint32_t hdl;  //handle of the first object
      public:
        PTPObjIndexParser() : idx(0){};
        uint32_t GetIdx();
        uint32_t GetHandle();
        virtual void Parse(const uint16_t len, const uint8_t* pbuf, const uint32_t &offset);
      };
       
       
      void PTPObjIndexParser::Parse(const uint16_t len, const uint8_t* pbuf, const uint32_t &offset)
      {
        uint8_t* p = (uint8_t*)pbuf + 12;  //end of PTP header
        if( offset == 0 ) {
          idx = *((uint32_t* )p);
          hdl = *((uint32_t* )p+4);
        }
      }
       
      uint32_t PTPObjIndexParser::GetIdx()
      {
        return idx;
      }
       
      uint32_t PTPObjIndexParser::GetHandle()
      {
        return hdl;
      }

      It skips first 12 bytes, then stores next 4 bytes as an index (number of objects ), then stores next 4 bytes as a handle of the first file, then skips the rest of the response.

      A parser for GetObject() is trivial. You need to skip first 12 bytes, the rest is your image. Also, if you are sending your file somewhere, you can just transfer all GetObject() output and process it on the receiving end.

      • Peter

        Hello Oleg
        I heave already a little question: Is there any possibility to capture a image whitout the canoneos.h files?

        The background of my question is:
        I can read the objects on the camera, readout the image with the ptp-functions (PTP Ptp(&Usb, &CamStates);) But when i try the same with the canoneos-functions (CanonEOS Eos(&Usb, &CamStates);) i can’t read the image form the camerea. In the function CanonEOS::GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser) is an additional parameter parent_id. I read the object info with PTPObjInfo and see the parameter “parent object”. But with this 32bit value as parent id in CanonEOS::GetObject i don’t became any response form the camera.

        Or: must i adapt my h-file of the parser and include the eos.h file there

        My ptpgetobjectparser.h:

        #ifndef __PTPGETOBJECTPARSER_H__
        #define __PTPGETOBJECTPARSER_H__

        #include
        #include
        #include

        class PTPGetObjectParser : public PTPReadParser {
        uint32_t idx; //number of elements in object array
        uint32_t hdl; //handle of the first object
        public:
        PTPGetObjectParser() : idx(0){};
        uint32_t GetIdx();
        uint32_t GetHandle();
        virtual void Parse(const uint16_t len, const uint8_t* pbuf, const uint32_t &offset);
        };

        #endif // __PTPGETOBJECTPARSER_H__

        My ptpgetobjectparser.cpp:

        #include "ptpgetobjectparser.h"

        void PTPGetObjectParser::Parse(const uint16_t len, const uint8_t* pbuf, const uint32_t &offset)
        {
        uint8_t* p = (uint8_t*)pbuf + 12; //end of PTP header
        char c_out[4];
        int start;
        if( offset == 0 )
        {
        idx = *((uint32_t* )p);
        hdl = *((uint32_t* )p+4);
        start = 12;
        }else
        {
        start = 0;
        }

        for(int i=start;i<len;i++)
        {
        sprintf(c_out, "%02X" , pbuf[i]);
        Serial.print(c_out);
        }
        }

        uint32_t PTPGetObjectParser::GetIdx()
        {
        return idx;
        }

        uint32_t PTPGetObjectParser::GetHandle()
        {
        return hdl;
        }

        • Peter

          Sometime it helps to describe the problem:
          I can use the ptp and eso funcions at the same time wehn i start it with: CanonEOS Eos(&Usb, &CamStates);
          The read-out of the image takes several seconds to start! Maybe was my patience to little…

          Sorry for spam! ;-)
          greez Peter

  • Peter

    Hello Oleg
    Thanks a million for your help!
    I have transvered the first image from the camera to my pc (for the first test). I take a picture with the smallest resolution and compression. The picture is about 800kB and the transmission take over 2 min @ 115200 but it works.

    Peter

    • You may want to use GetThumb() instead of GetObject() to send the thumbnail, it is much smaller in size.

    • Rob

      Peter is there anyway you could past your code to transfer the image from the camera to the pc? You guys are much better at this coding than I am. So far I can take the images remotely but can not see what I’m taking from the PC.

    • Rob

      I can run the code that Oleg pointed to and I do get lots of numbers on the Arduino terminal but I’m not sure if that is the picture data and if it is I dont know how to save it as a jpg file and view it on my PC.

      • Peter

        It seems to be the image! :-)
        Can you open the orginal image with a hex-viewer? Then you compare the numbers in the therminal with the image. You should send the image with Serial.print(…,HEX), then it’s easy to compare!

  • Vincent

    Hi there,

    just got my usb shield.
    but when trying to compile a lot of errrors occur:

    In file included from T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptp.h:28,
    from EOSCapture.pde:43:
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptpcallback.h:22:22: error: WProgram.h: No such file or directory
    In file included from EOSCapture.pde:29:
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:75: error: multiple definition of ‘enum LED’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:21: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:76: error: conflicting declaration ‘LED1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:22: error: ‘LED1′ has a previous declaration as ‘LED LED1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:77: error: conflicting declaration ‘LED2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:23: error: ‘LED2′ has a previous declaration as ‘LED LED2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:78: error: conflicting declaration ‘LED3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:24: error: ‘LED3′ has a previous declaration as ‘LED LED3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:79: error: conflicting declaration ‘LED4′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:25: error: ‘LED4′ has a previous declaration as ‘LED LED4′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:81: error: conflicting declaration ‘LED5′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:27: error: ‘LED5′ has a previous declaration as ‘LED LED5′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:82: error: conflicting declaration ‘LED6′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:28: error: ‘LED6′ has a previous declaration as ‘LED LED6′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:83: error: conflicting declaration ‘LED7′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:29: error: ‘LED7′ has a previous declaration as ‘LED LED7′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:84: error: conflicting declaration ‘LED8′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:30: error: ‘LED8′ has a previous declaration as ‘LED LED8′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:85: error: conflicting declaration ‘LED9′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:31: error: ‘LED9′ has a previous declaration as ‘LED LED9′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:86: error: conflicting declaration ‘LED10′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:32: error: ‘LED10′ has a previous declaration as ‘LED LED10′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:89: error: multiple definition of ‘enum Button’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:47: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:90: error: conflicting declaration ‘LEFT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:55: error: ‘LEFT’ has a previous declaration as ‘Button LEFT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:91: error: conflicting declaration ‘RIGHT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:53: error: ‘RIGHT’ has a previous declaration as ‘Button RIGHT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:92: error: conflicting declaration ‘DOWN’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:54: error: ‘DOWN’ has a previous declaration as ‘Button DOWN’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:93: error: conflicting declaration ‘UP’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:52: error: ‘UP’ has a previous declaration as ‘Button UP’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:106: error: multiple definition of ‘enum AnalogHat’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:91: error: previous definition here
    In file included from EOSCapture.pde:30:
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:55: error: multiple definition of ‘enum LED’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:21: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:57: error: conflicting declaration ‘LED1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:22: error: ‘LED1′ has a previous declaration as ‘LED LED1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:58: error: conflicting declaration ‘LED2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:23: error: ‘LED2′ has a previous declaration as ‘LED LED2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:59: error: conflicting declaration ‘LED3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:24: error: ‘LED3′ has a previous declaration as ‘LED LED3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:60: error: conflicting declaration ‘LED4′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:25: error: ‘LED4′ has a previous declaration as ‘LED LED4′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:69: error: multiple definition of ‘enum Button’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:47: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:70: error: conflicting declaration ‘L1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:59: error: ‘L1′ has a previous declaration as ‘Button L1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:71: error: conflicting declaration ‘R1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:60: error: ‘R1′ has a previous declaration as ‘Button R1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:75: error: conflicting declaration ‘A’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:99: error: ‘A’ has a previous declaration as ‘Button A’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:76: error: conflicting declaration ‘B’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:98: error: ‘B’ has a previous declaration as ‘Button B’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:80: error: conflicting declaration ‘UP’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:52: error: ‘UP’ has a previous declaration as ‘Button UP’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:81: error: conflicting declaration ‘DOWN’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:54: error: ‘DOWN’ has a previous declaration as ‘Button DOWN’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:82: error: conflicting declaration ‘LEFT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:55: error: ‘LEFT’ has a previous declaration as ‘Button LEFT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:83: error: conflicting declaration ‘RIGHT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:53: error: ‘RIGHT’ has a previous declaration as ‘Button RIGHT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:85: error: conflicting declaration ‘START’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:51: error: ‘START’ has a previous declaration as ‘Button START’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:87: error: conflicting declaration ‘L3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:49: error: ‘L3′ has a previous declaration as ‘Button L3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:88: error: conflicting declaration ‘R3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:50: error: ‘R3′ has a previous declaration as ‘Button R3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:91: error: conflicting declaration ‘L2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:57: error: ‘L2′ has a previous declaration as ‘Button L2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:92: error: conflicting declaration ‘R2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:58: error: ‘R2′ has a previous declaration as ‘Button R2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:94: error: multiple definition of ‘enum AnalogHat’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:91: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:95: error: conflicting declaration ‘LeftHatX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:93: error: ‘LeftHatX’ has a previous declaration as ‘AnalogHat LeftHatX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:96: error: conflicting declaration ‘LeftHatY’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:94: error: ‘LeftHatY’ has a previous declaration as ‘AnalogHat LeftHatY’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:97: error: conflicting declaration ‘RightHatX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:95: error: ‘RightHatX’ has a previous declaration as ‘AnalogHat RightHatX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:98: error: conflicting declaration ‘RightHatY’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:96: error: ‘RightHatY’ has a previous declaration as ‘AnalogHat RightHatY’
    In file included from EOSCapture.pde:31:
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:56: error: multiple definition of ‘enum LED’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:21: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:57: error: conflicting declaration ‘ALL’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:56: error: ‘ALL’ has a previous declaration as ‘LED ALL’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:58: error: conflicting declaration ‘LED1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:22: error: ‘LED1′ has a previous declaration as ‘LED LED1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:59: error: conflicting declaration ‘LED2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:23: error: ‘LED2′ has a previous declaration as ‘LED LED2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:60: error: conflicting declaration ‘LED3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:24: error: ‘LED3′ has a previous declaration as ‘LED LED3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:61: error: conflicting declaration ‘LED4′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:25: error: ‘LED4′ has a previous declaration as ‘LED LED4′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:63: error: multiple definition of ‘enum LEDMode’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:62: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:64: error: conflicting declaration ‘ROTATING’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:63: error: ‘ROTATING’ has a previous declaration as ‘LEDMode ROTATING’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:65: error: conflicting declaration ‘FASTBLINK’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:64: error: ‘FASTBLINK’ has a previous declaration as ‘LEDMode FASTBLINK’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:66: error: conflicting declaration ‘SLOWBLINK’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:65: error: ‘SLOWBLINK’ has a previous declaration as ‘LEDMode SLOWBLINK’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:67: error: conflicting declaration ‘ALTERNATING’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:66: error: ‘ALTERNATING’ has a previous declaration as ‘LEDMode ALTERNATING’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:70: error: multiple definition of ‘enum Button’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:47: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:72: error: conflicting declaration ‘UP’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:52: error: ‘UP’ has a previous declaration as ‘Button UP’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:73: error: conflicting declaration ‘DOWN’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:54: error: ‘DOWN’ has a previous declaration as ‘Button DOWN’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:74: error: conflicting declaration ‘LEFT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:55: error: ‘LEFT’ has a previous declaration as ‘Button LEFT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:75: error: conflicting declaration ‘RIGHT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:53: error: ‘RIGHT’ has a previous declaration as ‘Button RIGHT’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:77: error: conflicting declaration ‘START’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:51: error: ‘START’ has a previous declaration as ‘Button START’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:78: error: conflicting declaration ‘BACK’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:86: error: ‘BACK’ has a previous declaration as ‘Button BACK’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:79: error: conflicting declaration ‘L3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:49: error: ‘L3′ has a previous declaration as ‘Button L3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:80: error: conflicting declaration ‘R3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:50: error: ‘R3′ has a previous declaration as ‘Button R3′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:82: error: conflicting declaration ‘L1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:59: error: ‘L1′ has a previous declaration as ‘Button L1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:83: error: conflicting declaration ‘R1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:60: error: ‘R1′ has a previous declaration as ‘Button R1′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:84: error: conflicting declaration ‘XBOX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:72: error: ‘XBOX’ has a previous declaration as ‘Button XBOX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:86: error: conflicting declaration ‘A’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:99: error: ‘A’ has a previous declaration as ‘Button A’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:87: error: conflicting declaration ‘B’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/Wii.h:98: error: ‘B’ has a previous declaration as ‘Button B’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:88: error: conflicting declaration ‘X’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:77: error: ‘X’ has a previous declaration as ‘Button X’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:89: error: conflicting declaration ‘Y’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXRECV.h:78: error: ‘Y’ has a previous declaration as ‘Button Y’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:92: error: conflicting declaration ‘L2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:57: error: ‘L2′ has a previous declaration as ‘Button L2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:93: error: conflicting declaration ‘R2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:58: error: ‘R2′ has a previous declaration as ‘Button R2′
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:95: error: multiple definition of ‘enum AnalogHat’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:91: error: previous definition here
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:96: error: conflicting declaration ‘LeftHatX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:93: error: ‘LeftHatX’ has a previous declaration as ‘AnalogHat LeftHatX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:97: error: conflicting declaration ‘LeftHatY’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:94: error: ‘LeftHatY’ has a previous declaration as ‘AnalogHat LeftHatY’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:98: error: conflicting declaration ‘RightHatX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:95: error: ‘RightHatX’ has a previous declaration as ‘AnalogHat RightHatX’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/XBOXUSB.h:99: error: conflicting declaration ‘RightHatY’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/PS3Enums.h:96: error: ‘RightHatY’ has a previous declaration as ‘AnalogHat RightHatY’
    In file included from T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptp.h:28,
    from EOSCapture.pde:43:
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptpcallback.h:31: error: redefinition of ‘struct MultiValueBuffer’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/parsetools.h:33: error: previous definition of ‘struct MultiValueBuffer’
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptpcallback.h:37: error: redefinition of ‘class MultiByteValueParser’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/parsetools.h:39: error: previous definition of ‘class MultiByteValueParser’
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptpcallback.h:57: error: redefinition of ‘class ByteSkipper’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/parsetools.h:59: error: previous definition of ‘class ByteSkipper’
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptpcallback.h:92: error: redefinition of ‘class PTPListParser’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/parsetools.h:94: error: previous definition of ‘class PTPListParser’
    In file included from T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptp.h:29,
    from EOSCapture.pde:43:
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptpdebug.h:28: error: redefinition of ‘template void PrintHex(T)’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/printhex.h:27: error: ‘template void PrintHex(T)’ previously declared here
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptpdebug.h:43: error: redefinition of ‘template void PrintHex2(Print*, T)’
    T:\download\ARDUINO\arduino-1.0.2\libraries\USBShield2/printhex.h:42: error: ‘template void PrintHex2(Print*, T)’ previously declared here
    In file included from EOSCapture.pde:43:
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptp.h:86: error: ‘EP_RECORD’ does not name a type
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptp.h: In member function ‘void PTP::Setup()’:
    T:\download\ARDUINO\arduino-1.0.2\libraries\CameraControl/ptp.h:124: error: ‘class MAX3421E’ has no member named ‘powerOn’

    • Vincent

      Sorry for the spaming :)

      So i am on windows 7 and using the arduino software 1.0.2
      with arduino UNO + USB Shield R2

      Looks like i am doing something completly wrong!
      I could really need some help.

      Cheers,
      Vincent

    • It seems you have several copies of the libraries installed. You may only have one.

      • Vincent

        hi oleg,
        sorry for my late replay.
        i do not think i have multiple copies of the libraries.

        but here is step by step what i did:

        I downloaded the
        USB_Host_Shield_2.0-master.zip
        and
        Arduino_Camera_Control-master.zip

        then i unpacked the two zips in
        arduino-1.0.2\libraries

        renamed the folders (made them shorter and without “.”)

        i start the arduino software and choose from the examples/CameraContro/PTPDevInfo

        when i try to verify a big bunch of errors occur

        “”"”"”"”"”"”"”"”"”"”"”"”"”"

        In file included from devinfoparser.cpp:1:
        devinfoparser.h:238: error: expected class-name before ‘{‘ token
        devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintFunctMode(uint8_t**, uint16_t&)’:
        devinfoparser.cpp:195: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:195: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp:195: error: ‘HEX’ was not declared in this scope
        devinfoparser.cpp: In member function ‘void DevInfoParser::PrintOperation(uint16_t)’:
        devinfoparser.cpp:203: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp:203: error: ‘HEX’ was not declared in this scope
        devinfoparser.cpp:204: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:217: error: ‘PTP_VENDOR_MICROSOFT’ was not declared in this scope
        devinfoparser.cpp:218: error: ‘PTP_VENDOR_CANON’ was not declared in this scope
        devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintPTPOperation(uint16_t)’:
        devinfoparser.cpp:235: error: ‘PTP_OC_InitiateOpenCapture’ was not declared in this scope
        devinfoparser.cpp:237: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintMTPOperation(uint16_t)’:
        devinfoparser.cpp:245: error: ‘MTP_OC_SendObjectPropList’ was not declared in this scope
        devinfoparser.cpp:246: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:251: error: ‘MTP_OC_GetObjectReferences’ was not declared in this scope
        devinfoparser.cpp:252: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:254: error: ‘MTP_OC_SetObjectReferences’ was not declared in this scope
        devinfoparser.cpp:257: error: ‘MTP_OC_Skip’ was not declared in this scope
        devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintPSOperation(uint16_t)’:
        devinfoparser.cpp:318: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintEOSOperation(uint16_t)’:
        devinfoparser.cpp:366: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp: In member function ‘void DevInfoParser::PrintEvent(uint16_t)’:
        devinfoparser.cpp:372: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp:372: error: ‘HEX’ was not declared in this scope
        devinfoparser.cpp:373: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:375: error: ‘PTP_EC_UnreportedStatus’ was not declared in this scope
        devinfoparser.cpp:378: error: ‘MTP_EC_ObjectReferencesChanged’ was not declared in this scope
        devinfoparser.cpp: In member function ‘void DevInfoParser::PrintDevProp(uint16_t)’:
        devinfoparser.cpp:387: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp:387: error: ‘HEX’ was not declared in this scope
        devinfoparser.cpp:388: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:390: error: ‘PTP_DPC_CopyrightInfo’ was not declared in this scope
        devinfoparser.cpp:395: error: ‘MTP_DPC_Perceived_Device_Type’ was not declared in this scope
        devinfoparser.cpp:401: error: ‘MTP_DPC_Playback_Rate’ was not declared in this scope
        devinfoparser.cpp:404: error: ‘MTP_DPC_Playback_Object’ was not declared in this scope
        devinfoparser.cpp:407: error: ‘MTP_DPC_Playback_Container’ was not declared in this scope
        devinfoparser.cpp: In member function ‘void DevInfoParser::PrintFormat(uint16_t)’:
        devinfoparser.cpp:423: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp:423: error: ‘HEX’ was not declared in this scope
        devinfoparser.cpp:424: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:426: error: ‘PTP_OFC_QT’ was not declared in this scope
        devinfoparser.cpp:429: error: ‘PTP_OFC_JPX’ was not declared in this scope
        devinfoparser.cpp:435: error: ‘MTP_OFC_Undefined_Firmware’ was not declared in this scope
        devinfoparser.cpp:438: error: ‘MTP_OFC_Windows_Image_Format’ was not declared in this scope
        devinfoparser.cpp:441: error: ‘MTP_OFC_Undefined_Audio’ was not declared in this scope
        devinfoparser.cpp:444: error: ‘MTP_OFC_WMA’ was not declared in this scope
        devinfoparser.cpp:447: error: ‘MTP_OFC_OGG’ was not declared in this scope
        devinfoparser.cpp:450: error: ‘MTP_OFC_AAC’ was not declared in this scope
        devinfoparser.cpp:453: error: ‘MTP_OFC_Audible’ was not declared in this scope
        devinfoparser.cpp:456: error: ‘MTP_OFC_FLAC’ was not declared in this scope
        devinfoparser.cpp:459: error: ‘MTP_OFC_Undefined_Video’ was not declared in this scope
        devinfoparser.cpp:462: error: ‘MTP_OFC_WMV’ was not declared in this scope
        devinfoparser.cpp:465: error: ‘MTP_OFC_MP4_Container’ was not declared in this scope
        devinfoparser.cpp:468: error: ‘MTP_OFC_MP2′ was not declared in this scope
        devinfoparser.cpp:471: error: ‘MTP_OFC_3GP_Container’ was not declared in this scope
        devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintVendor(uint8_t**, uint16_t&)’:
        devinfoparser.cpp:483: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:484: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp:484: error: ‘HEX’ was not declared in this scope
        devinfoparser.cpp:488: error: ‘PTP_VENDOR_EASTMAN_KODAK’ was not declared in this scope
        devinfoparser.cpp:491: error: ‘PTP_VENDOR_SEIKO_EPSON’ was not declared in this scope
        devinfoparser.cpp:494: error: ‘PTP_VENDOR_AGILENT’ was not declared in this scope
        devinfoparser.cpp:497: error: ‘PTP_VENDOR_POLAROID’ was not declared in this scope
        devinfoparser.cpp:500: error: ‘PTP_VENDOR_AGFA_GEVAERT’ was not declared in this scope
        devinfoparser.cpp:503: error: ‘PTP_VENDOR_MICROSOFT’ was not declared in this scope
        devinfoparser.cpp:506: error: ‘PTP_VENDOR_EQUINOX’ was not declared in this scope
        devinfoparser.cpp:509: error: ‘PTP_VENDOR_VIEWQUEST’ was not declared in this scope
        devinfoparser.cpp:512: error: ‘PTP_VENDOR_STMICROELECTRONICS’ was not declared in this scope
        devinfoparser.cpp:515: error: ‘PTP_VENDOR_NIKON’ was not declared in this scope
        devinfoparser.cpp:518: error: ‘PTP_VENDOR_CANON’ was not declared in this scope
        devinfoparser.cpp:521: error: ‘PTP_VENDOR_FOTONATION’ was not declared in this scope
        devinfoparser.cpp:524: error: ‘PTP_VENDOR_PENTAX’ was not declared in this scope
        devinfoparser.cpp:527: error: ‘PTP_VENDOR_FUJI’ was not declared in this scope
        devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintString(uint8_t**, uint16_t&)’:
        devinfoparser.cpp:559: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp: At global scope:
        devinfoparser.cpp:564: error: ‘NULL’ was not declared in this scope
        devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintWordArray(uint8_t**, uint16_t&, void (DevInfoParser::*)(uint16_t))’:
        devinfoparser.cpp:591: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp:591: error: ‘HEX’ was not declared in this scope
        devinfoparser.cpp: In member function ‘virtual void DevInfoParser::Parse(uint16_t, const uint8_t*, const uint32_t&)’:
        devinfoparser.cpp:615: error: ‘Notify’ was not declared in this scope
        devinfoparser.cpp:615: error: ‘Serial’ was not declared in this scope
        devinfoparser.cpp:615: error: ‘DEC’ was not declared in this scope
        devinfoparser.cpp:621: error: ‘HEX’ was not declared in this scope

        “”"”"”"”"”"”"”"”"”"”"”"”"”"”

        i bet i am doing something completly wrong
        i have an eos 550D.
        and i also do not get what to do with this:
        http://www.circuitsathome.com/ptpusb-control-camera-data#EOS550D

        i thought this all would be easier :)

        if anybody wants to help me:
        vincent.langer@filmakademie.de

        thanks and cheers,
        Vincent

  • Maciej

    Hi oleg,
    I want to make an open source DSLR Controller Android app for Canon DSLR’s but for my needs I want it to be working wirelessly via WiFi (I suppose BT isn’t fast enough). One of the main features is obviously LiveView image. I never tried USB Host Shield with Arduino to control my camera (Canon 550D) via PTP. I must add that this is for my engineering thesis project.
    Platforms of my choice are Arduino and Android. I need to submit my topic ASAP so my question is (I don’t have time to make tests myself) – would it be possible to get liveview image with Arduino and pass it via WiFi shield? I believe you haven’t tried it but maybe you can predict it basing on your knowledge…

    Thanks in advance,
    Maciej

    • You can get data of any size out of a camera using Arduino, the question is how fast you need it. I used to transfer 10Mb pictures at a pace of about 0.5mb/min via serial to WiFi interface by Roving Networks. LiveView frame is ~250Kb, you will need ~30sec to transfer it.

      Numbers are from memory.

  • Maciej

    So the bottle neck was serial transfer to WiFi module? It gives me an idea that Arduino is not convinient for this project. I should try something more powerful and advanced like Raspberry Pi then.

  • Andreu

    Hi Oleg,

    I’m trying to control my NikonD60. I’m working with usb host shield 2.0 and Arduino UNO. (Arduino version 1.0.2). I unpacked PTP, Arduino_Camera_Control and USB_Host_Shield_2.0 libraries in \arduino-1.0.2\libraries. And when I try to run GetDevInfo, I got this:

    C:\Users\Andreu\arduino-1.0.2\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=102 -IC:\Users\Andreu\arduino-1.0.2\hardware\arduino\cores\arduino -IC:\Users\Andreu\arduino-1.0.2\hardware\arduino\variants\standard -IC:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20 -IC:\Users\Andreu\arduino-1.0.2\libraries\PTP C:\Users\Andreu\AppData\Local\Temp\build2184657369212545598.tmp\devinfoparser.cpp -o C:\Users\Andreu\AppData\Local\Temp\build2184657369212545598.tmp\devinfoparser.cpp.o
    In file included from /devinfoparser.h:7,
    from devinfoparser.cpp:1:
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/mtpconst.h:104:25: warning: missing whitespace after the macro name
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/mtpconst.h:109:20: warning: missing whitespace after the macro name
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/mtpconst.h:110:24: warning: missing whitespace after the macro name
    In file included from C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptp.h:26,
    from /devinfoparser.h:8,
    from devinfoparser.cpp:1:
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpdebug.h:22:33: error: ../USBHost/printhex.h: No such file or directory
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpdebug.h:23:32: error: ../USBHost/hexdump.h: No such file or directory
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpdebug.h:24:32: error: ../USBHost/message.h: No such file or directory
    In file included from C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/Usb.h:45,
    from C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptp.h:23,
    from /devinfoparser.h:8,
    from devinfoparser.cpp:1:
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/message.h: In function ‘void ErrorMessage(const char*, ERROR_TYPE)’:
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/message.h:31: warning: only initialized variables can be placed into program memory area
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/message.h:33: warning: only initialized variables can be placed into program memory area
    In file included from C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptp.h:25,
    from /devinfoparser.h:8,
    from devinfoparser.cpp:1:
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpmsgstr.h: At global scope:
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpmsgstr.h:20: warning: only initialized variables can be placed into program memory area
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpmsgstr.h:21: warning: only initialized variables can be placed into program memory area
    C:\Users\Andreu\arduino-1.0.2\libraries\USB_Host_Shield_20/../ptp/ptpmsgstr.h:22: warning: only initialized variables can be placed into program memory area
    In file included from devinfoparser.cpp:1:
    /devinfoparser.h:10: warning: only initialized variables can be placed into program memory area

    … the same from /devinfoparser.h:10 to /devinfoparser.h:200.

    /devinfoparser.h:201: warning: only initialized variables can be placed into program memory area

    devinfoparser.cpp:X: warning: only initialized variables can be placed into program memory area —> When X = 3,36,49,68,76,112,127,145.

    devinfoparser.cpp: In constructor ‘DevInfoParser::DevInfoParser()’:
    devinfoparser.cpp:175: warning: statement has no effect
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintFunctMode(uint8_t**, uint16_t&)’:
    devinfoparser.cpp:195: warning: only initialized variables can be placed into program memory area
    devinfoparser.cpp: In member function ‘bool DevInfoParser::PrintVendor(uint8_t**, uint16_t&)’:
    devinfoparser.cpp:X: warning: only initialized variables can be placed into program memory area — When (X=483,492, 495,498,501,504,507,510,513,516,519,522,525,528,531)
    devinfoparser.cpp: In member function ‘virtual void DevInfoParser::Parse(uint16_t, const uint8_t*, const uint32_t&)’:
    devinfoparser.cpp:615: warning: only initialized variables can be placed into program memory area
    devinfoparser.cpp:X: warning: only initialized variables can be placed into program memory area When (X=642,650,658,666,674,682,690,698,706)

    devinfoparser.cpp:711: warning: only initialized variables can be placed into program memory area from /devinfoparser.h:8,

    —–

    Do you know what I am doing wrong?

    Cheers in advance

  • Hi Oleg.
    Thank you so much for sharing this.
    I would appreciate your advice on the following: I’ve installed your PTP_2.0_master library and the Time library and am just trying to compile the sketches in order to make sure all is good.
    I get the following, on the following examples:
    EOSBulb -> compiles fine
    EOSCamController -> Well.. Here’s the error log:

    hdrcapture.h:20: error: ‘Q_USER_SIG’ was not declared in this scope
    hdrcapture.h:34: error: expected class-name before ‘{‘ token
    hdrcapture.h:40: error: expected class-name before ‘{‘ token
    hdrcapture.h:45: error: expected class-name before ‘{‘ token
    hdrcapture.h:52: error: expected class-name before ‘{‘ token
    hdrcapture.h:57: error: expected class-name before ‘{‘ token
    hdrcapture.h:73: error: ‘QEvt’ does not name a type
    hdrcapture.h:75: error: ‘QStateHandler’ does not name a type
    hdrcapture.h:77: error: ‘QEvt’ was not declared in this scope
    hdrcapture.h:77: error: template argument 1 is invalid
    hdrcapture.h:98: error: ‘QEvt’ has not been declared
    hdrcapture.h:111: error: ‘QState’ does not name a type
    hdrcapture.h:112: error: ‘QState’ does not name a type
    hdrcapture.h:113: error: ‘QState’ does not name a type
    hdrcapture.h:114: error: ‘QState’ does not name a type
    hdrcapture.h:115: error: ‘QState’ does not name a type
    hdrcapture.h:116: error: ‘QState’ does not name a type
    hdrcapture.h:117: error: ‘QState’ does not name a type
    hdrcapture.h:118: error: ‘QState’ does not name a type
    hdrcapture.h:119: error: ‘QState’ does not name a type
    hdrcapture.h:120: error: ‘QState’ does not name a type
    hdrcapture.h:121: error: ‘QState’ does not name a type
    /hdrcapture.h: In constructor ‘HDRCapture::HDRCapture(CanonEOS&)’:
    hdrcapture.h:81: error: class ‘HDRCapture’ does not have any field named ‘QHsm’
    hdrcapture.h:81: error: ‘QStateHandler’ was not declared in this scope
    hdrcapture.h:81: error: ‘Initial’ is not a member of ‘HDRCapture’
    hdrcapture.h:93: error: class ‘HDRCapture’ does not have any field named ‘activeHistory’
    hdrcapture.h:95: error: ‘struct SetTimeoutEvt’ has no member named ‘sig’
    hdrcapture.h:96: error: ‘struct PTP_RC_Evt’ has no member named ‘sig’
    /hdrcapture.h: In member function ‘void HDRCapture::PostEvent(int*)’:
    hdrcapture.h:100: error: request for member ‘Push’ in ‘((HDRCapture*)this)->HDRCapture::theQueue’, which is of non-class type ‘int’
    /hdrcapture.h: In member function ‘void HDRCapture::Run()’:
    hdrcapture.h:104: error: ‘QEvt’ was not declared in this scope
    hdrcapture.h:104: error: ‘e’ was not declared in this scope
    hdrcapture.h:106: error: request for member ‘Pop’ in ‘((HDRCapture*)this)->HDRCapture::theQueue’, which is of non-class type ‘int’
    hdrcapture.h:107: error: ‘dispatch’ was not declared in this scope
    EOSCamController.cpp: At global scope:
    EOSCamController.pde:-1: error: ‘QEvt’ does not name a type
    EOSCamController.cpp: In function ‘void MenuRunAbort()’:
    EOSCamController.pde:-1: error: ‘evtAbort’ was not declared in this scope
    EOSCamController.cpp: In function ‘void MenuRun()’:
    EOSCamController.pde:-1: error: ‘struct SetEvt’ has no member named ‘sig’
    EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
    EOSCamController.pde:-1: error: ‘struct SetEvt’ has no member named ‘sig’
    EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
    EOSCamController.pde:-1: error: ‘struct SetEvt’ has no member named ‘sig’
    EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
    EOSCamController.pde:-1: error: ‘struct SetBktEvt’ has no member named ‘sig’
    EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
    EOSCamController.pde:-1: error: ‘struct SetEvt’ has no member named ‘sig’
    EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘dispatch’
    EOSCamController.cpp: In member function ‘virtual void CamStateHandlers::OnDeviceInitializedState(PTP*)’:
    EOSCamController.pde:-1: error: ‘evtTick’ was not declared in this scope
    EOSCamController.pde:-1: error: cannot declare variable ‘hnd’ to be of abstract type ‘EosEventHandlers’
    /eoseventhandler.h:13: note: because the following virtual functions are pure within ‘EosEventHandlers’:
    C:\Program Files (x86)\arduino-1.0.1\libraries\PTP20master/eoseventparser.h:37: note: virtual void EOSEventHandlers::OnObjectCreated(const EOSEvent*)
    EOSCamController.cpp: In function ‘void setup()’:
    EOSCamController.pde:-1: error: ‘evtTick’ was not declared in this scope
    EOSCamController.pde:-1: error: ‘evtAbort’ was not declared in this scope
    EOSCamController.pde:-1: error: ‘class CamHDRCapture’ has no member named ‘init’

    Would appreciate very much your help on this.

  • Is someone else could help me out here it would be great. I’ve combed all the forums and read all the comments and still can’t figure out:
    A: Has this been updated to work with IDE 1.0?
    B: After downloading, extracting and renaming the various libraries, AND after replacing qp_ccp I still get errors
    C: after commenting out the void operator delete(void *) on the qp_ccp file I get different errors.

    Is someone went through this and finally figured it out please reply.

  • And this is the error I get:

    EOSRemote.cpp: In member function ‘virtual void CamStateHandlers::OnDeviceInitializedState(PTP*)’:
    EOSRemote.pde:-1: error: cannot declare variable ‘hnd’ to be of abstract type ‘EosEventHandlers’
    /eoseventhandlers.h:12: note: because the following virtual functions are pure within ‘EosEventHandlers’:
    C:\Program Files (x86)\arduino-1.0.1\libraries\ptp/eoseventparser.h:37: note: virtual void EOSEventHandlers::OnObjectCreated(const EOSEvent*)

  • For all the struggling users out there, here are my 2 cents.
    I managed to compile all sketches EXCEPT EOSRemote.
    It was after I

    1. Replaced qp_ccp
    2. Commented out these lines in the qp_port.cpp:
    // void operator delete(void *) {
    // Q_ERROR(); // this operator should never be actually called
    // }
    3. Added the following line to eoseventhandler.h file found in EOSCamController folder:
    virtual void OnObjectCreated(const EOSEvent *evt) {};

    Hope this may help some of you.
    As for me – I still get the following error for EOSRemote:

    EOSRemote.cpp: In member function ‘virtual void CamStateHandlers::OnDeviceInitializedState(PTP*)’:
    EOSRemote.pde:-1: error: cannot declare variable ‘hnd’ to be of abstract type ‘EosEventHandlers’
    /eoseventhandlers.h:12: note: because the following virtual functions are pure within ‘EosEventHandlers’:
    C:\Program Files (x86)\arduino-1.0.1\libraries\ptp/eoseventparser.h:37: note: virtual void EOSEventHandlers::OnObjectCreated(const EOSEvent*)

    If someone knows what to do with this I’d appreciate the tip.

  • Vitor

    Hi Oleg,

    First and foremost thanks for the help so far :)

    I’m getting this errors when I try to compile the example for EOSCapture:

    EOSCapture.pde:14:17: warning: ptp.h: No such file or directory
    EOSCapture.pde:15:22: warning: canoneos.h: No such file or directory
    In file included from C:\Arduino\libraries\USB_Host_Shield_20/Usb.h:40,
    from EOSCapture.pde:8:
    C:\Arduino\libraries\USB_Host_Shield_20/message.h: In function ‘void ErrorMessage(const char*, ERROR_TYPE)’:
    C:\Arduino\libraries\USB_Host_Shield_20/message.h:48: warning: only initialized variables can be placed into program memory area
    C:\Arduino\libraries\USB_Host_Shield_20/message.h:50: warning: only initialized variables can be placed into program memory area
    In file included from EOSCapture.pde:8:
    C:\Arduino\libraries\USB_Host_Shield_20/Usb.h: At global scope:
    C:\Arduino\libraries\USB_Host_Shield_20/Usb.h:168: warning: ‘packed’ attribute ignored
    EOSCapture:18: error: expected class-name before ‘{‘ token
    EOSCapture:24: error: ‘PTP’ has not been declared
    EOSCapture:25: error: ‘PTP’ has not been declared
    EOSCapture:30: error: ‘CanonEOS’ does not name a type
    EOSCapture:32: error: variable or field ‘OnDeviceDisconnectedState’ declared void
    EOSCapture:32: error: ‘PTP’ was not declared in this scope
    EOSCapture:32: error: ‘ptp’ was not declared in this scope

    Where am I screwing the code?

    Many thanks in advance and the best reagards,
    Vitor

      • Vitor

        Yep.
        I have the following libraies installed:

        EEPROM
        Esplora
        Ethernet
        Firmata
        GSM
        LiquidCrystal
        ptp
        SD
        Servo
        SoftwareSerial
        SPI
        Stepper
        USB_Host_Shield_20
        WiFi
        Wire

        I’ve tried to rename some, but the errors continued.
        I did a fresh arduino install, redownloaded the libraries (the ptp you sent and https://github.com/felis/USB_Host_Shield_2.0 )

        Tahanks in advance!

      • Vitor

        Hello Oleg,
        Thanks for the help so far
        The error now is

        In file included from C:\Arduino\libraries\USBHost/Usb.h:40,
        from EOSCapture.pde:8:
        C:\Arduino\libraries\USBHost/message.h: In function ‘void ErrorMessage(const char*, ERROR_TYPE)’:
        C:\Arduino\libraries\USBHost/message.h:48: warning: only initialized variables can be placed into program memory area
        C:\Arduino\libraries\USBHost/message.h:50: warning: only initialized variables can be placed into program memory area
        In file included from EOSCapture.pde:8:
        C:\Arduino\libraries\USBHost/Usb.h: At global scope:
        C:\Arduino\libraries\USBHost/Usb.h:168: warning: ‘packed’ attribute ignored
        In file included from C:\Arduino\libraries\ptp/ptp.h:25,
        from EOSCapture.pde:14:
        C:\Arduino\libraries\ptp/ptpmsgstr.h:20: warning: only initialized variables can be placed into program memory area
        C:\Arduino\libraries\ptp/ptpmsgstr.h:21: warning: only initialized variables can be placed into program memory area
        C:\Arduino\libraries\ptp/ptpmsgstr.h:22: warning: only initialized variables can be placed into program memory area
        EOSCapture.pde: In member function ‘virtual void CamStateHandlers::OnDeviceDisconnectedState(PTP*)’:
        EOSCapture.pde:37: warning: only initialized variables can be placed into program memory area
        C:\Arduino\libraries\USBHost/message.h:27: error: too few arguments to function ‘void Notify(const char*, int)’
        EOSCapture:37: error: at this point in file

        Any clue?
        Many thanks!
        Vitor

  • Vitor

    Thanks for the quick reply!
    I’m using this one: https://www.sparkfun.com/products/9947
    And downloaded this https://github.com/felis/USB_Host_Shield_2.0 library.

    This is the optput of the board_qc

    Circuits At Home 2011
    USB Host Shield Quality Control Routine
    Reading REVISION register… Die revision invalid. Value returned: 00
    Unrecoverable error – test halted!!
    0×55 pattern is transmitted via SPI
    Press RESET to restart test

    • I don’t support this board.

      • Vitor

        Thanks for all the help!

        I googled around and found the solution.
        The Digital Pin 7 must be jumpered to reset pin in the SparkFun 9947 board.

        Along with it, I had a soldering problem. After all fixed, the ptp capture code worked just fine!

        Best regards,
        Vitor

  • Vitor

    Oleg,

    When I call the function SwitchLiveView(on), the camera raises the mirror as if I’m using the live view, but the LCD display won’t turn on and the camera will be busy all the time…
    I’m using a Canon 40D and also tested on a Canon 5D mark III

    Any clues?

    Thanks in advance!

  • Vitor

    Thanks, Oleg! It helped a lot.
    Is there any way I can read from the camera if the live view is on and/or if the mirror is raised?
    Many thanks in advance.

  • Brian

    I just stumbled across this site but know nothing about Arduino. I Use Canon A620 cameras for trail camera use. I have a control board that controls Motion sensing, Camera Power, and Camera shutter.

    This is what I want to do with Arduino. Please tell me if this is possible and how to do it?

    I want to connect the camera through USB to the Arduino board and a GSM board (like the picture at the beginning of this post). When the Camera snaps a picture I want to transfer the picture through USB and send the picture to my email or text through GSM.

    Please Help!!!

  • Is there a way to tell the camera what focus to put the lens to?

    I know the 7D will tell a 580EX what focal length the lens is at. Is there a way to have an arduino tell the camera to set the lens to specific focal length.. This way, you could take an ultrasonic rangefinder, mount it to the hot shoe, and have the arduino focus the lens based on the ping from the rangefinder kind of like how the old Polaroid cameras worked.

  • I’m trying to control my Canon EOS 60D via the USB Hostshield 2.0
    But I’m experiencing some strange Problem when trying to start and stop recording video…
    Starting (setting 0xD1B8 to 4) always works but when I try to stop it (setting 0xD1B8 to 0) it always kind of crashes the host controller..
    I get this:

    4
    Error: 2001
    0
    Fatal USB Error

    Transaction: Response recieve error
    SetProperty rec error:
    Error: 2002

    so 4 works and returns RC_OK but 0 returns the general error…

    Do you know what could be the problem?
    Thanks in advance

    Lukas

  • I traced the Problem until the function USB::dispatchPkt

    ———————–

    rcode = (regRd(rHRSL) & 0x0f); //analyze transfer result

    Serial.println(rcode);

    switch(rcode) {
    ————————

    After I added the print statement it suddenly worked as it should have before.
    So I added a little delay there (minimum are 30 microSeconds, I choose 50)

    So that’s a workaround for everybody with that problem
    Would be intresting though what the problem is/was… (To lazy to search what regRd does…)

    Lukas

    http://www.lbsfilm.at

Leave a Reply

  

  

  



You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">