9 #define PTP_CHDK_VERSION_MAJOR 2 // increase only with backwards incompatible changes (and reset minor) 10 #define PTP_CHDK_VERSION_MINOR 6 // increase with extensions of functionality 27 #define PTP_OC_CHDK 0x9999 31 enum PTP_CHDK_Command {
40 PTP_CHDK_CallFunction,
45 PTP_CHDK_DownloadFile,
47 PTP_CHDK_ExecuteScript,
52 PTP_CHDK_ScriptStatus,
57 PTP_CHDK_ScriptSupport,
60 PTP_CHDK_ReadScriptMsg,
69 PTP_CHDK_WriteScriptMsg,
74 PTP_CHDK_GetDisplayData,
84 PTP_CHDK_RemoteCaptureIsReady,
90 PTP_CHDK_RemoteCaptureGetData
99 enum ptp_chdk_script_data_type {
100 PTP_CHDK_TYPE_UNSUPPORTED = 0,
102 PTP_CHDK_TYPE_BOOLEAN,
103 PTP_CHDK_TYPE_INTEGER,
104 PTP_CHDK_TYPE_STRING,
111 #define PTP_CHDK_TD_DOWNLOAD 0x1 // download data instead of upload 112 #define PTP_CHDK_TD_CLEAR 0x2 // clear the stored data; with DOWNLOAD this 118 #define PTP_CHDK_SL_LUA 0 119 #define PTP_CHDK_SL_UBASIC 1 120 #define PTP_CHDK_SL_MASK 0xFF 123 #define PTP_CHDK_LUA_SERIALIZE "\n\ 124 serialize_r = function(v,opts,r,seen,depth)\n\ 125 local vt = type(v)\n\ 126 if vt == 'nil' or vt == 'boolean' or vt == 'number' then\n\ 127 table.insert(r,tostring(v))\n\ 130 if vt == 'string' then\n\ 131 table.insert(r,string.format('%q',v))\n\ 134 if vt == 'table' then\n\ 138 if depth >= opts.maxdepth then\n\ 139 error('serialize: max depth')\n\ 143 elseif seen[v] then\n\ 144 if opts.err_cycle then\n\ 145 error('serialize: cycle')\n\ 147 table.insert(r,'\"cycle:'..tostring(v)..'\"')\n\ 152 table.insert(r,'{')\n\ 153 for k,v1 in pairs(v) do\n\ 154 if opts.pretty then\n\ 155 table.insert(r,'\\n'..string.rep(' ',depth))\n\ 157 if type(k) == 'string' and string.match(k,'^[_%a][%a%d_]*$') then\n\ 160 table.insert(r,'[')\n\ 161 serialize_r(k,opts,r,seen,depth+1)\n\ 162 table.insert(r,']')\n\ 164 table.insert(r,'=')\n\ 165 serialize_r(v1,opts,r,seen,depth+1)\n\ 166 table.insert(r,',')\n\ 168 if opts.pretty then\n\ 169 table.insert(r,'\\n'..string.rep(' ',depth-1))\n\ 171 table.insert(r,'}')\n\ 174 if opts.err_type then\n\ 175 error('serialize: unsupported type ' .. vt, 2)\n\ 177 table.insert(r,'\"'..tostring(v)..'\"')\n\ 180 serialize_defaults = {\n\ 186 function serialize(v,opts)\n\ 188 for k,v in pairs(serialize_defaults) do\n\ 189 if not opts[k] then\n\ 194 opts=serialize_defaults\n\ 197 serialize_r(v,opts,r)\n\ 198 return table.concat(r)\n\ 201 usb_msg_table_to_string=serialize\n" 205 #define PTP_CHDK_SCRIPT_FL_NOKILL 0x100 // if script is running return error instead of killing 206 #define PTP_CHDK_SCRIPT_FL_FLUSH_CAM_MSGS 0x200 // discard existing cam->host messages before starting 207 #define PTP_CHDK_SCRIPT_FL_FLUSH_HOST_MSGS 0x400 // discard existing host->cam messages before starting 210 #define PTP_CHDK_SCRIPT_STATUS_RUN 0x1 // script running 211 #define PTP_CHDK_SCRIPT_STATUS_MSG 0x2 // messages waiting 213 #define PTP_CHDK_SCRIPT_SUPPORT_LUA 0x1 221 #define PTP_CHDK_CAPTURE_JPG 0x1 227 #define PTP_CHDK_CAPTURE_RAW 0x2 247 #define PTP_CHDK_CAPTURE_DNGHDR 0x4 250 #define PTP_CHDK_CAPTURE_NOTSET 0x10000000 253 enum ptp_chdk_script_msg_type {
254 PTP_CHDK_S_MSGTYPE_NONE = 0,
255 PTP_CHDK_S_MSGTYPE_ERR,
256 PTP_CHDK_S_MSGTYPE_RET,
257 PTP_CHDK_S_MSGTYPE_USER,
262 enum ptp_chdk_script_error_type {
263 PTP_CHDK_S_ERRTYPE_NONE = 0,
264 PTP_CHDK_S_ERRTYPE_COMPILE,
265 PTP_CHDK_S_ERRTYPE_RUN,
267 PTP_CHDK_S_ERR_SCRIPTRUNNING = 0x1000,
271 enum ptp_chdk_script_msg_status {
272 PTP_CHDK_S_MSGSTATUS_OK = 0,
273 PTP_CHDK_S_MSGSTATUS_NOTRUN,
274 PTP_CHDK_S_MSGSTATUS_QFULL,
275 PTP_CHDK_S_MSGSTATUS_BADID,
278 #endif // __CHDK_PTP_H