chdkptp supports console CLI, a GUI, and batch operation. The GUI is still unfinished =Invoking= The interface is selected by command line options, described below. ==Running under linux== Under linux, the .lua files will not automatically found relative to the executable directory. You can set LUA_PATH on the command line to allow them to be located: $ LUA_PATH="/path/to/chdkptp/lua/?.lua" /path/to/chdkptp ... Similarly, if the IUP and CD shared libraries are not on the default system path, you must also set LD_LIBARARY_PATH $ LD_LIBRARY_PATH=/path/to/iup LUA_PATH="/path/to/chdkptp/lua/?.lua" /path/to/chdkptp -g It is suggested that you put all this in a shell script, see chdkptp-sample.sh for an example. ==Command line== Usage: chdkptp [options] Options: -g start GUI - default if GUI available and no options given -i start interactive CLI -c connect at startup, with optional device spec e.g. -c"-d001 -bbus-0" -e execute CLI command, multiple allowed, e.g -e"u DISKBOOT.BIN" -ereboot -r specify startup command file, if no file given skip default startup files -h help If invoked with no options, the GUI will be started if available. Otherwise, the CLI will be started. If started with options and neither -g nor -i is given, chdkptp will run in batch mode, exiting after performing the actions specified by in the options When using -e, -c or -r, you must quote any arguments that include spaces ==Startup files== Startup files can be used to automatically execute CLI commands at startup. Using the exec command, you may also execute arbitrary lua. If the -r command line option is used, it is treated as the full name of the file, and the default files are ignored. If -r is given without a filename, no startup file is used. If -r is not used, CHDKPTP checks for startup files using the CHDKPTP_HOME environment variable, or if that is not set, the HOME environment variable. .chdkptprc (linux) / _chdkptprc (windows) is the default startup file in CLI or batch mode. .chdkptpguirc (linux) / _chdkptpguirc (windows) is the default startup file in GUI mode. This is run after the gui module is loaded, but before the GUI is started. =CLI= CLI commands are available from the console, GUI and the command line Many CLI commands have full descriptive name and a short name. The short is listed in parenthesis in the command reference below. ==CLI parsing== The cli commands lua, luar, exec and putm all accept a single line of free-form text and pass it unmodified to the underlying function. Most other commands parse the remaining input into switches and arguments Switches are in the for -switchname and may take values with -switch=value Arguments are any other sequence of non-space or quoted characters. Both switches and words may be quoted as follows: The characters " or ' can be used to quote arguments or switch values that contain spaces. Inside double quotes "", backslash \ is treated as an escape character. ==Command reference== output of help -v help (h) [cmd]|[-v] : - help on [cmd] or all commands help -v gives full help on all commands, otherwise as summary is printed # : - comment exec (!) : - execute local lua Execute lua in chdkptp. The global variable con accesses the current CLI connection. Return values are printed in the console. set [-v|-c] [option[=value]]: - show or set option Use set with no options to see a list -v show desciption when showing value -c output as set command quit (q) : - quit program source : - execute cli commands from file lua (.) : - execute remote lua Execute Lua code on the camera. Returns immediately after the script is started. Return values or error messages can be retrieved with getm after the script is completed. getm : - get messages putm : - send message luar (=) : - execute remote lua, wait for result Execute Lua code on the camera, waiting for the script to end. Return values or error messages are printed after the script completes. rmem
[count] [-i32[=fmt]]: - read memory Dump bytes or words starting at
-i32 display as 32 bit words rather than byte oriented hex dump -i32= use printf format string fmt to display list : - list devices Lists all recognized PTP devices in the following format on success : b= d= v= p= s= or on error b= d= ERROR: status values * connected, current target for CLI commands (con global variable) + connected, not CLI target - not connected ! error querying status serial numbers are not available from all models upload (u) [-nolua] [remote]: - upload a file to the camera file to upload [remote] destination If not specified, file is uploaded to A/ If remote is a directory or ends in / uploaded to remote/ -nolua skip lua based checks on remote Allows upload while running script Prevents detecting if remote is a directory Some cameras have problems with paths > 32 characters Dryos cameras do not handle non 8.3 filenames well download (d) [-nolua] [local]: - download a file from the camera file to download A/ is prepended if not present [local] destination If not specified, the file will be downloaded to the current directory If a directory, the file will be downloaded into it -nolua skip lua based checks on remote Allows download while running script mdownload (mdl) [options] : - download file/directories from the camera files/directories to download directory to download into options: -fmatch= download only file with path/name matching -dmatch= only create directories with path/name matching -rmatch= only recurse into directories with path/name matching -nodirs only create directories needed to download file -maxdepth=n only recurse into N levels of directory -pretend print actions instead of doing them -nomtime don't preserve modification time of remote files -batchsize=n lower = slower, less mememory used -dbgmem print memory usage info -overwrite= overwrite existing files (y|n|old) note is a lua pattern, not a filesystem glob like *.JPG mupload (mup) [options] : - upload file/directories to the camera files/directories to upload directory to upload into options: -fmatch= upload only file with path/name matching -dmatch= only create directories with path/name matching -rmatch= only recurse into directories with path/name matching -nodirs only create directories needed to upload file -maxdepth=n only recurse into N levels of directory -pretend print actions instead of doing them -nomtime don't preserve local modification time note is a lua pattern, not a filesystem glob like *.JPG delete (rm) [options] : - delete file/directories from the camera files/directories to remote options: -fmatch= upload only file with names matching -dmatch= only delete directories with names matching -rmatch= only recurse into directories with names matching -nodirs don't delete drictories recursed into, only files -maxdepth=n only recurse into N levels of directory -pretend print actions instead of doing them -ignore_errors don't abort if delete fails, continue to next item -skip_topdirs don't delete directories given in command line, only contents note is a lua pattern, not a filesystem glob like *.JPG mkdir : - create directories on camera directory to create. Intermediate directories will be created as needed version (ver) [-p] : - print API and program versions -p print program version connect (c) [-b=] [-d=] [-p=] [-s=] [model] : - connect to device If no options are given, connects to the first available device. is the USB product ID, as a decimal or hexadecimal number. All other options are treated as a Lua pattern. For alphanumerics, this is a case sensitive substring match. If the serial or model are specified, a temporary connection will be made to each device If includes spaces, it must be quoted. If multiple devices match, the first matching device will be connected. reconnect (r) : - reconnect to current device disconnect (dis) : - disconnect from device ls [-l] [path] : - list files/directories on camera reboot [options] [file]: - reboot the camera file: Optional file to boot. Must be an unencoded binary or for DryOS only, an encoded .FI2 Format is assumed based on extension If not set, firmware boots normally, loading diskboot.bin if configured options: -norecon don't try to reconnect -wait= wait N ms before attempting to reconnect, default 3500 dumpframes [options] [file]: - dump camera display frames to file file: optional output file name, defaults to chdk___