Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 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
*/
17
#include "canonps.h"
18
 
19
void PSStateHandlers::OnSessionOpenedState(PTP *ptp)
20
{
21
        if (FAILED(((CanonPS*)ptp)->SetDevicePropValue(PS_DPC_EventEmulateMode, (uint16_t)4)) )
22
                PTPTRACE("EventEmulateMode error\r\n");
23
 
24
        if (FAILED(((CanonPS*)ptp)->Initialize(true)) )
25
                PTPTRACE("Initialization error\r\n");
26
 
27
        ptp->SetState(PTP_STATE_DEVICE_INITIALIZED);
28
}
29
 
30
 
31
CanonPS::CanonPS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPStateHandlers *s)
32
: PTP(addr, epin, epout, epint, nconf, s)
33
{
34
}
35
 
36
uint16_t CanonPS::EventCheck(PTPReadParser *parser)
37
{
38
        uint16_t        ptp_error       = PTP_RC_GeneralError;
39
        OperFlags       flags           = { 0, 0, 0, 1, 1, 0 };
40
 
41
        if ( (ptp_error = Transaction(PS_OC_CheckEvent, &flags, NULL, parser)) != PTP_RC_OK)
42
                PTPTRACE2("EOSEventCheck error: ", ptp_error);
43
 
44
        return ptp_error;
45
}
46
 
47
uint16_t CanonPS::Initialize(bool binit)
48
{
49
        uint16_t        ptp_error;
50
 
51
        if (binit)
52
        {
53
                if ((ptp_error = Operation(PS_OC_StartShootingMode, 0, NULL)) != PTP_RC_OK)
54
                        PTPTRACE2("StartShootingMode failed: ", ptp_error);
55
        }
56
        else
57
        {
58
                if ((ptp_error = Operation(PS_OC_EndShootingMode, 0, NULL)) != PTP_RC_OK)
59
                        PTPTRACE2("EndShootingMode failed: ", ptp_error);
60
        }
61
        return ptp_error;
62
}
63
 
64
uint16_t CanonPS::Capture()
65
{
66
        uint16_t        ptp_error;
67
 
68
        if ((ptp_error = Operation(PS_OC_FocusLock, 0, NULL)) != PTP_RC_OK)
69
                PTPTRACE2("Focus Lock Error: ", ptp_error);
70
 
71
        if ((ptp_error = Operation(PS_OC_InitiateCaptureInMemory, 0, NULL)) != PTP_RC_OK)
72
                PTPTRACE2("Capture Error: ", ptp_error);
73
 
74
        return ptp_error;
75
}
76