Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit d2c7b4dc2de69b074bb11f84b590954d65d1f44e @felis committed Sep 4, 2011
Showing with 16,949 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +4 −0 README
  3. +310 −0 canoneos.cpp
  4. +153 −0 canoneos.h
  5. +76 −0 canonps.cpp
  6. +165 −0 canonps.h
  7. +110 −0 eoseventdump.cpp
  8. +43 −0 eoseventdump.h
  9. +123 −0 eoseventparser.cpp
  10. +92 −0 eoseventparser.h
  11. +296 −0 eosvaluetitles.h
  12. +76 −0 examples/Canon_EOS/EOSBulb/EOSBulb.pde
  13. +595 −0 examples/Canon_EOS/EOSCamController/EOSCamController.pde
  14. +57 −0 examples/Canon_EOS/EOSCamController/camcontroller.h
  15. +50 −0 examples/Canon_EOS/EOSCamController/controls.cpp
  16. +50 −0 examples/Canon_EOS/EOSCamController/controls.h
  17. +51 −0 examples/Canon_EOS/EOSCamController/dataitem.cpp
  18. +194 −0 examples/Canon_EOS/EOSCamController/dataitem.h
  19. +110 −0 examples/Canon_EOS/EOSCamController/eoseventhandler.cpp
  20. +20 −0 examples/Canon_EOS/EOSCamController/eoseventhandler.h
  21. +3 −0 examples/Canon_EOS/EOSCamController/expcomp_macro.h
  22. +336 −0 examples/Canon_EOS/EOSCamController/hdrcapture.cpp
  23. +130 −0 examples/Canon_EOS/EOSCamController/hdrcapture.h
  24. +39 −0 examples/Canon_EOS/EOSCamController/menu.cpp
  25. +200 −0 examples/Canon_EOS/EOSCamController/menu.h
  26. +43 −0 examples/Canon_EOS/EOSCamController/screen.cpp
  27. +32 −0 examples/Canon_EOS/EOSCamController/screen.h
  28. +93 −0 examples/Canon_EOS/EOSCamController/screenitem.cpp
  29. +36 −0 examples/Canon_EOS/EOSCamController/screenitem.h
  30. +76 −0 examples/Canon_EOS/EOSCapture/EOSCapture.pde
  31. +133 −0 examples/Canon_EOS/EOSDualCapture/EOSDualCapture.pde
  32. +107 −0 examples/Canon_EOS/EOSEventLab/EOSEventLab.pde
  33. +85 −0 examples/Canon_EOS/EOSFocus/EOSFocus.pde
  34. +110 −0 examples/Canon_EOS/EOSHDRCapture/EOSHDRCapture.pde
  35. +9 −0 examples/Canon_EOS/EOSHDRCapture/expcomp_macro.h
  36. +336 −0 examples/Canon_EOS/EOSHDRCapture/hdrcapture.cpp
  37. +130 −0 examples/Canon_EOS/EOSHDRCapture/hdrcapture.h
  38. +428 −0 examples/Canon_EOS/EOSRemote/EOSConsole.cpp
  39. +51 −0 examples/Canon_EOS/EOSRemote/EOSConsole.h
  40. +140 −0 examples/Canon_EOS/EOSRemote/EOSRemote.pde
  41. +118 −0 examples/Canon_EOS/EOSRemote/eoseventhandlers.cpp
  42. +19 −0 examples/Canon_EOS/EOSRemote/eoseventhandlers.h
  43. +212 −0 examples/Canon_EOS/EOSRemote/eoseventparser.cpp
  44. +74 −0 examples/Canon_EOS/EOSRemote/eoseventparser.h
  45. +105 −0 examples/Canon_PS/PSCapture/PSCapture.pde
  46. +86 −0 examples/Canon_PS/PSCapture/pseventparser.cpp
  47. +30 −0 examples/Canon_PS/PSCapture/pseventparser.h
  48. +298 −0 examples/Canon_PS/PSCapture/ptpobjinfoparser.cpp
  49. +85 −0 examples/Canon_PS/PSCapture/ptpobjinfoparser.h
  50. +105 −0 examples/Canon_PS/PSDevProp/PSDevProp.pde
  51. +368 −0 examples/Canon_PS/PSDevProp/devpropparser.cpp
  52. +172 −0 examples/Canon_PS/PSDevProp/devpropparser.h
  53. +117 −0 examples/Canon_PS/PSRemote/PSRemote.pde
  54. +475 −0 examples/Canon_PS/PSRemote/psconsole.cpp
  55. +56 −0 examples/Canon_PS/PSRemote/psconsole.h
  56. +85 −0 examples/Canon_PS/PSRemote/pseventparser.cpp
  57. +30 −0 examples/Canon_PS/PSRemote/pseventparser.h
  58. +298 −0 examples/Canon_PS/PSRemote/ptpobjinfoparser.cpp
  59. +85 −0 examples/Canon_PS/PSRemote/ptpobjinfoparser.h
  60. +152 −0 examples/Nikon/NKEventLab/NKEventLab.pde
  61. +111 −0 examples/Nikon/NKEventMonitor/NKEventMonitor.pde
  62. +120 −0 examples/Nikon/NKLiveView/NKLiveView.pde
  63. +136 −0 examples/Nikon/NKRemote/NKRemote.pde
  64. +510 −0 examples/Nikon/NKRemote/psconsole.cpp
  65. +58 −0 examples/Nikon/NKRemote/psconsole.h
  66. +298 −0 examples/Nikon/NKRemote/ptpobjinfoparser.cpp
  67. +85 −0 examples/Nikon/NKRemote/ptpobjinfoparser.h
  68. +71 −0 examples/ptpsketches/PTPCapture/PTPCapture.pde
  69. +80 −0 examples/ptpsketches/PTPDevInfo/PTPDevInfo.pde
  70. +714 −0 examples/ptpsketches/PTPDevInfo/devinfoparser.cpp
  71. +295 −0 examples/ptpsketches/PTPDevInfo/devinfoparser.h
  72. +96 −0 examples/ptpsketches/PTPDevProp/PTPDevProp.pde
  73. +368 −0 examples/ptpsketches/PTPDevProp/devpropparser.cpp
  74. +170 −0 examples/ptpsketches/PTPDevProp/devpropparser.h
  75. +91 −0 examples/ptpsketches/PTPObjInfo/PTPObjInfo.pde
  76. +298 −0 examples/ptpsketches/PTPObjInfo/ptpobjinfoparser.cpp
  77. +88 −0 examples/ptpsketches/PTPObjInfo/ptpobjinfoparser.h
  78. +79 −0 examples/ptpsketches/PTPObjectHandles/PTPObjectHandles.pde
  79. +20 −0 examples/ptpsketches/PTPObjectHandles/ptpobjhandleparser.cpp
  80. +34 −0 examples/ptpsketches/PTPObjectHandles/ptpobjhandleparser.h
  81. +73 −0 examples/ptpsketches/PTPStorageIDs/PTPStorageIDs.pde
  82. +92 −0 examples/ptpsketches/PTPStorageInfo/PTPStorageInfo.pde
  83. +204 −0 examples/ptpsketches/PTPStorageInfo/stinfoparser.cpp
  84. +50 −0 examples/ptpsketches/PTPStorageInfo/stinfoparser.h
  85. +340 −0 gpl2.txt
  86. +249 −0 mtpconst.h
  87. +114 −0 nikon.cpp
  88. +204 −0 nikon.h
  89. +57 −0 nkeventparser.cpp
  90. +107 −0 nkeventparser.h
  91. +259 −0 nkvaluetitles.h
  92. +369 −0 psvaluetitles.h
  93. +1,083 −0 ptp.cpp
  94. +173 −0 ptp.h
  95. +40 −0 ptpcallback.h
  96. +310 −0 ptpconst.h
  97. +314 −0 ptpconstitles.cpp
  98. +220 −0 ptpconstitles.h
  99. +38 −0 ptpdebug.h
  100. +255 −0 ptpdpparser.h
  101. +95 −0 ptpmsgstr.h
  102. +74 −0 simplefifo.h
  103. +88 −0 simpletimer.cpp
  104. +108 −0 simpletimer.h
  105. +246 −0 valuelist.h
@@ -0,0 +1,3 @@
+*.bak
+*.zip
+*.rar
4 README
@@ -0,0 +1,4 @@
+This is Rev.2.0 of PTP Digital Camera Control Library compatible with Rev.2.0 of USB Host Shield library.
+Supports select Canon EOS and Powershot, as well as Nikon DSLRs and P&S cameras.
+
+Project web site is http://www.circuitsathome.com
@@ -0,0 +1,310 @@
+/* Copyright (C) 2011 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 (GPL2) as published by the Free Software
+Foundation and appearing in the file GPL2.TXT included in the packaging of
+this file. Please note that GPL2 Section 2[b] requires that all works based
+on this software must also be made publicly available under the terms of
+the GPL2 ("Copyleft").
+
+Contact information
+-------------------
+
+Circuits At Home, LTD
+Web : http://www.circuitsathome.com
+e-mail : support@circuitsathome.com
+*/
+#include "canoneos.h"
+
+
+void EOSStateHandlers::OnSessionOpenedState(PTP *ptp)
+{
+ uint16_t ret;
+
+ ret = ((CanonEOS*)ptp)->SetPCConnectMode(1);
+
+ if (FAILED(ret))
+ {
+ PTPTRACE2("SetPCConnectMode failed", ret);
+ return;
+ }
+
+ ret = ((CanonEOS*)ptp)->SetExtendedEventInfo(1);
+
+ if (FAILED(ret))
+ {
+ PTPTRACE2("SetExtendedEventInfo failed", ret);
+ return;
+ }
+
+ PTPTRACE("Init complete\r\n");
+
+ ptp->SetState(PTP_STATE_DEVICE_INITIALIZED);
+
+ //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);
+}
+
+void ImgQualitySupplier::GetData(const uint16_t len, uint8_t *pbuf)
+{
+ uint8_t num_files = (pictFormat & 0xFFFF0000) ? 2 : 1;
+
+ ((uint32_t*)pbuf)[0] = (num_files == 2) ? 0x0000002C : 0x0000001C;
+ ((uint32_t*)pbuf)[1] = (uint32_t) EOS_DPC_ImageQuality;
+ ((uint32_t*)pbuf)[2] = (uint32_t) num_files;
+
+ uint32_t format = pictFormat;
+
+ for (uint8_t i=0, pos=3; i<num_files; i++)
+ {
+ ((uint32_t*)pbuf)[pos++] = 0x00000010;
+
+ for (uint8_t j=0; j<3; j++, format >>= 4)
+ ((uint32_t*)pbuf)[pos++] = (uint32_t)(format & 0xF);
+ }
+}
+
+CanonEOS::CanonEOS(USB *pusb, PTPStateHandlers *s)
+: PTP(pusb, s)
+{
+}
+
+uint8_t CanonEOS::Init(uint8_t parent, uint8_t port, bool lowspeed)
+{
+ uint8_t buf[10];
+ uint8_t rcode;
+ UsbDevice *p = NULL;
+ EpInfo *oldep_ptr = NULL;
+
+ PTPTRACE("EOS Init\r\n");
+
+ AddressPool &addrPool = pUsb->GetAddressPool();
+
+ if (devAddress)
+ return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
+
+ // Get pointer to pseudo device with address 0 assigned
+ p = addrPool.GetUsbDevicePtr(0);
+
+ if (!p)
+ return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
+
+ if (!p->epinfo)
+ {
+ PTPTRACE("epinfo\r\n");
+ return USB_ERROR_EPINFO_IS_NULL;
+ }
+
+ // Save old pointer to EP_RECORD of address 0
+ oldep_ptr = p->epinfo;
+
+ // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence
+ p->epinfo = epInfo;
+
+ // Get device descriptor
+ rcode = pUsb->getDevDescr( 0, 0, 10, (uint8_t*)buf );
+
+ // Restore p->epinfo
+ p->epinfo = oldep_ptr;
+
+ if( rcode )
+ {
+ PTPTRACE2("getDevDesc:", rcode);
+ return rcode;
+ }
+
+ if (((USB_DEVICE_DESCRIPTOR*)buf)->idVendor == 0x04A9)
+ return PTP::Init(parent, port, lowspeed);
+ else
+ {
+ PTPTRACE("Camera isn't Canon\r\n");
+ return USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
+ }
+}
+
+uint16_t CanonEOS::SetImageQuality(uint32_t format)
+{
+ uint16_t ptp_error = PTP_RC_GeneralError;
+ OperFlags flags = { 0, 0, 1, 1, 1, 0 };
+
+ ImgQualitySupplier sup;
+ sup.SetPictureFormat(format);
+
+ if ( (ptp_error = Transaction(EOS_OC_SetDevicePropValue, &flags, NULL, (void*)&sup)) != PTP_RC_OK)
+ PTPTRACE2("SetImageQuality error", ptp_error);
+
+ return ptp_error;
+}
+
+uint16_t CanonEOS::SetPCConnectMode(uint8_t mode)
+{
+ uint32_t params[1];
+ params[0] = (uint32_t) mode;
+ return Operation(EOS_OC_SetPCConnectMode, 1, params);
+}
+
+uint16_t CanonEOS::SetExtendedEventInfo(uint8_t mode)
+{
+ uint32_t params[1];
+ params[0] = (uint32_t) mode;
+ return Operation(EOS_OC_SetExtendedEventInfo, 1, params);
+}
+
+uint16_t CanonEOS::StartBulb()
+{
+ uint32_t params[3];
+
+ params[0] = 0xfffffff8;
+ params[1] = 0x00001000;
+ params[2] = 0x00000000;
+
+ Operation(0x911A, 3, params);
+ Operation(0x911B, 0, NULL);
+ Operation(0x9125, 0, NULL);
+
+ return PTP_RC_OK;
+}
+
+uint16_t CanonEOS::StopBulb()
+{
+ uint32_t params[3];
+
+ params[0] = 0xffffffff;
+ params[1] = 0x00001000;
+ params[2] = 0x00000000;
+ Operation(0x911A, 3, params);
+
+ params[0] = 0xfffffffc;
+ Operation(0x911A, 3, params);
+ Operation(0x9126, 0, NULL);
+ Operation(0x911C, 0, NULL);
+
+ return PTP_RC_OK;
+}
+
+uint16_t CanonEOS::CancelTransfer(uint32_t object_id)
+{
+ uint32_t params[1];
+ params[0] = object_id;
+
+ return Operation(EOS_OC_CancelTransfer, 1, params);
+}
+
+uint16_t CanonEOS::ResetTransfer(uint32_t object_id)
+{
+ uint32_t params[1];
+ params[0] = object_id;
+
+ return Operation(EOS_OC_ResetTransfer, 1, params);
+}
+
+uint16_t CanonEOS::SwitchLiveView(bool on)
+{
+ uint16_t ptp_error = PTP_RC_GeneralError;
+
+ if ((ptp_error = SetProperty(EOS_DPC_LiveView, (on) ? 2 : 0)) == PTP_RC_OK)
+ {
+ if (on)
+ {
+ if ((ptp_error = SetProperty(0xD1B3, 0)) != PTP_RC_OK)
+ {
+ PTPTRACE2("LiveView start failure:", ptp_error);
+ SetProperty(EOS_DPC_LiveView, 0);
+ return PTP_RC_GeneralError;
+ }
+ }
+ }
+ return ptp_error;
+}
+
+uint16_t CanonEOS::MoveFocus(uint16_t step)
+{
+ uint16_t ptp_error = PTP_RC_GeneralError;
+ OperFlags flags = { 1, 0, 0, 0, 0, 0 };
+ uint32_t params[1];
+
+ params[0] = (uint32_t) step;
+
+ if ( (ptp_error = Transaction(EOS_OC_MoveFocus, &flags, params, NULL)) != PTP_RC_OK)
+ PTPTRACE2("MoveFocus error: ", ptp_error);
+
+ return ptp_error;
+}
+
+uint16_t CanonEOS::EventCheck(PTPReadParser *parser)
+{
+ uint16_t ptp_error = PTP_RC_GeneralError;
+ OperFlags flags = { 0, 0, 0, 1, 1, 0 };
+
+ if ( (ptp_error = Transaction(0x9116, &flags, NULL, parser)) != PTP_RC_OK)
+ PTPTRACE2("EOSEventCheck error:", ptp_error);
+
+ return ptp_error;
+}
+
+uint16_t CanonEOS::Capture()
+{
+ return Operation(EOS_OC_Capture, 0, NULL);
+}
+
+
+uint16_t CanonEOS::SetProperty(uint16_t prop, uint32_t val)
+{
+ uint16_t ptp_error = PTP_RC_GeneralError;
+ OperFlags flags = { 0, 0, 1, 1, 3, 12 };
+ uint32_t params[3];
+
+ params[0] = 0x0000000C;
+ params[1] = (uint32_t)prop;
+ params[2] = val;
+
+ if ( (ptp_error = Transaction(EOS_OC_SetDevicePropValue, &flags, NULL, (void*)params)) != PTP_RC_OK)
+ PTPTRACE2("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(EOS_OC_GetDevicePropValue, &flags, params, (void*)parser)) != PTP_RC_OK)
+ PTPTRACE2("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(EOS_OC_GetDeviceInfoEx, &flags, NULL, (void*)parser)) != PTP_RC_OK)
+ PTPTRACE2("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(EOS_OC_GetObject, &flags, params, (void*)parser)) != PTP_RC_OK)
+ PTPTRACE2("GetObject error:", ptp_error);
+
+ return ptp_error;
+}
Oops, something went wrong.

0 comments on commit d2c7b4d

Please sign in to comment.