chdkptp supports console CLI, a GUI, and batch operation. The gui is not currently very useful =Command line= The interface is selected by command line options Usage: chdkptp [options] Options: -g start gui -i start interactive cli -c connect at startup, with optional device spec e.g. -c"-d001 -bbus-0" -n non-interactive - quit after processing command line options (default) -e execute cli command, multiple allowed, e.g -e"u DISKBOOT.BIN" -ereboot -h help =CLI= CLI commands are available from the console, gui and the command line ==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. quit (q) : - quit program 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]: - read memory list : - list devices Lists all recognized PTP devices in the following format b= d= v= p= s= status values * connected, current target for CLI commands (con global variable) + connected, not CLI target - not connected 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 -nomtime don't preserve modification time of remote files 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) : - print API versions 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 =Examples= start chdkptp in interactive mode and connect to the camera chdkptp -i -c execute lua on host PC and print the result con> !return 1+1 =2 execute lua on the camera, and print the result con> =return get_buildinfo() 1:return:table:{platformid=12732,platform="d10",version="CHDK",platsub="100a",build_number="0.9.9",os="dryos",build_date="May 3 2011",build_time="20:54:20",} upload diskboot.bin to A/diskboot.bin, reboot camera, enter interactive mode chdkptp -c -e"u bin/diskboot.bin" -ereboot -i upload interval.lua to A/CHDK/SCRIPTS/interval.lua, from the command line chdkptp -c -e"u interval.lua CHDK/SCRIPTS/" download A/CHDK/CCHDK.CFG to BACKUP.CFG in the current directory chdkptp -c -e"d CHDK/CCHDK.CFG BACKUP.CFG" connect to the device with name containing D10 on bus "bus-0", chdkptp -c"D10 -b=bus%-0" -i note connect -b takes a lua pattern, so % is needed to escapes the - download some jpeg images (in 100CANON etc folders) con> mdl -fmatch=%.JPG$ DCIM C:\temp delete some raw images con> rm -nodirs -fmatch=%.CRW$ DCIM upload some scripts con> mup c:\CHDK\SCRIPTS CHDK/SCRIPTS ad hoc scripting on PC side - download some files con> !t=con:listdir('A/DCIM/100CANON',{match="%.JPG$"}) con> !for i,n in ipairs(t) do con:download("A/DCIM/100CANON/"..n,"C:/TEMP/"..n) end note the mdownload cli command above is probably more convenient list devices and connect to a specific camera ___> list 1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=12345678123456781234567812345678 2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil ___> c 540 con> list 1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=12345678123456781234567812345678 *2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil =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 you have built IUP and not installed the libraries to the system lib directory, you must also set LD_LIBARARY_PATH $ LD_LIBRARY_PATH=/path/to/iup LUA_PATH="/path/to/chdkptp/lua/?.lua" /path/to/chdkptp -g This can be done in a shell script, see chdkptp-sample.sh