Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Major rewrite of PTP:Task state machine interface

  • Loading branch information...
commit afe6d262a6580957b49bf7bf5b629e9ed1e48ea4 1 parent 6085d65
@felis authored
View
129 canoneos.cpp
@@ -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;
}
View
226 canoneos.h
@@ -1,3 +1,18 @@
+/*****************************************************************************
+*
+* 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
+*****************************************************************************/
#ifndef __CANONEOS_H__
#define __CANONEOS_H__
@@ -7,52 +22,64 @@
#define PTP_OC_EOS_GetStorageIDs 0x9101
#define PTP_OC_EOS_GetStorageInfo 0x9102
#define PTP_OC_EOS_GetObject 0x9107
-#define PTP_OC_EOS_GetDeviceInfo 0x9108
+#define PTP_OC_EOS_GetDeviceInfoEx 0x9108
#define PTP_OC_EOS_GetObjectIDs 0x9109
-#define PTP_OC_EOS_Capture 0x910f
-#define PTP_OC_EOS_SetDevicePropValue 0x9110
+#define PTP_OC_EOS_Capture 0x910f
+#define PTP_OC_EOS_SetDevicePropValue 0x9110
#define PTP_OC_EOS_SetPCConnectMode 0x9114
-#define PTP_OC_EOS_SetExtendedEventInfo 0x9115
-#define PTP_OC_EOS_GetEvent 0x9116
-#define PTP_OC_EOS_GetLiveViewPicture 0x9153
+#define PTP_OC_EOS_SetExtendedEventInfo 0x9115
+#define PTP_OC_EOS_GetEvent 0x9116
+#define PTP_OC_EOS_TransferComplete 0x9117
+#define PTP_OC_EOS_CancelTransfer 0x9118
+#define PTP_OC_EOS_ResetTransfer 0x9119
+#define PTP_OC_EOS_GetDevicePropValue 0x9127
+#define PTP_OC_EOS_GetLiveViewPicture 0x9153
#define PTP_OC_EOS_MoveFocus 0x9155
// PTP Device Properties
-#define PTP_DPC_EOS_CameraDescription 0xD402
+#define PTP_DPC_EOS_CameraDescription 0xD402
// Non-PTP Device properties
-#define EOS_DPC_Aperture 0xD101
-#define EOS_DPC_Exposure 0xD102
-#define EOS_DPC_Iso 0xD103
-#define EOS_DPC_ExposureCorrection 0xD104
-#define EOS_DPC_ShootingMode 0xD105
-#define EOS_DPC_DriveMode 0xD106
-#define EOS_DPC_ExpMeterringMode 0xD107
-#define EOS_DPC_AFMode 0xD108
-#define EOS_DPC_WhiteBalance 0xD109
-#define EOS_DPC_PictureStyle 0xD110
-#define EOS_DPC_UnixTime 0xD113
-#define EOS_DPC_ImageQuality 0xD120
-#define EOS_DPC_LiveView 0xD1B0
+#define EOS_DPC_Aperture 0xD101
+#define EOS_DPC_Exposure 0xD102
+#define EOS_DPC_Iso 0xD103
+#define EOS_DPC_ExposureCorrection 0xD104
+#define EOS_DPC_ShootingMode 0xD105
+#define EOS_DPC_DriveMode 0xD106
+#define EOS_DPC_ExpMeterringMode 0xD107
+#define EOS_DPC_AFMode 0xD108
+#define EOS_DPC_WhiteBalance 0xD109
+#define EOS_DPC_PictureStyle 0xD110
+#define EOS_DPC_TransferOption 0xD111
+#define EOS_DPC_UnixTime 0xD113
+#define EOS_DPC_AvailableShots 0xD11B
+#define EOS_DPC_CaptureDestination 0xD11C //2-camera, 4-host, 6-both
+#define EOS_DPC_BracketMode 0xD11D
+#define EOS_DPC_ImageQuality 0xD120
+#define EOS_DPC_LiveView 0xD1B0 //0-off, 1-camera LCD, 2-PC
+#define EOS_DPC_EVFMode 0xD1B1
+#define EOS_DPC_EVFSharpness 0xD1B3
+#define EOS_DPC_EVFRecordStatus 0xD1B8 // 4 = start, 0 = stop
+#define EOS_DPC_LvViewTypeSelect 0xD1BC
+#define EOS_DPC_FocusInfoEx 0xD1D3
+#define EOS_DPC_LensID 0xD1DD
// Non-PTP Events
#define EOS_EC_DevPropChanged 0xC189
-//#define EOS_EC_ObjectCreated 0xC186
#define EOS_EC_ObjectCreated 0xC181
#define EOS_EC_DevPropValuesAccepted 0xC18A
#define EOS_EC_Capture 0xC18B
#define EOS_EC_HalfPushReleaseButton 0xC18E
-typedef bool (*MenuItemHandler)(PTP *p) ;
-struct TextMenuItem
+class EOSStateHandlers : public PTPStateHandlers
{
- const char *itemString;
- MenuItemHandler itemHandler;
- uint8_t bEnabled;
+public:
+ virtual void OnSessionOpenedState(PTP *ptp);
};
+
class ImgQualitySupplier : PTPDataSupplier
{
uint32_t pictFormat;
@@ -64,7 +91,7 @@ class ImgQualitySupplier : PTPDataSupplier
virtual void GetData(const uint16_t len, uint8_t *pbuf);
};
-class CanonEOS : public PTP //, public Camera
+class CanonEOS : public PTP
{
public:
enum { modeADEP=5, modeM=3, modeAv=2, modeTv=1, modeP=0, modeAuto=9, modePortrait=0xC, modeLandscape=0xD,
@@ -101,58 +128,65 @@ class CanonEOS : public PTP //, public Camera
ecMinus2 = 0xf0, //"-2"
};
- CanonEOS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPMAIN pfunc);
+ CanonEOS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPStateHandlers *s);
uint16_t SetPCConnectMode(uint8_t mode);
uint16_t SetExtendedEventInfo(uint8_t mode);
- uint16_t Initialize(bool binit);
-
- uint16_t Test();
-
uint16_t Capture();
uint16_t StartBulb();
uint16_t StopBulb();
uint16_t SwitchLiveView(bool on);
uint16_t MoveFocus(uint16_t step);
uint16_t SetProperty(uint16_t prop, uint32_t val);
+
+ uint16_t GetProperty(uint16_t prop, PTPReadParser *parser);
+
+ uint16_t GetDeviceInfoEx(PTPReadParser *parser);
uint16_t SetImageQuality(uint32_t format);
+ uint16_t GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser);
+ uint16_t ResetTransfer(uint32_t object_id);
+ uint16_t CancelTransfer(uint32_t object_id);
+
virtual uint16_t EventCheck(PTPReadParser *parser);
+ uint16_t DigitalZoom(uint16_t magnify);
+
};
+
template <class ValueType, const uint16_t ListSize>
-struct ValueList
+class ValueList
{
- uint16_t size;
- ValueType list[ListSize];
+public:
+ uint16_t listSize;
+ ValueType valueList[ListSize];
+ ValueType currentValue;
- ValueType GetNext(ValueType val)
+ ValueType GetNext()
{
- for (uint8_t i=0; i<ListSize; i++)
- {
- //Serial.println(list[i],HEX);
-
- if (list[i] == val)
- return ((i+1 < size) ? list[i+1] : val);
- }
- return val;
+ for (uint16_t i=0; i<listSize; i++)
+ if (valueList[i] == currentValue)
+ return ((i+1 < listSize) ? valueList[i+1] : currentValue);
+
+ return currentValue;
};
- ValueType GetPrev(ValueType val)
+ ValueType GetPrev()
{
- for (uint8_t i=0; i<ListSize; i++)
- {
- //Serial.println(list[i],HEX);
-
- if (list[i] == val)
- return ((i-1 >= 0) ? list[i-1] : val);
- }
- return val;
+ for (uint16_t i=0; i<listSize; i++)
+ if (valueList[i] == currentValue)
+ return ((i-1 >= 0) ? valueList[i-1] : currentValue);
+
+ return currentValue;
};
};
-#define MAX_APERTURE_LIST_SIZE 24
-#define MAX_SHUTTER_SPEED_LIST_SIZE 64
+
+
+#define MAX_APERTURE_LIST_SIZE 32
+
+#define MAX_SHUTTER_SPEED_LIST_SIZE 64
+
typedef ValueList<uint8_t, MAX_APERTURE_LIST_SIZE> APERTURE_VALUE_LIST;
typedef ValueList<uint8_t, MAX_SHUTTER_SPEED_LIST_SIZE> SHUTTER_SPEED_VALUE_LIST;
@@ -175,4 +209,86 @@ const char* FindTitle(uint8_t size, const ValueTitle<ValueType, TitleSize> *p, V
return PSTR("N/A");
}
+
+#include <avr/eeprom.h>
+
+class EEPROMByteList
+{
+ const uint16_t listOffset;
+ const uint8_t maxListSize;
+ uint8_t listSize;
+
+ uint16_t GetValueAddress(uint8_t val)
+ {
+ uint16_t tail = listOffset+listSize+2;
+
+ for (uint16_t i=listOffset+1; i<tail; i++)
+ if (eeprom_read_byte((uint8_t*)i) == val)
+ return i;
+
+ return 0xffff;
+ };
+
+public:
+ EEPROMByteList(uint16_t list_offset, uint16_t max_size) : listOffset(list_offset), maxListSize(max_size), listSize(0)
+ {
+ };
+
+ void SetSize(uint8_t size)
+ {
+ listSize = (size < maxListSize) ? size : maxListSize;
+
+ if (eeprom_read_byte((uint8_t*) listOffset) != listSize)
+ eeprom_write_byte((uint8_t*) listOffset, listSize);
+ };
+
+ uint8_t GetSize()
+ {
+ return listSize;
+ };
+
+
+ uint8_t Get(uint8_t i)
+ {
+ return (eeprom_read_byte((uint8_t*)(listOffset + 1 + ((i < listSize) ? i : listOffset+listSize-1))));
+ };
+
+ void Set(uint8_t i, uint8_t val)
+ {
+ if (i < listSize)
+ {
+ uint16_t pos = listOffset + i + 1;
+
+ if (eeprom_read_byte((uint8_t*) pos) != val)
+ eeprom_write_byte((uint8_t*) pos, val);
+ }
+ };
+
+ uint8_t GetNext(uint8_t val, uint8_t di=1)
+ {
+ uint16_t addr = GetValueAddress(val);
+
+ uint16_t tail = listOffset+listSize;
+
+ if (addr == 0xffff)
+ return eeprom_read_byte((uint8_t*)tail);
+
+ addr += di;
+
+ return eeprom_read_byte((uint8_t*)((addr > tail) ? tail : addr));
+ };
+
+ uint8_t GetPrev(uint8_t val, uint8_t di=1)
+ {
+ uint16_t addr = GetValueAddress(val);
+
+ if (addr == 0xffff)
+ return eeprom_read_byte((uint8_t*)(listOffset+1));
+
+ addr -= di;
+
+ return eeprom_read_byte((uint8_t*)((addr <= listOffset) ? listOffset+1 : addr));
+ };
+};
+
#endif // __CANONEOS_H__
View
134 canonps.cpp
@@ -1,134 +0,0 @@
-#include "canonps.h"
-
-CanonPS::CanonPS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPMAIN pfunc)
-: PTP(addr, epin, epout, epint, nconf, pfunc)
-{
-}
-
-uint16_t CanonPS::EventCheck(PTPReadParser *parser)
-{
- uint16_t ptp_error = PTP_RC_GeneralError;
- OperFlags flags = { 0, 0, 0, 1, 1, 0 };
-
- if ( (ptp_error = Transaction(PTP_OC_PS_CheckEvent, &flags, NULL, parser)) != PTP_RC_OK)
- Message(PSTR("EOSEventCheck: Error."), ptp_error);
-
- return ptp_error;
-}
-
-uint16_t CanonPS::Initialize(bool binit)
-{
- uint16_t ptp_error;
-
- if (binit)
- {
- if ((ptp_error = Operation(PTP_OC_PS_StartShootingMode, 0, NULL)) != PTP_RC_OK)
- Message(PSTR("PC Connect mode failed: "), ptp_error);
- }
- else
- {
- if ((ptp_error = Operation(PTP_OC_PS_EndShootingMode, 0, NULL)) != PTP_RC_OK)
- Message(PSTR("PC Connect mode failed: "), ptp_error);
- }
- return ptp_error;
-}
-
-uint16_t CanonPS::Capture()
-{
- uint16_t ptp_error;
-
- if ((ptp_error = Operation(PTP_OC_PS_FocusLock, 0, NULL)) != PTP_RC_OK)
- Message(PSTR("Focus Lock: Error: "), ptp_error);
-
- if ((ptp_error = Operation(PTP_OC_PS_InitiateCaptureInMemory, 0, NULL)) != PTP_RC_OK)
- Message(PSTR("Capture: Error: "), ptp_error);
-
- return ptp_error;
-}
-
-#if 0
-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);
- delay(50);
- Operation(0x911C, 0, NULL);
- delay(50);
-}
-
-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)
- {
- Message(PSTR("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(PTP_OC_EOS_MoveFocus, &flags, params, NULL)) != PTP_RC_OK)
- Message(PSTR("MoveFocus: Error."), ptp_error);
- else
- Message(PSTR("MoveFocus: Success."), ptp_error);
-
- return ptp_error;
-}
-
-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(PTP_OC_EOS_SetDevicePropValue, &flags, NULL, (void*)params)) != PTP_RC_OK)
- Message(PSTR("SetProperty: Error."), ptp_error);
-
- return ptp_error;
-}
-#endif
-
View
195 canonps.h
@@ -1,195 +0,0 @@
-#ifndef __CANONPS_H__
-#define __CANONPS_H__
-
-#include "ptp.h"
-
-// PTP Operation Codes (PowerSot specific)
-#define PTP_OC_PS_GetObjectSize 0x9001
-#define PTP_OC_PS_StartShootingMode 0x9008
-#define PTP_OC_PS_EndShootingMode 0x9009
-#define PTP_OC_PS_ViewfinderOn 0x900B
-#define PTP_OC_PS_ViewfinderOff 0x900C
-#define PTP_OC_PS_ReflectChanges 0x900D
-#define PTP_OC_PS_CheckEvent 0x9013
-#define PTP_OC_PS_FocusLock 0x9014
-#define PTP_OC_PS_FocusUnlock 0x9015
-#define PTP_OC_PS_InitiateCaptureInMemory 0x901A
-#define PTP_OC_PS_GetPartialObject 0x901B
-#define PTP_OC_PS_GetViewfinderImage 0x901d
-#define PTP_OC_PS_GetChanges 0x9020
-#define PTP_OC_PS_GetFolderEntries 0x9021
-
-// PTP PowerShot Extention Events
-#define PTP_EC_PS_ObjectCreated 0xC008
-#define PTP_EC_PS_RequestObjectTransfer 0xC009
-#define PTP_EC_PS_CameraModeChanged 0xC00C
-#define PTP_EC_PS_StorageInfoChanged 0xC00D // ??
-
- // PTP Device Properties
-//#define PTP_DPC_EOS_CameraDescription 0xD402
-
-
-// PowerShot-specific Device Properties
-#define PS_DPC_BeepMode 0xD001
-#define PS_DPC_BatteryKind 0xD002
-#define PS_DPC_BatteryStatus 0xD003
-#define PS_DPC_UILockType 0xD004
-#define PS_DPC_CameraMode 0xD005
-#define PS_DPC_ImageQuality 0xD006
-#define PS_DPC_FullViewFileFormat 0xD007
-#define PS_DPC_ImageSize 0xD008
-#define PS_DPC_SelfTime 0xD009
-#define PS_DPC_FlashMode 0xD00A
-#define PS_DPC_Beep 0xD00B
-#define PS_DPC_ShootingMode 0xD00C
-#define PS_DPC_ImageMode 0xD00D
-#define PS_DPC_DriveMode 0xD00E
-#define PS_DPC_EZoom 0xD00F
-#define PS_DPC_MeteringMode 0xD010
-#define PS_DPC_AFDistance 0xD011
-#define PS_DPC_FocusingPoint 0xD012
-#define PS_DPC_WhiteBalance 0xD013
-#define PS_DPC_SlowShutterSetting 0xD014
-#define PS_DPC_AFMode 0xD015
-#define PS_DPC_ImageStabilization 0xD016
-#define PS_DPC_Contrast 0xD017
-#define PS_DPC_ColorGain 0xD018
-#define PS_DPC_Sharpness 0xD019
-#define PS_DPC_Sensitivity 0xD01A
-#define PS_DPC_ParameterSet 0xD01B
-#define PS_DPC_ISOSpeed 0xD01C
-#define PS_DPC_Aperture 0xD01D
-#define PS_DPC_ShutterSpeed 0xD01E
-#define PS_DPC_ExpCompensation 0xD01F
-#define PS_DPC_FlashCompensation 0xD020
-#define PS_DPC_AEBExposureCompensation 0xD021
-#define PS_DPC_AvOpen 0xD023
-#define PS_DPC_AvMax 0xD024
-#define PS_DPC_FocalLength 0xD025
-#define PS_DPC_FocalLengthTele 0xD026
-#define PS_DPC_FocalLengthWide 0xD027
-#define PS_DPC_FocalLengthDenominator 0xD028
-#define PS_DPC_CaptureTransferMode 0xD029
-#define PS_DPC_Zoom 0xD02A
-#define PS_DPC_NamePrefix 0xD02B
-#define PS_DPC_SizeQualityMode 0xD02C
-#define PS_DPC_SupportedThumbSize 0xD02D
-#define PS_DPC_SizeOfOutputDataFromCamera 0xD02E
-#define PS_DPC_SizeOfInputDataToCamera 0xD02F
-#define PS_DPC_RemoteAPIVersion 0xD030
-#define PS_DPC_FirmwareVersion 0xD031
-#define PS_DPC_CameraModel 0xD032
-#define PS_DPC_CameraOwner 0xD033
-#define PS_DPC_UnixTime 0xD034
-#define PS_DPC_CameraBodyID 0xD035
-#define PS_DPC_CameraOutput 0xD036
-#define PS_DPC_DispAv 0xD037
-#define PS_DPC_AvOpenApex 0xD038
-#define PS_DPC_DZoomMagnification 0xD039
-#define PS_DPC_MlSpotPos 0xD03A
-#define PS_DPC_DispAvMax 0xD03B
-#define PS_DPC_AvMaxApex 0xD03C
-#define PS_DPC_EZoomStartPosition 0xD03D
-#define PS_DPC_FocalLengthOfTele 0xD03E
-#define PS_DPC_EZoomSizeOfTele 0xD03F
-#define PS_DPC_PhotoEffect 0xD040
-#define PS_DPC_AssistLight 0xD041
-#define PS_DPC_FlashQuantityCount 0xD042
-#define PS_DPC_RotationAngle 0xD043
-#define PS_DPC_RotationScene 0xD044
-#define PS_DPC_EventEmulateMode 0xD045
-#define PS_DPC_DPOFVersion 0xD046
-#define PS_DPC_TypeOfSupportedSlideShow 0xD047
-#define PS_DPC_AverageFilesizes 0xD048
-#define PS_DPC_ModelID 0xD049
-
-
-
-
-
-// Non-PTP Device properties
-#define PS_DPC_BeepMode 0xD001
-#define PS_DPC_ViewfinderMode 0xD003
-#define PS_DPC_ImageQuality 0xD006
-#define PS_DPC_D007 0xD007
-#define PS_DPC_ImageSize 0xD008
-#define PS_DPC_FlashMode 0xD00A
-#define PS_DPC_TvAvSetting 0xD00C
-#define PS_DPC_MeteringMode 0xD010
-#define PS_DPC_MacroMode 0xD011
-#define PS_DPC_FocusingPoint 0xD012
-#define PS_DPC_WhiteBalance 0xD013
-#define PS_DPC_ISOSpeed 0xD01C
-#define PS_DPC_Aperture 0xD01D
-#define PS_DPC_ShutterSpeed 0xD01E
-#define PS_DPC_ExpCompensation 0xD01F
-#define PS_DPC_D029 0xD029
-#define PS_DPC_Zoom 0xD02A
-#define PS_DPC_SizeQualityMode 0xD02C
-#define PS_DPC_FlashMemory 0xD031
-#define PS_DPC_CameraModel 0xD032
-#define PS_DPC_CameraOwner 0xD033
-#define PS_DPC_UnixTime 0xD034
-#define PS_DPC_ViewfinderOutput 0xD036
-#define PS_DPC_RealImageWidth 0xD039
-#define PS_DPC_PhotoEffect 0xD040
-#define PS_DPC_AssistLight 0xD041
-#define PS_DPC_D045 0xD045
-
-
-
-
-// PowerShot-specific Event Codes
-#define PS_EC_ExtendedErrorcode 0xC005 /* ? */
-#define PS_EC_ObjectInfoChanged 0xC008
-#define PS_EC_RequestObjectTransfer 0xC009
-#define PS_EC_CameraModeChanged 0xC00C
-
-#define PS_EC_StartDirectTransfer 0xC011
-#define PS_EC_StopDirectTransfer 0xC013
-
-
-
-// Non-PTP Events
-#define EOS_EC_DevPropChanged 0xC189
-#define EOS_EC_ObjectCreated 0xC186
-
-
-
-class CanonPS : public PTP //, public Camera
-{
-public:
- // ISO Speed Values
- enum { IsoAuto = 0, Iso80 = 0x45, Iso100 = 0x48, Iso200 = 0x50, Iso400 = 0x58, Iso800=0x60 };
-
- // White Balance Values
- enum { WbAuto = 0, WbSunny, WbCloudy, WbTungsten, WbFluorescent, WbFlash, WbCustom, WbUnknown };
-
- // Exposure Compensation Values (same values for both exposure compensation and flash compensation)
- enum { ExpCompDown2 = 0x08, ExpCompDown1_2d3= 0x0B, ExpCompDown1_1d3= 0x0D, ExpCompDown1 = 0x10, ExpCompDown2d3 = 0x13,
- ExpCompDown1d3 = 0x15, ExpComp_0 = 18, ExpCompUp1d3 = 0x1B, ExpCompUp2d3 = 0x1D, ExpCompUp1 = 0x20,
- ExpCompUp1_1d3 = 0x23, ExpCompUp1_2d3 = 0x25, ExpCompUp2 = 0x28 };
-
- // Image Quality Values
- enum { ImgQualityNormal = 2, ImageQualityFine = 3, ImageQualitySuperb = 5 };
-
- // Image Size Values
- enum { ImgSizeLarge, ImgSizeMedium1, ImgSizeSmall, ImgSizeMedium2 };
-
- CanonPS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPMAIN pfunc);
-
- uint16_t Initialize(bool binit);
-
- uint16_t Capture();
- //uint16_t StartBulb();
- //uint16_t StopBulb();
- //uint16_t SwitchLiveView(bool on);
- //uint16_t MoveFocus(uint16_t step);
- //uint16_t SetProperty(uint16_t prop, uint32_t val);
-
-
- uint16_t EventCheck(PTPReadParser *parser);
-
-};
-
-#endif // __CANONPS_H__
View
15 copying.txt
@@ -0,0 +1,15 @@
+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 (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
View
53 examples/EOSCapture.pde
@@ -1,53 +0,0 @@
-/* EOS Capture Example. Works with the following cameras: */
-/* 400D, 450D(XSi), 40D, 5D Mark II, 7D */
-#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();
- }
-}
-
View
84 examples/EOSEventLab/EOSEventLab.pde
@@ -0,0 +1,84 @@
+#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 <ptpdebug.h>
+#include <canoneos.h>
+#include <simpletimer.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();
+
+class CamStateHandlers : public EOSStateHandlers
+{
+ bool stateConnected;
+
+public:
+ CamStateHandlers() : stateConnected(false) {};
+
+ virtual void OnDeviceDisconnectedState(PTP *ptp);
+ virtual void OnDeviceInitializedState(PTP *ptp);
+};
+
+CamStateHandlers CamStates;
+SimpleTimer PTPPollTimer;
+CanonEOS Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates);
+
+
+void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
+{
+ if (stateConnected)
+ {
+ stateConnected = false;
+ PTPPollTimer.Disable();
+ Notify(PSTR("\r\nDevice disconnected.\r\n"));
+ }
+}
+
+void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
+{
+ if (!stateConnected)
+ {
+ stateConnected = true;
+ PTPPollTimer.Enable();
+ }
+}
+
+void OnPTPPollTimer()
+{
+ EOSEventDump hex;
+ Eos.EventCheck(&hex);
+}
+
+void setup()
+{
+ Serial.begin( 115200 );
+ Serial.println("Start");
+ Eos.Setup();
+ delay( 200 );
+ PTPPollTimer.Set(OnPTPPollTimer, 500);
+}
+
+void loop()
+{
+ Eos.Task();
+ PTPPollTimer.Run();
+}
+
View
47 examples/PTPDevInfo/PTPDevInfo.pde
@@ -19,29 +19,36 @@
#define INTERRUPT_EP 3
#define CONFIG_NUM 1
-#define MAX_USB_STRING_LEN 64
-
void setup();
void loop();
-void ptpmain();
-PTP Ptp(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, (PTPMAIN)&ptpmain);
+class CamStateHandlers : public PTPStateHandlers
+{
+ bool stateConnected;
+
+public:
+ CamStateHandlers() : stateConnected(false) {};
+
+ virtual void OnDeviceDisconnectedState(PTP *ptp);
+ virtual void OnDeviceInitializedState(PTP *ptp);
+} CamStates;
-void setup() {
- Serial.begin( 9600 );
- Serial.println("Start");
- Ptp.Setup();
- delay( 200 );
-}
+PTP Ptp(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates);
-void loop() {
- Ptp.Task();
+void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
+{
+ if (stateConnected)
+ {
+ stateConnected = false;
+ Notify(PSTR("Camera disconnected\r\n"));
+ }
}
-void ptpmain()
+void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
{
- if (Ptp.OpenSession() == PTP_RC_OK)
+ if (!stateConnected)
{
+ stateConnected = true;
{
HexDump dmp;
Ptp.GetDeviceInfo(&dmp);
@@ -51,7 +58,17 @@ void ptpmain()
DevInfoParser prs;
Ptp.GetDeviceInfo(&prs);
}
- Ptp.CloseSession();
}
}
+
+void setup() {
+ Serial.begin( 115200 );
+ Serial.println("Start");
+ Ptp.Setup();
+ delay( 200 );
+}
+
+void loop() {
+ Ptp.Task();
+}
View
1,268 examples/PTPDevInfo/devinfoparser.cpp
@@ -1,275 +1,275 @@
-#include "devinfoparser.h"
-
-const char* DevInfoParser::ptpopNames[] PROGMEM =
-{
- msgUndefined,
- msgGetDeviceInfo,
- msgOpenSession,
- msgCloseSession,
- msgGetStorageIDs,
- msgGetStorageInfo,
- msgGetNumObjects,
- msgGetObjectHandles,
- msgGetObjectInfo,
- msgGetObject,
- msgGetThumb,
- msgDeleteObject,
- msgSendObjectInfo,
- msgSendObject,
- msgInitiateCapture,
- msgFormatStore,
- msgResetDevice,
- msgSelfTest,
- msgSetObjectProtection,
- msgPowerDown,
- msgGetDevicePropDesc,
- msgGetDevicePropValue,
- msgSetDevicePropValue,
- msgResetDevicePropValue,
- msgTerminateOpenCapture,
- msgMoveObject,
- msgCopyObject,
- msgGetPartialObject,
- msgInitiateOpenCapture
-};
-
-const char* DevInfoParser::mtpopNames[] PROGMEM =
-{
- msgUndefined,
- msgGetObjectPropsSupported,
- msgGetObjectPropDesc,
- msgGetObjectPropValue,
- msgSetObjectPropValue,
- msgGetObjectPropList,
- msgSetObjectPropList,
- msgGetInterdependentPropDesc,
- msgSendObjectPropList
-};
-
-const char* DevInfoParser::ptpevNames[] PROGMEM =
-{
- msgUndefined,
- msgCancelTransaction,
- msgObjectAdded,
- msgObjectRemoved,
- msgStoreAdded,
- msgStoreRemoved,
- msgDevicePropChanged,
- msgObjectInfoChanged,
- msgDeviceInfoChanged,
- msgRequestObjectTransfer,
- msgStoreFull,
- msgDeviceReset,
- msgStorageInfoChanged,
- msgCaptureComplete,
- msgUnreportedStatus
-};
-
-const char* DevInfoParser::mtpevNames[] PROGMEM =
-{
- msgUndefined,
- msgObjectPropChanged,
- msgObjectPropDescChanged,
- msgObjectReferencesChanged
-};
-
-const char* DevInfoParser::ptpprNames[] PROGMEM =
-{
- msgUndefined,
- msgBatteryLevel,
- msgFunctionalMode,
- msgImageSize,
- msgCompressionSetting,
- msgWhiteBalance,
- msgRGBGain,
- msgFNumber,
- msgFocalLength,
- msgFocusDistance,
- msgFocusMode,
- msgExposureMeteringMode,
- msgFlashMode,
- msgExposureTime,
- msgExposureProgramMode,
- msgExposureIndex,
- msgExposureBiasCompensation,
- msgDateTime,
- msgCaptureDelay,
- msgStillCaptureMode,
- msgContrast,
- msgSharpness,
- msgDigitalZoom,
- msgEffectMode,
- msgBurstNumber,
- msgBurstInterval,
- msgTimelapseNumber,
- msgTimelapseInterval,
- msgFocusMeteringMode,
- msgUploadURL,
- msgArtist,
- msgCopyrightInfo
-};
-
-const char* DevInfoParser::mtpprNames[] PROGMEM =
-{
- msgUndefined,
- msgSynchronization_Partner,
- msgDevice_Friendly_Name,
- msgVolume,
- msgSupportedFormatsOrdered,
- msgDeviceIcon,
- msgSession_Initiator_Version_Info,
- msgPerceived_Device_Type,
- msgPlayback_Rate,
- msgPlayback_Object,
- msgPlayback_Container
-};
-
-const char* DevInfoParser::acNames[] PROGMEM =
-{
- msgUndefined,
- msgAssociation,
- msgScript,
- msgExecutable,
- msgText,
- msgHTML,
- msgDPOF,
- msgAIFF,
- msgWAV,
- msgMP3,
- msgAVI,
- msgMPEG,
- msgASF,
- msgQT
-};
-
-const char* DevInfoParser::imNames[] PROGMEM =
-{
- msgUndefined,
- msgEXIF_JPEG,
- msgTIFF_EP,
- msgFlashPix,
- msgBMP,
- msgCIFF,
- msgUndefined_0x3806,
- msgGIF,
- msgJFIF,
- msgPCD,
- msgPICT,
- msgPNG,
- msgUndefined_0x380C,
- msgTIFF,
- msgTIFF_IT,
- msgJP2,
- msgJPX,
-};
-
-DevInfoParser::DevInfoParser() :
- nStage(0),
- strByteCountDown(0),
- waStage(0),
- waLenCountDown(0),
- waByteCountDown(0),
- fmByteCountDown(0),
- idVendor(0)
-{
- for (uint8_t i=0; i<4; i++) waLen[i];
- waWord.word = 0;
- fmBytes[0] = 0;
- fmBytes[1] = 0;
-};
-
-bool DevInfoParser::PrintFunctMode(uint8_t **pp, uint16_t &count)
-{
- if (!count)
- return true;
-
- if (!fmByteCountDown)
- fmByteCountDown = 2;
-
- for (; fmByteCountDown && count; fmByteCountDown--, count--, (*pp)++)
- fmBytes[fmByteCountDown & 1] = (**pp);
-
- if (fmByteCountDown)
- return false;
-
- Notify(PSTR("Func.Mode:\t0x")); Serial.println((uint16_t)fmBytes, HEX);
- return true;
-}
-
-void DevInfoParser::PrintOperation(uint16_t op)
-{
- bool bResult = false;
-
- Serial.print(op, HEX);
- Notify(msgTab);
-
- switch (((op >> 8) & 0xFF))
- {
- case 0x10:
- bResult = PrintPTPOperation(op);
- break;
- case 0x98:
- bResult = PrintMTPOperation(op);
- break;
- default:
- switch (idVendor)
- {
- case PTP_VENDOR_MICROSOFT:
- case PTP_VENDOR_CANON:
- if ((bResult = PrintPSOperation(op)))
- break;
- bResult = PrintEOSOperation(op);
- break;
- default:
- Notify(msgVendorDefined);
- bResult = true;
- }
- }
- if (!bResult)
- Notify(msgVendorDefined);
- Notify(msgCRLF);
-}
-
-bool DevInfoParser::PrintPTPOperation(uint16_t op)
-{
- if ((op & 0xFF) <= (PTP_OC_InitiateOpenCapture & 0xFF))
- {
- Notify((char*)pgm_read_word(&ptpopNames[(op & 0xFF)]));
- return true;
- }
- return false;
-}
-
-bool DevInfoParser::PrintMTPOperation(uint16_t op)
-{
- if ((op & 0xFF) <= (MTP_OC_SendObjectPropList & 0xFF))
- Notify((char*)pgm_read_word(&mtpopNames[(op & 0xFF)]));
- else
- {
- switch (op)
- {
- case MTP_OC_GetObjectReferences:
- Notify(msgGetObjectReferences);
- break;
- case MTP_OC_SetObjectReferences:
- Notify(msgSetObjectReferences);
- break;
- case MTP_OC_Skip:
- Notify(msgSkip);
- break;
- default:
- return false;
- }
- }
- return true;
-}
-
-bool DevInfoParser::PrintPSOperation(uint16_t op)
-{
- const char* msg;
-
- switch (op)
- {
+#include "devinfoparser.h"
+
+const char* DevInfoParser::ptpopNames[] PROGMEM =
+{
+ msgUndefined,
+ msgGetDeviceInfo,
+ msgOpenSession,
+ msgCloseSession,
+ msgGetStorageIDs,
+ msgGetStorageInfo,
+ msgGetNumObjects,
+ msgGetObjectHandles,
+ msgGetObjectInfo,
+ msgGetObject,
+ msgGetThumb,
+ msgDeleteObject,
+ msgSendObjectInfo,
+ msgSendObject,
+ msgInitiateCapture,
+ msgFormatStore,
+ msgResetDevice,
+ msgSelfTest,
+ msgSetObjectProtection,
+ msgPowerDown,
+ msgGetDevicePropDesc,
+ msgGetDevicePropValue,
+ msgSetDevicePropValue,
+ msgResetDevicePropValue,
+ msgTerminateOpenCapture,
+ msgMoveObject,
+ msgCopyObject,
+ msgGetPartialObject,
+ msgInitiateOpenCapture
+};
+
+const char* DevInfoParser::mtpopNames[] PROGMEM =
+{
+ msgUndefined,
+ msgGetObjectPropsSupported,
+ msgGetObjectPropDesc,
+ msgGetObjectPropValue,
+ msgSetObjectPropValue,
+ msgGetObjectPropList,
+ msgSetObjectPropList,
+ msgGetInterdependentPropDesc,
+ msgSendObjectPropList
+};
+
+const char* DevInfoParser::ptpevNames[] PROGMEM =
+{
+ msgUndefined,
+ msgCancelTransaction,
+ msgObjectAdded,
+ msgObjectRemoved,
+ msgStoreAdded,
+ msgStoreRemoved,
+ msgDevicePropChanged,
+ msgObjectInfoChanged,
+ msgDeviceInfoChanged,
+ msgRequestObjectTransfer,
+ msgStoreFull,
+ msgDeviceReset,
+ msgStorageInfoChanged,
+ msgCaptureComplete,
+ msgUnreportedStatus
+};
+
+const char* DevInfoParser::mtpevNames[] PROGMEM =
+{
+ msgUndefined,
+ msgObjectPropChanged,
+ msgObjectPropDescChanged,
+ msgObjectReferencesChanged
+};
+
+const char* DevInfoParser::ptpprNames[] PROGMEM =
+{
+ msgUndefined,
+ msgBatteryLevel,
+ msgFunctionalMode,
+ msgImageSize,
+ msgCompressionSetting,
+ msgWhiteBalance,
+ msgRGBGain,
+ msgFNumber,
+ msgFocalLength,
+ msgFocusDistance,
+ msgFocusMode,
+ msgExposureMeteringMode,
+ msgFlashMode,
+ msgExposureTime,
+ msgExposureProgramMode,
+ msgExposureIndex,
+ msgExposureBiasCompensation,
+ msgDateTime,
+ msgCaptureDelay,
+ msgStillCaptureMode,
+ msgContrast,
+ msgSharpness,
+ msgDigitalZoom,
+ msgEffectMode,
+ msgBurstNumber,
+ msgBurstInterval,
+ msgTimelapseNumber,
+ msgTimelapseInterval,
+ msgFocusMeteringMode,
+ msgUploadURL,
+ msgArtist,
+ msgCopyrightInfo
+};
+
+const char* DevInfoParser::mtpprNames[] PROGMEM =
+{
+ msgUndefined,
+ msgSynchronization_Partner,
+ msgDevice_Friendly_Name,
+ msgVolume,
+ msgSupportedFormatsOrdered,
+ msgDeviceIcon,
+ msgSession_Initiator_Version_Info,
+ msgPerceived_Device_Type,
+ msgPlayback_Rate,
+ msgPlayback_Object,
+ msgPlayback_Container
+};
+
+const char* DevInfoParser::acNames[] PROGMEM =
+{
+ msgUndefined,
+ msgAssociation,
+ msgScript,
+ msgExecutable,
+ msgText,
+ msgHTML,
+ msgDPOF,
+ msgAIFF,
+ msgWAV,
+ msgMP3,
+ msgAVI,
+ msgMPEG,
+ msgASF,
+ msgQT
+};
+
+const char* DevInfoParser::imNames[] PROGMEM =
+{
+ msgUndefined,
+ msgEXIF_JPEG,
+ msgTIFF_EP,
+ msgFlashPix,
+ msgBMP,
+ msgCIFF,
+ msgUndefined_0x3806,
+ msgGIF,
+ msgJFIF,
+ msgPCD,
+ msgPICT,
+ msgPNG,
+ msgUndefined_0x380C,
+ msgTIFF,
+ msgTIFF_IT,
+ msgJP2,
+ msgJPX,
+};
+
+DevInfoParser::DevInfoParser() :
+ nStage(0),
+ strByteCountDown(0),
+ waStage(0),
+ waLenCountDown(0),
+ waByteCountDown(0),
+ fmByteCountDown(0),
+ idVendor(0)
+{
+ for (uint8_t i=0; i<4; i++) waLen[i];
+ waWord.word = 0;
+ fmBytes[0] = 0;
+ fmBytes[1] = 0;
+};
+
+bool DevInfoParser::PrintFunctMode(uint8_t **pp, uint16_t &count)
+{
+ if (!count)
+ return true;
+
+ if (!fmByteCountDown)
+ fmByteCountDown = 2;
+
+ for (; fmByteCountDown && count; fmByteCountDown--, count--, (*pp)++)
+ fmBytes[fmByteCountDown & 1] = (**pp);
+
+ if (fmByteCountDown)
+ return false;
+
+ Notify(PSTR("Func.Mode:\t0x")); Serial.println((uint16_t)fmBytes, HEX);
+ return true;
+}
+
+void DevInfoParser::PrintOperation(uint16_t op)
+{
+ bool bResult = false;
+
+ Serial.print(op, HEX);
+ Notify(msgTab);
+
+ switch (((op >> 8) & 0xFF))
+ {
+ case 0x10:
+ bResult = PrintPTPOperation(op);
+ break;
+ case 0x98:
+ bResult = PrintMTPOperation(op);
+ break;
+ default:
+ switch (idVendor)
+ {
+ case PTP_VENDOR_MICROSOFT:
+ case PTP_VENDOR_CANON:
+ if ((bResult = PrintPSOperation(op)))
+ break;
+ bResult = PrintEOSOperation(op);
+ break;
+ default:
+ Notify(msgVendorDefined);
+ bResult = true;
+ }
+ }
+ if (!bResult)
+ Notify(msgVendorDefined);
+ Notify(msgCRLF);
+}
+
+bool DevInfoParser::PrintPTPOperation(uint16_t op)
+{
+ if ((op & 0xFF) <= (PTP_OC_InitiateOpenCapture & 0xFF))
+ {
+ Notify((char*)pgm_read_word(&ptpopNames[(op & 0xFF)]));
+ return true;
+ }
+ return false;
+}
+
+bool DevInfoParser::PrintMTPOperation(uint16_t op)
+{
+ if ((op & 0xFF) <= (MTP_OC_SendObjectPropList & 0xFF))
+ Notify((char*)pgm_read_word(&mtpopNames[(op & 0xFF)]));
+ else
+ {
+ switch (op)
+ {
+ case MTP_OC_GetObjectReferences:
+ Notify(msgGetObjectReferences);
+ break;
+ case MTP_OC_SetObjectReferences:
+ Notify(msgSetObjectReferences);
+ break;
+ case MTP_OC_Skip:
+ Notify(msgSkip);
+ break;
+ default:
+ return false;
+ }
+ }
+ return true;
+}
+
+bool DevInfoParser::PrintPSOperation(uint16_t op)
+{
+ const char* msg;
+
+ switch (op)
+ {
case PTP_OC_PS_GetObjectSize:
msg = msgPS_GetObjectSize;
break;
@@ -314,16 +314,16 @@ bool DevInfoParser::PrintPSOperation(uint16_t op)
break;
default:
return false;
- }
- Notify(msg);
- return true;
-}
-
-bool DevInfoParser::PrintEOSOperation(uint16_t op)
-{
- const char *msg;
- switch (op)
- {
+ }
+ Notify(msg);
+ return true;
+}
+
+bool DevInfoParser::PrintEOSOperation(uint16_t op)
+{
+ const char *msg;
+ switch (op)
+ {
case PTP_OC_EOS_GetStorageIDs:
msg = msgEOS_GetStorageIDs;
break;
@@ -360,355 +360,355 @@ bool DevInfoParser::PrintEOSOperation(uint16_t op)
case PTP_OC_EOS_MoveFocus:
msg = msgEOS_MoveFocus;
break;
- default:
- return false;
- }
- Notify(msg);
- return true;
-}
-
-void DevInfoParser::PrintEvent(uint16_t op)
-{
- Serial.print(op, HEX);
- Notify(msgTab);
-
- if ((((op >> 8) & 0xFF) == 0x40) && ((op & 0xFF) <= (PTP_EC_UnreportedStatus & 0xFF)))
- Notify((char*)pgm_read_word(&ptpevNames[(op & 0xFF)]));
- else
- if ((((op >> 8) & 0xFF) == 0xC8) && ((op & 0xFF) <= (MTP_EC_ObjectReferencesChanged & 0xFF)))
- Notify((char*)pgm_read_word(&mtpevNames[(op & 0xFF)]));
- else
- Notify(msgVendorDefined);
- Notify(msgCRLF);
-}
-
-void DevInfoParser::PrintDevProp(uint16_t op)
-{
- Serial.print(op, HEX);
- Notify(msgTab);
-
- if ((((op >> 8) & 0xFF) == 0x50) && ((op & 0xFF) <= (PTP_DPC_CopyrightInfo & 0xFF)))
- Notify((char*)pgm_read_word(&ptpprNames[(op & 0xFF)]));
- else
- if (((op >> 8) & 0xFF) == 0xD4)
- {
- if ( (op & 0xFF) <= (MTP_DPC_Perceived_Device_Type & 0xFF) )
- Notify((char*)pgm_read_word(&mtpprNames[(op & 0xFF)]));
- else
- {
- switch (op)
- {
- case MTP_DPC_Playback_Rate:
- Notify(msgPlayback_Rate);
- break;
- case MTP_DPC_Playback_Object:
- Notify(msgPlayback_Object);
- break;
- case MTP_DPC_Playback_Container:
- Notify(msgPlayback_Container);
- break;
- default:
- Notify(msgVendorDefined);
- }
- }
- }
- else
- Notify(msgVendorDefined);
-
- Notify(msgCRLF);
-}
-
-void DevInfoParser::PrintFormat(uint16_t op)
-{
- Serial.print(op, HEX);
- Notify(msgTab);
-
- if ((((op >> 8) & 0xFF) == 0x30) && ((op & 0xFF) <= (PTP_OFC_QT & 0xFF)))
- Notify((char*)pgm_read_word(&acNames[(op & 0xFF)]));
- else
- if ((((op >> 8) & 0xFF) == 0x38) && ((op & 0xFF) <= (PTP_OFC_JPX & 0xFF)))
- Notify((char*)pgm_read_word(&imNames[(op & 0xFF)]));
- else
- {
- switch (op)
- {
- case MTP_OFC_Undefined_Firmware:
- Notify(msgUndefined_Firmware);
- break;
- case MTP_OFC_Windows_Image_Format:
- Notify(msgWindows_Image_Format);
- break;
- case MTP_OFC_Undefined_Audio:
- Notify(msgUndefined_Audio);
- break;
- case MTP_OFC_WMA:
- Notify(msgWMA);
- break;
- case MTP_OFC_OGG:
- Notify(msgOGG);
- break;
- case MTP_OFC_AAC:
- Notify(msgAAC);
- break;
- case MTP_OFC_Audible:
- Notify(msgAudible);
- break;
- case MTP_OFC_FLAC:
- Notify(msgFLAC);
- break;
- case MTP_OFC_Undefined_Video:
- Notify(msgUndefined_Video);
- break;
- case MTP_OFC_WMV:
- Notify(msgWMV);
- break;
- case MTP_OFC_MP4_Container:
- Notify(msgMP4_Container);
- break;
- case MTP_OFC_MP2:
- Notify(msgMP2);
- break;
- case MTP_OFC_3GP_Container:
- Notify(msg3GP_Container);
- break;
- default:
- Notify(msgVendorDefined);
- }
- }
- Notify(msgCRLF);
-}
-
-bool DevInfoParser::PrintVendor(uint8_t **pp, uint16_t &count)
-{
- Notify(PSTR("Vendor Ext. ID:\t0x"));
- Serial.print(*((uint32_t*)*pp),HEX);
-
- switch (*((uint32_t*)*pp))
- {
- case PTP_VENDOR_EASTMAN_KODAK:
- Notify(PSTR("(Eastman Kodak)"));
- break;
- case PTP_VENDOR_SEIKO_EPSON:
- Notify(PSTR("(Seiko Epson)"));
- break;
- case PTP_VENDOR_AGILENT:
- Notify(PSTR("(Agilent)"));
- break;
- case PTP_VENDOR_POLAROID:
- Notify(PSTR("(Polaroid)"));
- break;
- case PTP_VENDOR_AGFA_GEVAERT:
- Notify(PSTR("(AGFA)"));
- break;
- case PTP_VENDOR_MICROSOFT:
- Notify(PSTR("(Microsoft)"));
- break;
- case PTP_VENDOR_EQUINOX:
- Notify(PSTR("(Equinox)"));
- break;
- case PTP_VENDOR_VIEWQUEST:
- Notify(PSTR("(ViewQuest)"));
- break;
- case PTP_VENDOR_STMICROELECTRONICS:
- Notify(PSTR("(StMicroelectronics)"));
- break;
- case PTP_VENDOR_NIKON:
- Notify(PSTR("(Nikon)"));
- break;
- case PTP_VENDOR_CANON:
- Notify(PSTR("(Canon)"));
- break;
- case PTP_VENDOR_FOTONATION:
- Notify(PSTR("(FotoNation)"));
- break;
- case PTP_VENDOR_PENTAX:
- Notify(PSTR("(Pentax)"));
- break;
- case PTP_VENDOR_FUJI:
- Notify(PSTR("(Fuji)"));
- break;
- default:
- Notify(PSTR("(Unknown)"));
- }
- Notify(msgCRLF);
- *pp += 4; count -= 4;
- return true;
-}
-
-bool DevInfoParser::PrintString(uint8_t **pp, uint16_t &count)
-{
- if (!count)
- return true;
-
- if ( !strByteCountDown )
- {
- if ( !(**pp) )
- {
- (*pp) ++;
- count --;
- return true;
- }
- strByteCountDown = ((**pp) << 1);
- (*pp) ++;
- count --;
- }
-
- for (; strByteCountDown && count; strByteCountDown--, count--, (*pp)++)
- {
- if ( !(strByteCountDown & 1) && ((**pp) > 0))
- Serial.print((unsigned char)(**pp));
- }
- return (strByteCountDown == 0);
-}
-
-bool DevInfoParser::PrintWordArray(uint8_t **pp, uint16_t &count, PRINTFUNC pf = NULL)
-{
- switch (waStage)
- {
- case 0:
- if (!waLenCountDown)
- waLenCountDown = 4;
-
- for (; waLenCountDown && count; waLenCountDown--, count--, (*pp)++)
- waLen[4-waLenCountDown] = (**pp);
-
- if (waLenCountDown)
- return false;
-
- waStage ++;
-
- case 1:
- for (waByteCountDown = (waByteCountDown) ? waByteCountDown : ((*((uint32_t*)waLen) << 1));
- waByteCountDown && count; waByteCountDown--, count--, (*pp)++)
- {
- if (waByteCountDown & 1)
- {
- waWord.bytes[1] = (**pp);
-
- if ( pf )
- (this->*pf)(waWord.word);
- else
- Serial.println (waWord.word, HEX);
- }
- else
- waWord.bytes[0] = (**pp);
- }
- if (waByteCountDown)
- return false;
- }
- waStage = 0;
- return true;
-}
-
-void DevInfoParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset)
-{
- uint16_t count = (uint16_t)len;
- uint8_t *p = (uint8_t*)pbuf;
-
- switch (nStage)
- {
- case 0:
- // Skip PTP container header
- p += 12; count -=12;
- nStage ++;
- case 1:
- Notify(PSTR("\r\nStd.Ver.:\t0x")); Serial.println(*(uint16_t*)p, DEC);
- p += 2; count -= 2;
-
- idVendor = *((uint32_t*)p);
- PrintVendor(&p, count);
-
- Notify(PSTR("\r\nVend.Ext.Ver.:\t0x")); Serial.println(*((uint16_t*)p), HEX);
- p += 2; count -=2;
-
- nStage ++;
- case 2:
- // Vendor extension description
- //if (*p)
- {
- if (!PrintString(&p, count))
- return;
-
- Notify(msgCRLF);
- }
- nStage ++;
- case 3:
- // Functional mode
- if (!PrintFunctMode(&p, count))
- return;
- nStage ++;
- case 4:
- // Operations Supported
- Notify(PSTR("\r\nOperations supported:\r\n"));
- nStage++;
- case 5:
- if (!PrintWordArray(&p, count, &DevInfoParser::PrintOperation))
- return;
- nStage ++;
- case 6:
- // Events Supported
- Notify(PSTR("\r\nEvents supported:\r\n"));
- nStage ++;
- case 7:
- if (!PrintWordArray(&p, count, &DevInfoParser::PrintEvent))
- return;
- nStage ++;
- case 8:
- // Device Properties Supported
- Notify(PSTR("\r\nDevice properties supported:\r\n"));
- nStage ++;
- case 9:
- if (!PrintWordArray(&p, count, &DevInfoParser::PrintDevProp))
- return;
- nStage ++;
- case 10:
- // Capture formats
- Notify(PSTR("\r\nCapture formats:\r\n"));
- nStage ++;
- case 11:
- if (!PrintWordArray(&p, count, &DevInfoParser::PrintFormat))
- return;
- nStage ++;
- case 12:
- // Image Formats
- Notify(PSTR("\r\nImage Formats:\r\n"));
- nStage ++;
- case 13:
- if (!PrintWordArray(&p, count, &DevInfoParser::PrintFormat))
- return;
- nStage ++;
- case 14:
- // Manufacturer
- Notify(PSTR("\r\nManufacturer:\t"));
- nStage ++;
- case 15:
- if (!PrintString(&p, count))
- return;
- nStage ++;
- case 16:
- // Model
- Notify(PSTR("\r\nModel:\t\t"));
- nStage ++;
- case 17:
- if (!PrintString(&p, count))
- return;
- nStage ++;
- case 18:
- // Device version
- Notify(PSTR("\r\nDevice ver.:\t"));
- nStage ++;
- case 19:
- if (!PrintString(&p, count))
- return;
- nStage ++;
- case 20:
- // Serial number
- Notify(PSTR("\r\nSerial num.:\t"));
- nStage ++;
- case 21:
- if (!PrintString(&p, count))
- return;
- Notify(PSTR("\r\n\r\n"));
- //nStage = 0;
- }
-}
+ default:
+ return false;
+ }
+ Notify(msg);
+ return true;
+}
+
+void DevInfoParser::PrintEvent(uint16_t op)
+{
+ Serial.print(op, HEX);
+ Notify(msgTab);
+
+ if ((((op >> 8) & 0xFF) == 0x40) && ((op & 0xFF) <= (PTP_EC_UnreportedStatus & 0xFF)))
+ Notify((char*)pgm_read_word(&ptpevNames[(op & 0xFF)]));
+ else
+ if ((((op >> 8) & 0xFF) == 0xC8) && ((op & 0xFF) <= (MTP_EC_ObjectReferencesChanged & 0xFF)))
+ Notify((char*)pgm_read_word(&mtpevNames[(op & 0xFF)]));
+ else
+ Notify(msgVendorDefined);
+ Notify(msgCRLF);
+}
+
+void DevInfoParser::PrintDevProp(uint16_t op)
+{
+ Serial.print(op, HEX);
+ Notify(msgTab);
+
+ if ((((op >> 8) & 0xFF) == 0x50) && ((op & 0xFF) <= (PTP_DPC_CopyrightInfo & 0xFF)))
+ Notify((char*)pgm_read_word(&ptpprNames[(op & 0xFF)]));
+ else
+ if (((op >> 8) & 0xFF) == 0xD4)
+ {
+ if ( (op & 0xFF) <= (MTP_DPC_Perceived_Device_Type & 0xFF) )
+ Notify((char*)pgm_read_word(&mtpprNames[(op & 0xFF)]));
+ else
+ {
+ switch (op)
+ {
+ case MTP_DPC_Playback_Rate:
+ Notify(msgPlayback_Rate);
+ break;
+ case MTP_DPC_Playback_Object:
+ Notify(msgPlayback_Object);
+ break;
+ case MTP_DPC_Playback_Container:
+ Notify(msgPlayback_Container);
+ break;
+ default:
+ Notify(msgVendorDefined);
+ }
+ }
+ }
+ else
+ Notify(msgVendorDefined);
+
+ Notify(msgCRLF);
+}
+
+void DevInfoParser::PrintFormat(uint16_t op)
+{
+ Serial.print(op, HEX);
+ Notify(msgTab);
+
+ if ((((op >> 8) & 0xFF) == 0x30) && ((op & 0xFF) <= (PTP_OFC_QT & 0xFF)))
+ Notify((char*)pgm_read_word(&acNames[(op & 0xFF)]));
+ else
+ if ((((op >> 8) & 0xFF) == 0x38) && ((op & 0xFF) <= (PTP_OFC_JPX & 0xFF)))
+ Notify((char*)pgm_read_word(&imNames[(op & 0xFF)]));
+ else
+ {
+ switch (op)
+ {
+ case MTP_OFC_Undefined_Firmware:
+ Notify(msgUndefined_Firmware);
+ break;
+ case MTP_OFC_Windows_Image_Format:
+ Notify(msgWindows_Image_Format);
+ break;
+ case MTP_OFC_Undefined_Audio:
+ Notify(msgUndefined_Audio);
+ break;
+ case MTP_OFC_WMA:
+ Notify(msgWMA);
+ break;
+ case MTP_OFC_OGG:
+ Notify(msgOGG);
+ break;
+ case MTP_OFC_AAC:
+ Notify(msgAAC);
+ break;
+ case MTP_OFC_Audible:
+ Notify(msgAudible);
+ break;
+ case MTP_OFC_FLAC:
+ Notify(msgFLAC);
+ break;
+ case MTP_OFC_Undefined_Video:
+ Notify(msgUndefined_Video);
+ break;
+ case MTP_OFC_WMV:
+ Notify(msgWMV);
+ break;
+ case MTP_OFC_MP4_Container:
+ Notify(msgMP4_Container);
+ break;
+ case MTP_OFC_MP2:
+ Notify(msgMP2);
+ break;
+ case MTP_OFC_3GP_Container:
+ Notify(msg3GP_Container);
+ break;
+ default:
+ Notify(msgVendorDefined);
+ }
+ }
+ Notify(msgCRLF);
+}
+
+bool DevInfoParser::PrintVendor(uint8_t **pp, uint16_t &count)
+{
+ Notify(PSTR("Vendor Ext. ID:\t0x"));
+ Serial.print(*((uint32_t*)*pp),HEX);
+
+ switch (*((uint32_t*)*pp))
+ {
+ case PTP_VENDOR_EASTMAN_KODAK:
+ Notify(PSTR("(Eastman Kodak)"));
+ break;
+ case PTP_VENDOR_SEIKO_EPSON:
+ Notify(PSTR("(Seiko Epson)"));
+ break;
+ case PTP_VENDOR_AGILENT:
+ Notify(PSTR("(Agilent)"));
+ break;
+ case PTP_VENDOR_POLAROID:
+ Notify(PSTR("(Polaroid)"));
+ break;
+ case PTP_VENDOR_AGFA_GEVAERT:
+ Notify(PSTR("(AGFA)"));
+ break;
+ case PTP_VENDOR_MICROSOFT:
+ Notify(PSTR("(Microsoft)"));
+ break;
+ case PTP_VENDOR_EQUINOX:
+ Notify(PSTR("(Equinox)"));
+ break;
+ case PTP_VENDOR_VIEWQUEST:
+ Notify(PSTR("(ViewQuest)"));
+ break;
+ case PTP_VENDOR_STMICROELECTRONICS:
+ Notify(PSTR("(StMicroelectronics)"));
+ break;
+ case PTP_VENDOR_NIKON:
+ Notify(PSTR("(Nikon)"));
+ break;
+ case PTP_VENDOR_CANON:
+ Notify(PSTR("(Canon)"));
+ break;
+ case PTP_VENDOR_FOTONATION:
+ Notify(PSTR("(FotoNation)"));
+ break;
+ case PTP_VENDOR_PENTAX:
+ Notify(PSTR("(Pentax)"));
+ break;
+ case PTP_VENDOR_FUJI:
+ Notify(PSTR("(Fuji)"));
+ break;
+ default:
+ Notify(PSTR("(Unknown)"));
+ }
+ Notify(msgCRLF);
+ *pp += 4; count -= 4;
+ return true;
+}
+
+bool DevInfoParser::PrintString(uint8_t **pp, uint16_t &count)
+{
+ if (!count)
+ return true;
+
+ if ( !strByteCountDown )
+ {
+ if ( !(**pp) )
+ {
+ (*pp) ++;
+ count --;
+ return true;
+ }
+ strByteCountDown = ((**pp) << 1);
+ (*pp) ++;
+ count --;
+ }
+
+ for (; strByteCountDown && count; strByteCountDown--, count--, (*pp)++)
+ {
+ if ( !(strByteCountDown & 1) && ((**pp) > 0))
+ Serial.print((unsigned char)(**pp));
+ }
+ return (strByteCountDown == 0);
+}
+
+bool DevInfoParser::PrintWordArray(uint8_t **pp, uint16_t &count, PRINTFUNC pf = NULL)
+{
+ switch (waStage)
+ {
+ case 0:
+ if (!waLenCountDown)
+ waLenCountDown = 4;
+
+ for (; waLenCountDown && count; waLenCountDown--, count--, (*pp)++)
+ waLen[4-waLenCountDown] = (**pp);
+
+ if (waLenCountDown)
+ return false;
+
+ waStage ++;
+
+ case 1:
+ for (waByteCountDown = (waByteCountDown) ? waByteCountDown : ((*((uint32_t*)waLen) << 1));
+ waByteCountDown && count; waByteCountDown--, count--, (*pp)++)
+ {
+ if (waByteCountDown & 1)
+ {
+ waWord.bytes[1] = (**pp);
+
+ if ( pf )
+ (this->*pf)(waWord.word);
+ else
+ Serial.println (waWord.word, HEX);
+ }
+ else
+ waWord.bytes[0] = (**pp);
+ }
+ if (waByteCountDown)
+ return false;
+ }
+ waStage = 0;
+ return true;
+}
+
+void DevInfoParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset)
+{
+ uint16_t count = (uint16_t)len;
+ uint8_t *p = (uint8_t*)pbuf;
+
+ switch (nStage)
+ {
+ case 0:
+ // Skip PTP container header
+ p += 12; count -=12;
+ nStage ++;
+ case 1:
+ Notify(PSTR("\r\nStd.Ver.:\t0x")); Serial.println(*(uint16_t*)p, DEC);
+ p += 2; count -= 2;
+
+ idVendor = *((uint32_t*)p);
+ PrintVendor(&p, count);
+
+ Notify(PSTR("\r\nVend.Ext.Ver.:\t0x")); Serial.println(*((uint16_t*)p), HEX);
+ p += 2; count -=2;
+
+ nStage ++;
+ case 2:
+ // Vendor extension description
+ //if (*p)
+ {
+ if (!PrintString(&p, count))
+ return;
+
+ Notify(msgCRLF);
+ }
+ nStage ++;
+ case 3:
+ // Functional mode
+ if (!PrintFunctMode(&p, count))
+ return;
+ nStage ++;
+ case 4:
+ // Operations Supported
+ Notify(PSTR("\r\nOperations supported:\r\n"));
+ nStage++;
+ case 5:
+ if (!PrintWordArray(&p, count, &DevInfoParser::PrintOperation))
+ return;
+ nStage ++;
+ case 6:
+ // Events Supported
+ Notify(PSTR("\r\nEvents supported:\r\n"));
+ nStage ++;
+ case 7:
+ if (!PrintWordArray(&p, count, &DevInfoParser::PrintEvent))
+ return;
+ nStage ++;
+ case 8:
+ // Device Properties Supported
+ Notify(PSTR("\r\nDevice properties supported:\r\n"));
+ nStage ++;
+ case 9:
+ if (!PrintWordArray(&p, count, &DevInfoParser::PrintDevProp))
+ return;
+ nStage ++;
+ case 10:
+ // Capture formats
+ Notify(PSTR("\r\nCapture formats:\r\n"));
+ nStage ++;
+ case 11:
+ if (!PrintWordArray(&p, count, &DevInfoParser::PrintFormat))
+ return;
+ nStage ++;
+ case 12:
+ // Image Formats
+ Notify(PSTR("\r\nImage Formats:\r\n"));
+ nStage ++;
+ case 13:
+ if (!PrintWordArray(&p, count, &DevInfoParser::PrintFormat))
+ return;
+ nStage ++;
+ case 14:
+ // Manufacturer
+ Notify(PSTR("\r\nManufacturer:\t"));
+ nStage ++;
+ case 15:
+ if (!PrintString(&p, count))
+ return;
+ nStage ++;
+ case 16:
+ // Model
+ Notify(PSTR("\r\nModel:\t\t"));
+ nStage ++;
+ case 17:
+ if (!PrintString(&p, count))
+ return;
+ nStage ++;
+ case 18:
+ // Device version
+ Notify(PSTR("\r\nDevice ver.:\t"));
+ nStage ++;
+ case 19:
+ if (!PrintString(&p, count))
+ return;
+ nStage ++;
+ case 20:
+ // Serial number
+ Notify(PSTR("\r\nSerial num.:\t"));
+ nStage ++;
+ case 21:
+ if (!PrintString(&p, count))
+ return;
+ Notify(PSTR("\r\n\r\n"));
+ //nStage = 0;
+ }
+}
View
482 examples/PTPDevInfo/devinfoparser.h
@@ -1,61 +1,61 @@
-#ifndef __DEVINFOPARSER_H__
-#define __DEVINFOPARSER_H__
-
-#include <inttypes.h>
-#include <avr/pgmspace.h>
-#include <../ptp/ptpconst.h>
-#include <../ptp/mtpconst.h>
-#include <../ptp/ptp.h>
-
-const char msgVendorDefined [] PROGMEM = "Vendor defined";
-const char msgTab [] PROGMEM = "\t";
-const char msgCRLF [] PROGMEM = "\r\n";
-
-// PTP Operations
-const char msgUndefined [] PROGMEM = "Undefined";
-const char msgGetDeviceInfo [] PROGMEM = "GetDeviceInfo";
-const char msgOpenSession [] PROGMEM = "OpenSession";
-const char msgCloseSession [] PROGMEM = "CloseSession";
-const char msgGetStorageIDs [] PROGMEM = "GetStorageIDs";
-const char msgGetStorageInfo [] PROGMEM = "GetStorageInfo";
-const char msgGetNumObjects [] PROGMEM = "GetNumObjects";
-const char msgGetObjectHandles [] PROGMEM = "GetObjectHandles";
-const char msgGetObjectInfo [] PROGMEM = "GetObjectInfo";
-const char msgGetObject [] PROGMEM = "GetObject";
-const char msgGetThumb [] PROGMEM = "GetThumb";
-const char msgDeleteObject [] PROGMEM = "DeleteObject";
-const char msgSendObjectInfo [] PROGMEM = "SendObjectInfo";
-const char msgSendObject [] PROGMEM = "SendObject";
-const char msgInitiateCapture [] PROGMEM = "InitiateCapture";
-const char msgFormatStore [] PROGMEM = "FormatStore";
-const char msgResetDevice [] PROGMEM = "ResetDevice";
-const char msgSelfTest [] PROGMEM = "SelfTest";
-const char msgSetObjectProtection [] PROGMEM = "SetObjectProtection";
-const char msgPowerDown [] PROGMEM = "PowerDown";
-const char msgGetDevicePropDesc [] PROGMEM = "GetDevicePropDesc";
-const char msgGetDevicePropValue [] PROGMEM = "GetDevicePropValue";
-const char msgSetDevicePropValue [] PROGMEM = "SetDevicePropValue";
-const char msgResetDevicePropValue [] PROGMEM = "ResetDevicePropValue";
-const char msgTerminateOpenCapture [] PROGMEM = "TerminateOpenCapture";
-const char msgMoveObject [] PROGMEM = "MoveObject";
-const char msgCopyObject [] PROGMEM = "CopyObject";
-const char msgGetPartialObject [] PROGMEM = "GetPartialObject";
-const char msgInitiateOpenCapture [] PROGMEM = "InitiateOpenCapture";
-
-// MTP Operations
-const char msgGetObjectPropsSupported [] PROGMEM = "GetObjectPropsSupported";
-const char msgGetObjectPropDesc [] PROGMEM = "GetObjectPropDesc";
-const char msgGetObjectPropValue [] PROGMEM = "GetObjectPropValue";
-const char msgSetObjectPropValue [] PROGMEM = "SetObjectPropValue";
-const char msgGetObjectPropList [] PROGMEM = "GetObjectPropList";
-const char msgSetObjectPropList [] PROGMEM = "SetObjectPropList";
-const char msgGetInterdependentPropDesc [] PROGMEM = "GetInterdependentPropDesc";
-const char msgSendObjectPropList [] PROGMEM = "SendObjectPropList";
-const char msgGetObjectReferences [] PROGMEM = "GetObjectReferences";
-const char msgSetObjectReferences [] PROGMEM = "SetObjectReferences";
-const char msgSkip [] PROGMEM = "Skip";
-
-// Canon EOS Operations
+#ifndef __DEVINFOPARSER_H__
+#define __DEVINFOPARSER_H__
+
+#include <inttypes.h>
+#include <avr/pgmspace.h>
+#include <../ptp/ptpconst.h>
+#include <../ptp/mtpconst.h>
+#include <../ptp/ptp.h>
+
+const char msgVendorDefined [] PROGMEM = "Vendor defined";
+const char msgTab [] PROGMEM = "\t";
+const char msgCRLF [] PROGMEM = "\r\n";
+
+// PTP Operations
+const char msgUndefined [] PROGMEM = "Undefined";
+const char msgGetDeviceInfo [] PROGMEM = "GetDeviceInfo";
+const char msgOpenSession [] PROGMEM = "OpenSession";
+const char msgCloseSession [] PROGMEM = "CloseSession";
+const char msgGetStorageIDs [] PROGMEM = "GetStorageIDs";
+const char msgGetStorageInfo [] PROGMEM = "GetStorageInfo";
+const char msgGetNumObjects [] PROGMEM = "GetNumObjects";
+const char msgGetObjectHandles [] PROGMEM = "GetObjectHandles";
+const char msgGetObjectInfo [] PROGMEM = "GetObjectInfo";
+const char msgGetObject [] PROGMEM = "GetObject";
+const char msgGetThumb [] PROGMEM = "GetThumb";
+const char msgDeleteObject [] PROGMEM = "DeleteObject";
+const char msgSendObjectInfo [] PROGMEM = "SendObjectInfo";
+const char msgSendObject [] PROGMEM = "SendObject";
+const char msgInitiateCapture [] PROGMEM = "InitiateCapture";
+const char msgFormatStore [] PROGMEM = "FormatStore";
+const char msgResetDevice [] PROGMEM = "ResetDevice";
+const char msgSelfTest [] PROGMEM = "SelfTest";
+const char msgSetObjectProtection [] PROGMEM = "SetObjectProtection";
+const char msgPowerDown [] PROGMEM = "PowerDown";
+const char msgGetDevicePropDesc [] PROGMEM = "GetDevicePropDesc";
+const char msgGetDevicePropValue [] PROGMEM = "GetDevicePropValue";
+const char msgSetDevicePropValue [] PROGMEM = "SetDevicePropValue";
+const char msgResetDevicePropValue [] PROGMEM = "ResetDevicePropValue";
+const char msgTerminateOpenCapture [] PROGMEM = "TerminateOpenCapture";
+const char msgMoveObject [] PROGMEM = "MoveObject";
+const char msgCopyObject [] PROGMEM = "CopyObject";
+const char msgGetPartialObject [] PROGMEM = "GetPartialObject";
+const char msgInitiateOpenCapture [] PROGMEM = "InitiateOpenCapture";
+
+// MTP Operations
+const char msgGetObjectPropsSupported [] PROGMEM = "GetObjectPropsSupported";
+const char msgGetObjectPropDesc [] PROGMEM = "GetObjectPropDesc";
+const char msgGetObjectPropValue [] PROGMEM = "GetObjectPropValue";
+const char msgSetObjectPropValue [] PROGMEM = "SetObjectPropValue";
+const char msgGetObjectPropList [] PROGMEM = "GetObjectPropList";
+const char msgSetObjectPropList [] PROGMEM = "SetObjectPropList";
+const char msgGetInterdependentPropDesc [] PROGMEM = "GetInterdependentPropDesc";
+const char msgSendObjectPropList [] PROGMEM = "SendObjectPropList";
+const char msgGetObjectReferences [] PROGMEM = "GetObjectReferences";
+const char msgSetObjectReferences [] PROGMEM = "SetObjectReferences";
+const char msgSkip [] PROGMEM = "Skip";
+
+// Canon EOS Operations
const char msgEOS_GetStorageIDs [] PROGMEM = "EOS_GetStorageIDs";
const char msgEOS_GetStorageInfo [] PROGMEM = "EOS_GetStorageInfo";
const char msgEOS_GetObject [] PROGMEM = "EOS_GetObject";
@@ -68,8 +68,8 @@ const char msgEOS_SetExtendedEventInfo [] PROGMEM = "EOS_SetExtendedEventInfo";
const char msgEOS_GetEvent [] PROGMEM = "EOS_GetEvent";
const char msgEOS_GetLiveViewPicture [] PROGMEM = "EOS_GetLiveViewPicture";
const char msgEOS_MoveFocus [] PROGMEM = "EOS_MoveFocus";
-
-// Canon PowerShot Operations
+
+// Canon PowerShot Operations
const char msgPS_GetObjectSize [] PROGMEM = "PS_GetObjectSize";
const char msgPS_StartShootingMode [] PROGMEM = "PS_StartShootingMode";
const char msgPS_EndShootingMode [] PROGMEM = "PS_EndShootingMode";
@@ -84,123 +84,123 @@ const char msgPS_GetPartialObject [] PROGMEM = "PS_GetPartialObject";
const char msgPS_GetViewfinderImage [] PROGMEM = "PS_GetViewfinderImage";
const char msgPS_GetChanges [] PROGMEM = "PS_GetChanges";
const char msgPS_GetFolderEntries [] PROGMEM = "PS_GetFolderEntries";
-
-
-// PTP Events
-const char msgCancelTransaction [] PROGMEM = "CancelTransaction";
-const char msgObjectAdded [] PROGMEM = "ObjectAdded";
-const char msgObjectRemoved [] PROGMEM = "ObjectRemoved";
-const char msgStoreAdded [] PROGMEM = "StoreAdded";
-const char msgStoreRemoved [] PROGMEM = "StoreRemoved";
-const char msgDevicePropChanged [] PROGMEM = "DevicePropChanged";
-const char msgObjectInfoChanged [] PROGMEM = "ObjectInfoChanged";
-const char msgDeviceInfoChanged [] PROGMEM = "DeviceInfoChanged";
-const char msgRequestObjectTransfer [] PROGMEM = "RequestObjectTransfer";
-const char msgStoreFull [] PROGMEM = "StoreFull";
-const char msgDeviceReset [] PROGMEM = "DeviceReset";
-const char msgStorageInfoChanged [] PROGMEM = "StorageInfoChanged";
-const char msgCaptureComplete [] PROGMEM = "CaptureComplete";
-const char msgUnreportedStatus [] PROGMEM = "UnreportedStatus";
-
-// MTP Events
-const char msgObjectPropChanged [] PROGMEM = "ObjectPropChanged";
-const char msgObjectPropDescChanged [] PROGMEM = "ObjectPropDescChanged";
-const char msgObjectReferencesChanged [] PROGMEM = "ObjectReferencesChanged";
-
-// PTP Device properties