| 1 | #ifndef __PTP_H
|
|---|
| 2 | #define __PTP_H
|
|---|
| 3 |
|
|---|
| 4 | // N.B.: not checking to see if CAM_CHDK_PTP is set as ptp.h is currently
|
|---|
| 5 | // only included by ptp.c (which already checks this before including ptp.h)
|
|---|
| 6 |
|
|---|
| 7 | #define PTP_CHDK_VERSION_MAJOR 0 // increase only with backwards incompatible changes (and reset minor)
|
|---|
| 8 | #define PTP_CHDK_VERSION_MINOR 2 // increase with extensions of functionality
|
|---|
| 9 | /*
|
|---|
| 10 | protocol version history
|
|---|
| 11 | 0.1 - initial proposal from mweerden, + luar
|
|---|
| 12 | 0.2 - Added ScriptStatus and ScriptSupport, based on work by ultimA
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | #define PTP_OC_CHDK 0x9999
|
|---|
| 16 |
|
|---|
| 17 | #define PTP_RC_OK 0x2001
|
|---|
| 18 | #define PTP_RC_GeneralError 0x2002
|
|---|
| 19 | #define PTP_RC_ParameterNotSupported 0x2006
|
|---|
| 20 |
|
|---|
| 21 | // N.B.: unused parameters should be set to 0
|
|---|
| 22 | enum {
|
|---|
| 23 | PTP_CHDK_Version = 0, // return param1 is major version number
|
|---|
| 24 | // return param2 is minor version number
|
|---|
| 25 | PTP_CHDK_GetMemory, // param2 is base address (not NULL; circumvent by taking 0xFFFFFFFF and size+1)
|
|---|
| 26 | // param3 is size (in bytes)
|
|---|
| 27 | // return data is memory block
|
|---|
| 28 | PTP_CHDK_SetMemory, // param2 is address
|
|---|
| 29 | // param3 is size (in bytes)
|
|---|
| 30 | // data is new memory block
|
|---|
| 31 | PTP_CHDK_CallFunction, // data is array of function pointer and (long) arguments (max: 10 args)
|
|---|
| 32 | // return param1 is return value
|
|---|
| 33 | PTP_CHDK_TempData, // data is data to be stored for later
|
|---|
| 34 | // param2 is for the TD flags below
|
|---|
| 35 | PTP_CHDK_UploadFile, // data is 4-byte length of filename, followed by filename and contents
|
|---|
| 36 | PTP_CHDK_DownloadFile, // preceded by PTP_CHDK_TempData with filename
|
|---|
| 37 | // return data are file contents
|
|---|
| 38 | PTP_CHDK_ExecuteScript, // data is script to be executed
|
|---|
| 39 | // param2 is language of script
|
|---|
| 40 | // param3 is for the ES flags below
|
|---|
| 41 | PTP_CHDK_ScriptStatus, // Script execution status
|
|---|
| 42 | // param1 CHDK_PTP_SCRIPT_STATUS_RUN is set if a script running, cleared if not
|
|---|
| 43 | // all other bits and params are reserved for future use
|
|---|
| 44 | PTP_CHDK_ScriptSupport, // Which scripting interfaces are supported in this build
|
|---|
| 45 | // param1 CHDK_PTP_SUPPORT_LUA is set if lua is supported, cleared if not
|
|---|
| 46 | // all other bits and params are reserved for future use
|
|---|
| 47 | } ptp_chdk_command;
|
|---|
| 48 |
|
|---|
| 49 | // data types as used by TempData and ExecuteScript
|
|---|
| 50 | enum {
|
|---|
| 51 | PTP_CHDK_TYPE_NOTHING = 0,
|
|---|
| 52 | PTP_CHDK_TYPE_NIL,
|
|---|
| 53 | PTP_CHDK_TYPE_BOOLEAN,
|
|---|
| 54 | PTP_CHDK_TYPE_INTEGER,
|
|---|
| 55 | PTP_CHDK_TYPE_STRING
|
|---|
| 56 | } ptp_chdk_type;
|
|---|
| 57 |
|
|---|
| 58 | // TempData flags
|
|---|
| 59 | #define PTP_CHDK_TD_DOWNLOAD 0x1 // download data instead of upload
|
|---|
| 60 | #define PTP_CHDK_TD_CLEAR 0x2 // clear the stored data; with DOWNLOAD this
|
|---|
| 61 | // means first download, then clear and
|
|---|
| 62 | // without DOWNLOAD this means no uploading,
|
|---|
| 63 | // just clear
|
|---|
| 64 |
|
|---|
| 65 | // ExecuteScript flags
|
|---|
| 66 | #define PTP_CHDK_ES_WAIT 0x1 // do not return after script initialisation
|
|---|
| 67 | // but wait until execution has finished
|
|---|
| 68 | // (should only be used with short execution
|
|---|
| 69 | // times)
|
|---|
| 70 | #define PTP_CHDK_ES_RESULT 0x2 // only in combination with WAIT; return
|
|---|
| 71 | // param1 will be the ptp_chdk_type of the
|
|---|
| 72 | // code result and param2 the value (booleans
|
|---|
| 73 | // and integers) or length (strings)
|
|---|
| 74 |
|
|---|
| 75 | // Script Languages - for execution
|
|---|
| 76 | #define PTP_CHDK_SL_LUA 0
|
|---|
| 77 | #define PTP_CHDK_SL_UBASIC 1
|
|---|
| 78 |
|
|---|
| 79 | // bit flags for script status
|
|---|
| 80 | #define PTP_CHDK_SCRIPT_STATUS_RUN 0x1
|
|---|
| 81 | // bit flags for scripting support
|
|---|
| 82 | #define PTP_CHDK_SCRIPT_SUPPORT_LUA 0x1
|
|---|
| 83 |
|
|---|
| 84 | #endif // __PTP_H
|
|---|