From: <mar...@us...> - 2009-04-21 10:01:27
|
Revision: 12005 http://gphoto.svn.sourceforge.net/gphoto/?rev=12005&view=rev Author: marcusmeissner Date: 2009-04-21 10:01:18 +0000 (Tue, 21 Apr 2009) Log Message: ----------- eos deviceinfo Modified Paths: -------------- trunk/libgphoto2/camlibs/ptp2/ptp-pack.c trunk/libgphoto2/camlibs/ptp2/ptp.c trunk/libgphoto2/camlibs/ptp2/ptp.h Modified: trunk/libgphoto2/camlibs/ptp2/ptp-pack.c =================================================================== --- trunk/libgphoto2/camlibs/ptp2/ptp-pack.c 2009-04-19 22:18:17 UTC (rev 12004) +++ trunk/libgphoto2/camlibs/ptp2/ptp-pack.c 2009-04-21 10:01:18 UTC (rev 12005) @@ -266,7 +266,7 @@ { uint8_t len; unsigned int totallen; - + di->StandardVersion = dtoh16a(&data[PTP_di_StandardVersion]); di->VendorExtensionID = dtoh32a(&data[PTP_di_VendorExtensionID]); @@ -329,6 +329,33 @@ if (di->EventsSupported) free (di->EventsSupported); if (di->DevicePropertiesSupported) free (di->DevicePropertiesSupported); } + +/* EOS Device Info unpack */ +static inline void +ptp_unpack_EOS_DI (PTPParams *params, unsigned char* data, PTPCanonEOSDeviceInfo *di, unsigned int datalen) +{ + int totallen = 4; + if (datalen < 8) return; + + /* uint32_t struct len - ignore */ + di->EventsSupported_len = ptp_unpack_uint32_t_array(params, data, + totallen, &di->EventsSupported); + if (!di->EventsSupported) return; + totallen += di->EventsSupported_len*sizeof(uint32_t)+4; + if (totallen >= datalen) return; + + di->DevicePropertiesSupported_len = ptp_unpack_uint32_t_array(params, data, + totallen, &di->DevicePropertiesSupported); + if (!di->DevicePropertiesSupported) return; + totallen += di->DevicePropertiesSupported_len*sizeof(uint32_t)+4; + if (totallen >= datalen) return; + + di->unk_len = ptp_unpack_uint32_t_array(params, data, + totallen, &di->unk); + if (!di->unk) return; + totallen += di->unk_len*sizeof(uint32_t)+4; + return; +} /* ObjectHandles array pack/unpack */ Modified: trunk/libgphoto2/camlibs/ptp2/ptp.c =================================================================== --- trunk/libgphoto2/camlibs/ptp2/ptp.c 2009-04-19 22:18:17 UTC (rev 12004) +++ trunk/libgphoto2/camlibs/ptp2/ptp.c 2009-04-21 10:01:18 UTC (rev 12005) @@ -416,19 +416,24 @@ } uint16_t -ptp_canon_eos_getdeviceinfo (PTPParams* params, unsigned char**di, unsigned long *len ) +ptp_canon_eos_getdeviceinfo (PTPParams* params, PTPCanonEOSDeviceInfo*di) { uint16_t ret; PTPContainer ptp; PTPDataHandler handler; + unsigned long len; + unsigned char *data; ptp_init_recv_memory_handler (&handler); PTP_CNT_INIT(ptp); ptp.Code=PTP_OC_CANON_EOS_GetDeviceInfoEx; ptp.Nparam=0; - *len=0; + len=0; + data=NULL; ret=ptp_transaction_new(params, &ptp, PTP_DP_GETDATA, 0, &handler); - ptp_exit_recv_memory_handler (&handler, di, len); + ptp_exit_recv_memory_handler (&handler, &data, &len); + if (ret == PTP_RC_OK) ptp_unpack_EOS_DI(params, data, di, len); + free (data); return ret; } Modified: trunk/libgphoto2/camlibs/ptp2/ptp.h =================================================================== --- trunk/libgphoto2/camlibs/ptp2/ptp.h 2009-04-19 22:18:17 UTC (rev 12004) +++ trunk/libgphoto2/camlibs/ptp2/ptp.h 2009-04-21 10:01:18 UTC (rev 12005) @@ -1068,7 +1068,18 @@ PTPDevicePropDesc dpd; } PTPCanon_Property; +typedef struct _PTPCanonEOSDeviceInfo { + /* length */ + uint32_t EventsSupported_len; + uint32_t *EventsSupported; + uint32_t DevicePropertiesSupported_len; + uint32_t *DevicePropertiesSupported; + + uint32_t unk_len; + uint32_t *unk; +} PTPCanonEOSDeviceInfo; + /* DataType Codes */ #define PTP_DTC_UNDEF 0x0000 @@ -2031,7 +2042,7 @@ uint32_t handle, PTPCANONFolderEntry** entries, uint32_t* entnum); -uint16_t ptp_canon_eos_getdeviceinfo (PTPParams* params, unsigned char**di, unsigned long *len ); +uint16_t ptp_canon_eos_getdeviceinfo (PTPParams* params, PTPCanonEOSDeviceInfo*di); uint16_t ptp_canon_get_objecthandle_by_name (PTPParams* params, char* name, uint32_t* objectid); uint16_t ptp_canon_get_directory (PTPParams* params, PTPObjectHandles *handles, PTPObjectInfo **oinfos, uint32_t **flags); uint16_t ptp_canon_setobjectarchive (PTPParams* params, uint32_t oid, uint32_t flags); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |