Skip to content

Commit c5f2d67

Browse files
author
Oleg Mazurov
committed
Major ptp changes plus PowerShot support
1 parent 94ca7bc commit c5f2d67

58 files changed

Lines changed: 7449 additions & 1193 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

canoneos.cpp

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
/*****************************************************************************
2-
*
3-
* Copyright (C) 2010 Circuits At Home, LTD. All rights reserved.
4-
*
5-
* This software may be distributed and modified under the terms of the GNU
6-
* General Public License version 2 (GPL) as published by the Free Software
7-
* Foundation and appearing in the file GPL.TXT included in the packaging of
8-
* this file. Please note that GPL Section 2[b] requires that all works based
9-
* on this software must also be made publicly available under the terms of
10-
* the GPL ("Copyleft").
11-
*
12-
* Contact information:
13-
* Circuits At Home Web site: http://www.circuitsathome.com
14-
* e-mail: support@circuitsathome.com
15-
*****************************************************************************/
1+
/* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved.
2+
3+
This software may be distributed and modified under the terms of the GNU
4+
General Public License version 2 (GPL2) as published by the Free Software
5+
Foundation and appearing in the file GPL2.TXT included in the packaging of
6+
this file. Please note that GPL2 Section 2[b] requires that all works based
7+
on this software must also be made publicly available under the terms of
8+
the GPL2 ("Copyleft").
9+
10+
Contact information
11+
-------------------
12+
13+
Circuits At Home, LTD
14+
Web : http://www.circuitsathome.com
15+
e-mail : support@circuitsathome.com
16+
*/
1617
#include "canoneos.h"
1718

1819

@@ -59,8 +60,8 @@ uint16_t CanonEOS::SetImageQuality(uint32_t format)
5960
ImgQualitySupplier sup;
6061
sup.SetPictureFormat(format);
6162

62-
if ( (ptp_error = Transaction(PTP_OC_EOS_SetDevicePropValue, &flags, NULL, (void*)&sup)) != PTP_RC_OK)
63-
Message(PSTR("SetImageQuality error"), ptp_error);
63+
if ( (ptp_error = Transaction(EOS_OC_SetDevicePropValue, &flags, NULL, (void*)&sup)) != PTP_RC_OK)
64+
PTPTRACE2("SetImageQuality error", ptp_error);
6465

6566
return ptp_error;
6667
}
@@ -69,14 +70,14 @@ uint16_t CanonEOS::SetPCConnectMode(uint8_t mode)
6970
{
7071
uint32_t params[1];
7172
params[0] = (uint32_t) mode;
72-
return Operation(PTP_OC_EOS_SetPCConnectMode, 1, params);
73+
return Operation(EOS_OC_SetPCConnectMode, 1, params);
7374
}
7475

7576
uint16_t CanonEOS::SetExtendedEventInfo(uint8_t mode)
7677
{
7778
uint32_t params[1];
7879
params[0] = (uint32_t) mode;
79-
return Operation(PTP_OC_EOS_SetExtendedEventInfo, 1, params);
80+
return Operation(EOS_OC_SetExtendedEventInfo, 1, params);
8081
}
8182

8283
uint16_t CanonEOS::StartBulb()
@@ -98,18 +99,15 @@ uint16_t CanonEOS::StopBulb()
9899
{
99100
uint32_t params[3];
100101

101-
params[0] = 0xffffffff;
102+
params[0] = 0xffffffff;
102103
params[1] = 0x00001000;
103104
params[2] = 0x00000000;
104105
Operation(0x911A, 3, params);
105106

106-
params[0] = 0xfffffffc;
107+
params[0] = 0xfffffffc;
107108
Operation(0x911A, 3, params);
108-
109109
Operation(0x9126, 0, NULL);
110-
delay(50);
111110
Operation(0x911C, 0, NULL);
112-
delay(50);
113111

114112
return PTP_RC_OK;
115113
}
@@ -119,15 +117,15 @@ uint16_t CanonEOS::CancelTransfer(uint32_t object_id)
119117
uint32_t params[1];
120118
params[0] = object_id;
121119

122-
return Operation(PTP_OC_EOS_CancelTransfer, 1, params);
120+
return Operation(EOS_OC_CancelTransfer, 1, params);
123121
}
124122

125123
uint16_t CanonEOS::ResetTransfer(uint32_t object_id)
126124
{
127125
uint32_t params[1];
128126
params[0] = object_id;
129127

130-
return Operation(PTP_OC_EOS_ResetTransfer, 1, params);
128+
return Operation(EOS_OC_ResetTransfer, 1, params);
131129
}
132130

133131
uint16_t CanonEOS::SwitchLiveView(bool on)
@@ -140,7 +138,7 @@ uint16_t CanonEOS::SwitchLiveView(bool on)
140138
{
141139
if ((ptp_error = SetProperty(0xD1B3, 0)) != PTP_RC_OK)
142140
{
143-
Message(PSTR("LiveView start failure:"), ptp_error);
141+
PTPTRACE2("LiveView start failure:", ptp_error);
144142
SetProperty(EOS_DPC_LiveView, 0);
145143
return PTP_RC_GeneralError;
146144
}
@@ -157,10 +155,8 @@ uint16_t CanonEOS::MoveFocus(uint16_t step)
157155

158156
params[0] = (uint32_t) step;
159157

160-
if ( (ptp_error = Transaction(PTP_OC_EOS_MoveFocus, &flags, params, NULL)) != PTP_RC_OK)
161-
Message(PSTR("MoveFocus error."), ptp_error);
162-
else
163-
Message(PSTR("MoveFocus: Success."), ptp_error);
158+
if ( (ptp_error = Transaction(EOS_OC_MoveFocus, &flags, params, NULL)) != PTP_RC_OK)
159+
PTPTRACE2("MoveFocus error: ", ptp_error);
164160

165161
return ptp_error;
166162
}
@@ -171,14 +167,14 @@ uint16_t CanonEOS::EventCheck(PTPReadParser *parser)
171167
OperFlags flags = { 0, 0, 0, 1, 1, 0 };
172168

173169
if ( (ptp_error = Transaction(0x9116, &flags, NULL, parser)) != PTP_RC_OK)
174-
Message(PSTR("EOSEventCheck error:"), ptp_error);
170+
PTPTRACE2("EOSEventCheck error:", ptp_error);
175171

176172
return ptp_error;
177173
}
178174

179175
uint16_t CanonEOS::Capture()
180176
{
181-
return Operation(PTP_OC_EOS_Capture, 0, NULL);
177+
return Operation(EOS_OC_Capture, 0, NULL);
182178
}
183179

184180

@@ -192,8 +188,8 @@ uint16_t CanonEOS::SetProperty(uint16_t prop, uint32_t val)
192188
params[1] = (uint32_t)prop;
193189
params[2] = val;
194190

195-
if ( (ptp_error = Transaction(PTP_OC_EOS_SetDevicePropValue, &flags, NULL, (void*)params)) != PTP_RC_OK)
196-
Message(PSTR("SetProperty error:"), ptp_error);
191+
if ( (ptp_error = Transaction(EOS_OC_SetDevicePropValue, &flags, NULL, (void*)params)) != PTP_RC_OK)
192+
PTPTRACE2("SetProperty error:", ptp_error);
197193

198194
return ptp_error;
199195
}
@@ -206,8 +202,8 @@ uint16_t CanonEOS::GetProperty(uint16_t prop, PTPReadParser *parser)
206202

207203
params[0] = (uint32_t)prop;
208204

209-
if ( (ptp_error = Transaction(PTP_OC_EOS_GetDevicePropValue, &flags, params, (void*)parser)) != PTP_RC_OK)
210-
Message(PSTR("GetProperty error:"), ptp_error);
205+
if ( (ptp_error = Transaction(EOS_OC_GetDevicePropValue, &flags, params, (void*)parser)) != PTP_RC_OK)
206+
PTPTRACE2("GetProperty error:", ptp_error);
211207

212208
return ptp_error;
213209
}
@@ -217,8 +213,8 @@ uint16_t CanonEOS::GetDeviceInfoEx(PTPReadParser *parser)
217213
uint16_t ptp_error = PTP_RC_GeneralError;
218214
OperFlags flags = { 0, 0, 0, 1, 1, 0 };
219215

220-
if ( (ptp_error = Transaction(PTP_OC_EOS_GetDeviceInfoEx, &flags, NULL, (void*)parser)) != PTP_RC_OK)
221-
Message(PSTR("GetDeviceInfo error:"), ptp_error);
216+
if ( (ptp_error = Transaction(EOS_OC_GetDeviceInfoEx, &flags, NULL, (void*)parser)) != PTP_RC_OK)
217+
PTPTRACE2("GetDeviceInfo error:", ptp_error);
222218

223219
return ptp_error;
224220
}
@@ -232,8 +228,8 @@ uint16_t CanonEOS::GetObject(uint32_t object_id, uint32_t parent_id, PTPReadPars
232228
params[0] = object_id;
233229
params[1] = parent_id;
234230

235-
if ( (ptp_error = Transaction(PTP_OC_EOS_GetObject, &flags, params, (void*)parser)) != PTP_RC_OK)
236-
Message(PSTR("GetObject error:"), ptp_error);
231+
if ( (ptp_error = Transaction(EOS_OC_GetObject, &flags, params, (void*)parser)) != PTP_RC_OK)
232+
PTPTRACE2("GetObject error:", ptp_error);
237233

238234
return ptp_error;
239235
}

canoneos.h

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,64 @@
1-
/*****************************************************************************
2-
*
3-
* Copyright (C) 2010 Circuits At Home, LTD. All rights reserved.
4-
*
5-
* This software may be distributed and modified under the terms of the GNU
6-
* General Public License version 2 (GPL) as published by the Free Software
7-
* Foundation and appearing in the file GPL.TXT included in the packaging of
8-
* this file. Please note that GPL Section 2[b] requires that all works based
9-
* on this software must also be made publicly available under the terms of
10-
* the GPL ("Copyleft").
11-
*
12-
* Contact information:
13-
* Circuits At Home Web site: http://www.circuitsathome.com
14-
* e-mail: support@circuitsathome.com
15-
*****************************************************************************/
1+
/* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved.
2+
3+
This software may be distributed and modified under the terms of the GNU
4+
General Public License version 2 (GPL2) as published by the Free Software
5+
Foundation and appearing in the file GPL2.TXT included in the packaging of
6+
this file. Please note that GPL2 Section 2[b] requires that all works based
7+
on this software must also be made publicly available under the terms of
8+
the GPL2 ("Copyleft").
9+
10+
Contact information
11+
-------------------
12+
13+
Circuits At Home, LTD
14+
Web : http://www.circuitsathome.com
15+
e-mail : support@circuitsathome.com
16+
*/
1617
#ifndef __CANONEOS_H__
1718
#define __CANONEOS_H__
1819

20+
#include "WProgram.h"
1921
#include "ptp.h"
2022

2123
// PTP Operation Codes (EOS specific)
22-
#define PTP_OC_EOS_GetStorageIDs 0x9101
23-
#define PTP_OC_EOS_GetStorageInfo 0x9102
24-
#define PTP_OC_EOS_GetObject 0x9107
25-
#define PTP_OC_EOS_GetDeviceInfoEx 0x9108
26-
#define PTP_OC_EOS_GetObjectIDs 0x9109
27-
#define PTP_OC_EOS_Capture 0x910f
28-
#define PTP_OC_EOS_SetDevicePropValue 0x9110
29-
#define PTP_OC_EOS_SetPCConnectMode 0x9114
30-
#define PTP_OC_EOS_SetExtendedEventInfo 0x9115
31-
#define PTP_OC_EOS_GetEvent 0x9116
32-
#define PTP_OC_EOS_TransferComplete 0x9117
33-
#define PTP_OC_EOS_CancelTransfer 0x9118
34-
#define PTP_OC_EOS_ResetTransfer 0x9119
35-
#define PTP_OC_EOS_GetDevicePropValue 0x9127
36-
#define PTP_OC_EOS_GetLiveViewPicture 0x9153
37-
#define PTP_OC_EOS_MoveFocus 0x9155
24+
#define EOS_OC_GetStorageIDs 0x9101
25+
#define EOS_OC_GetStorageInfo 0x9102
26+
#define EOS_OC_GetObject 0x9107
27+
#define EOS_OC_GetDeviceInfoEx 0x9108
28+
#define EOS_OC_GetObjectIDs 0x9109
29+
#define EOS_OC_Capture 0x910f
30+
#define EOS_OC_SetDevicePropValue 0x9110
31+
#define EOS_OC_SetPCConnectMode 0x9114
32+
#define EOS_OC_SetExtendedEventInfo 0x9115
33+
#define EOS_OC_GetEvent 0x9116
34+
#define EOS_OC_TransferComplete 0x9117
35+
#define EOS_OC_CancelTransfer 0x9118
36+
#define EOS_OC_ResetTransfer 0x9119
37+
#define EOS_OC_GetDevicePropValue 0x9127
38+
#define EOS_OC_GetLiveViewPicture 0x9153
39+
#define EOS_OC_MoveFocus 0x9155
3840

3941
// PTP Device Properties
40-
#define PTP_DPC_EOS_CameraDescription 0xD402
42+
#define EOS_DPC_CameraDescription 0xD402
4143

4244
// Non-PTP Device properties
43-
#define EOS_DPC_Aperture 0xD101
44-
#define EOS_DPC_Exposure 0xD102
45-
#define EOS_DPC_Iso 0xD103
46-
#define EOS_DPC_ExposureCorrection 0xD104
45+
#define EOS_DPC_Aperture 0xD101
46+
#define EOS_DPC_ShutterSpeed 0xD102
47+
#define EOS_DPC_Iso 0xD103
48+
#define EOS_DPC_ExposureCompensation 0xD104
4749
#define EOS_DPC_ShootingMode 0xD105
48-
#define EOS_DPC_DriveMode 0xD106
50+
#define EOS_DPC_DriveMode 0xD106
4951
#define EOS_DPC_ExpMeterringMode 0xD107
50-
#define EOS_DPC_AFMode 0xD108
52+
#define EOS_DPC_AFMode 0xD108
5153
#define EOS_DPC_WhiteBalance 0xD109
5254
#define EOS_DPC_PictureStyle 0xD110
5355
#define EOS_DPC_TransferOption 0xD111
54-
#define EOS_DPC_UnixTime 0xD113
56+
#define EOS_DPC_UnixTime 0xD113
5557
#define EOS_DPC_ImageQuality 0xD120
56-
#define EOS_DPC_LiveView 0xD1B0
58+
#define EOS_DPC_LiveView 0xD1B0
5759
#define EOS_DPC_AvailableShots 0xD11B
58-
#define EOS_DPC_CaptureDestination 0xD11C
59-
#define EOS_DPC_BracketMode 0xD11D
60-
60+
#define EOS_DPC_CaptureDestination 0xD11C
61+
#define EOS_DPC_BracketMode 0xD11D
6162

6263
// Non-PTP Events
6364
#define EOS_EC_DevPropChanged 0xC189
@@ -67,14 +68,12 @@
6768
#define EOS_EC_HalfPushReleaseButton 0xC18E
6869

6970

70-
7171
class EOSStateHandlers : public PTPStateHandlers
7272
{
7373
public:
7474
virtual void OnSessionOpenedState(PTP *ptp);
7575
};
7676

77-
7877
class ImgQualitySupplier : PTPDataSupplier
7978
{
8079
uint32_t pictFormat;

0 commit comments

Comments
 (0)