Permalink
Browse files

Major rewrite of PTP:Task state machine interface

  • Loading branch information...
1 parent 6085d65 commit afe6d262a6580957b49bf7bf5b629e9ed1e48ea4 @felis committed Sep 10, 2010
Showing with 2,476 additions and 1,464 deletions.
  1. +104 −25 canoneos.cpp
  2. +171 −55 canoneos.h
  3. +0 −134 canonps.cpp
  4. +0 −195 canonps.h
  5. +15 −0 copying.txt
  6. +0 −53 examples/EOSCapture.pde
  7. +84 −0 examples/EOSEventLab/EOSEventLab.pde
  8. +32 −15 examples/PTPDevInfo/PTPDevInfo.pde
  9. +634 −634 examples/PTPDevInfo/devinfoparser.cpp
  10. +241 −241 examples/PTPDevInfo/devinfoparser.h
  11. +340 −0 gpl2.txt
  12. +15 −0 mtpconst.h
  13. +103 −98 ptp.cpp
  14. +95 −12 ptp.h
  15. +15 −0 ptpcallback.cpp
  16. +17 −2 ptpcallback.h
  17. +15 −0 ptpconst.h
  18. +17 −0 ptpdebug.cpp
  19. +30 −0 ptpdebug.h
  20. +15 −0 ptpmsgstr.h
  21. +87 −0 scheduler.cpp
  22. +252 −0 scheduler.h
  23. +87 −0 simpletimer.cpp
  24. +107 −0 simpletimer.h
View
@@ -1,6 +1,27 @@
+/*****************************************************************************
+*
+* Copyright (C) 2010 Circuits At Home, LTD. All rights reserved.
+*
+* This software may be distributed and modified under the terms of the GNU
+* General Public License version 2 (GPL) as published by the Free Software
+* Foundation and appearing in the file GPL.TXT included in the packaging of
+* this file. Please note that GPL Section 2[b] requires that all works based
+* on this software must also be made publicly available under the terms of
+* the GPL ("Copyleft").
+*
+* Contact information:
+* Circuits At Home Web site: http://www.circuitsathome.com
+* e-mail: support@circuitsathome.com
+*****************************************************************************/
#include "canoneos.h"
+void EOSStateHandlers::OnSessionOpenedState(PTP *ptp)
+{
+ if (!FAILED(((CanonEOS*)ptp)->SetPCConnectMode(1)) && !FAILED(((CanonEOS*)ptp)->SetExtendedEventInfo(1)))
+ ptp->SetState(PTP_STATE_DEVICE_INITIALIZED);
+}
+
uint32_t ImgQualitySupplier::GetDataSize()
{
return ((pictFormat & 0xFFFF0000) ? 0x0000002C : 0x0000001C);
@@ -25,8 +46,8 @@ void ImgQualitySupplier::GetData(const uint16_t len, uint8_t *pbuf)
}
}
-CanonEOS::CanonEOS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPMAIN pfunc)
-: PTP(addr, epin, epout, epint, nconf, pfunc)
+CanonEOS::CanonEOS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPStateHandlers *s)
+: PTP(addr, epin, epout, epint, nconf, s)
{
}
@@ -58,23 +79,6 @@ uint16_t CanonEOS::SetExtendedEventInfo(uint8_t mode)
return Operation(PTP_OC_EOS_SetExtendedEventInfo, 1, params);
}
-uint16_t CanonEOS::Initialize(bool binit)
-{
- uint16_t result1 = PTP_RC_OK, result2 = PTP_RC_OK;
-
- if (binit)
- {
- result2 = SetExtendedEventInfo(1);
- result1 = SetPCConnectMode(1);
- }
- else
- {
- result1 = SetPCConnectMode(0);
- result2 = SetExtendedEventInfo(0);
- }
- return (((result1 == PTP_RC_OK) && (result2 == PTP_RC_OK)) ? PTP_RC_OK : PTP_RC_GeneralError);
-}
-
uint16_t CanonEOS::StartBulb()
{
uint32_t params[3];
@@ -108,6 +112,22 @@ uint16_t CanonEOS::StopBulb()
delay(50);
}
+uint16_t CanonEOS::CancelTransfer(uint32_t object_id)
+{
+ uint32_t params[1];
+ params[0] = object_id;
+
+ return Operation(PTP_OC_EOS_CancelTransfer, 1, params);
+}
+
+uint16_t CanonEOS::ResetTransfer(uint32_t object_id)
+{
+ uint32_t params[1];
+ params[0] = object_id;
+
+ return Operation(PTP_OC_EOS_ResetTransfer, 1, params);
+}
+
uint16_t CanonEOS::SwitchLiveView(bool on)
{
uint16_t ptp_error = PTP_RC_GeneralError;
@@ -149,7 +169,7 @@ uint16_t CanonEOS::EventCheck(PTPReadParser *parser)
OperFlags flags = { 0, 0, 0, 1, 1, 0 };
if ( (ptp_error = Transaction(0x9116, &flags, NULL, parser)) != PTP_RC_OK)
- Message(PSTR("EOSEventCheck error."), ptp_error);
+ Message(PSTR("EOSEventCheck error:"), ptp_error);
return ptp_error;
}
@@ -159,15 +179,34 @@ uint16_t CanonEOS::Capture()
return Operation(PTP_OC_EOS_Capture, 0, NULL);
}
-uint16_t CanonEOS::Test()
+/*uint16_t CanonEOS::DigitalZoom(uint16_t magnify)
{
- uint16_t ptp_error = PTP_RC_GeneralError;
+ uint16_t ptp_error = PTP_RC_GeneralError;
+ OperFlags flags = { 1, 0, 0, 0, 0, 0 };
+ uint32_t params[1];
+
+ params[0] = (uint32_t) magnify;
- if ((ptp_error = Operation(0x9802, 0, NULL)) != PTP_RC_OK)
- Message(PSTR("Test: Error: "), ptp_error);
+ if ( (ptp_error = Transaction(PTP_OC_EOS_Zoom, &flags, params, NULL)) != PTP_RC_OK)
+ Message(PSTR("DigitalZoom error:") , ptp_error);
return ptp_error;
}
+*/
+
+/*
+> The other command is 0xD1B8, which I defined as EOS_DPC_VideoStart in
+> your camera control library within canoneos.h. This command works by
+> using the SetProperty function:
+>
+> Eos.SetProperty(EOS_DPC_VideoStart, 4); // 4 starts video recording
+> Eos.SetProperty(EOS_DPC_VideoStart, 0); // 0 stops video recording
+>
+> I found it useful to check the ptp response returned by SetProperty to
+> verify that the camera started or stopped the video recording, since
+> it does seem to take the camera a second or so to perform the command.
+*/
+
uint16_t CanonEOS::SetProperty(uint16_t prop, uint32_t val)
{
@@ -180,7 +219,47 @@ uint16_t CanonEOS::SetProperty(uint16_t prop, uint32_t val)
params[2] = val;
if ( (ptp_error = Transaction(PTP_OC_EOS_SetDevicePropValue, &flags, NULL, (void*)params)) != PTP_RC_OK)
- Message(PSTR("SetProperty: Error."), ptp_error);
+ Message(PSTR("SetProperty error:"), ptp_error);
+
+ return ptp_error;
+}
+
+uint16_t CanonEOS::GetProperty(uint16_t prop, PTPReadParser *parser)
+{
+ uint16_t ptp_error = PTP_RC_GeneralError;
+ OperFlags flags = { 1, 0, 0, 1, 1, 0 };
+ uint32_t params[1];
+
+ params[0] = (uint32_t)prop;
+
+ if ( (ptp_error = Transaction(PTP_OC_EOS_GetDevicePropValue, &flags, params, (void*)parser)) != PTP_RC_OK)
+ Message(PSTR("GetProperty error:"), ptp_error);
+
+ return ptp_error;
+}
+
+uint16_t CanonEOS::GetDeviceInfoEx(PTPReadParser *parser)
+{
+ uint16_t ptp_error = PTP_RC_GeneralError;
+ OperFlags flags = { 0, 0, 0, 1, 1, 0 };
+
+ if ( (ptp_error = Transaction(PTP_OC_EOS_GetDeviceInfoEx, &flags, NULL, (void*)parser)) != PTP_RC_OK)
+ Message(PSTR("GetDeviceInfo error:"), ptp_error);
+
+ return ptp_error;
+}
+
+uint16_t CanonEOS::GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser)
+{
+ uint16_t ptp_error = PTP_RC_GeneralError;
+ OperFlags flags = { 2, 0, 0, 1, 1, 0 };
+ uint32_t params[2];
+
+ params[0] = object_id;
+ params[1] = parent_id;
+
+ if ( (ptp_error = Transaction(PTP_OC_EOS_GetObject, &flags, params, (void*)parser)) != PTP_RC_OK)
+ Message(PSTR("GetObject error:"), ptp_error);
return ptp_error;
}
Oops, something went wrong. Retry.

0 comments on commit afe6d26

Please sign in to comment.