source: trunk/USAGE.TXT @ 134

Revision 134, 9.1 KB checked in by reyalp, 16 months ago (diff)

chdku con:connect now store ptp, usb and chdk api version information in con object by default
add reconnect to chdku, checks if pid, model and serial match. affects cli reconnect and reboot
list cli output changed, missing serial number is now "nil" rather than "(none)"
reboot now takes an options -wait=<ms> and -norecon

  • Property svn:eol-style set to native
Line 
1chdkptp supports console CLI, a GUI, and batch operation.
2
3The gui is not currently very useful
4
5=Command line=
6The interface is selected by command line options
7Usage: chdkptp [options]
8Options:
9  -g    start gui
10  -i    start interactive cli
11  -c    connect at startup, with optional device spec e.g. -c"-d001 -bbus-0"
12  -n    non-interactive - quit after processing command line options (default)
13  -e    execute cli command, multiple allowed, e.g -e"u DISKBOOT.BIN" -ereboot
14  -h    help
15
16=CLI=
17CLI commands are available from the console, gui and the command line
18
19==CLI parsing==
20The cli commands lua, luar, exec and putm all accept a single line of free-form text
21and pass it unmodified to the underlying function.
22
23Most other commands parse the remaining input into switches and arguments
24Switches are in the for -switchname and may take values with -switch=value
25Arguments are any other sequence of non-space or quoted characters.
26
27Both switches and words may be quoted as follows:
28The characters " or ' can be used to quote arguments or switch values that contain spaces
29Inside double quotes "",  backslash \ is treated as an escape character.
30
31==Command reference==
32output of help -v
33help (h)     [cmd]|[-v]  : - help on [cmd] or all commands
34 help -v gives full help on all commands, otherwise as summary is printed
35
36#                        : - comment
37exec (!)     <lua code>  : - execute local lua
38 Execute lua in chdkptp.
39 The global variable con accesses the current CLI connection.
40 Return values are printed in the console.
41
42quit (q)                 : - quit program
43lua (.)      <lua code>  : - execute remote lua
44 Execute Lua code on the camera.
45 Returns immediately after the script is started.
46 Return values or error messages can be retrieved with getm after the script is completed.
47
48getm                     : - get messages
49putm         <msg string>: - send message
50luar (=)     <lua code>  : - execute remote lua, wait for result
51 Execute Lua code on the camera, waiting for the script to end.
52 Return values or error messages are printed after the script completes.
53
54rmem         <address> [count]: - read memory
55list                     : - list devices
56 Lists all recognized PTP devices in the following format
57  <status><num><modelname> b=<bus> d=<device> v=<usb vendor> p=<usb pid> s=<serial number>
58 status values
59  * connected, current target for CLI commands (con global variable)
60  + connected, not CLI target
61  - not connected
62 serial numbers are not available from all models
63
64upload (u)   [-nolua] <local> [remote]: - upload a file to the camera
65 <local>  file to upload
66 [remote] destination
67   If not specified, file is uploaded to A/
68   If remote is a directory or ends in / uploaded to remote/<local file name>
69 -nolua   skip lua based checks on remote
70   Allows upload while running script
71   Prevents detecting if remote is a directory
72 Some cameras have problems with paths > 32 characters
73 Dryos cameras do not handle non 8.3 filenames well
74
75download (d) [-nolua] <remote> [local]: - download a file from the camera
76 <remote> file to download
77        A/ is prepended if not present
78 [local]  destination
79   If not specified, the file will be downloaded to the current directory
80   If a directory, the file will be downloaded into it
81 -nolua   skip lua based checks on remote
82   Allows download while running script
83
84mdownload (mdl) [options] <remote, remote, ...> <target dir>: - download file/directories from the camera
85 <remote...> files/directories to download
86 <target dir> directory to download into
87 options:
88   -fmatch=<pattern> download only file with path/name matching <pattern>
89   -dmatch=<pattern> only create directories with path/name matching <pattern>
90   -rmatch=<pattern> only recurse into directories with path/name matching <pattern>
91   -nodirs           only create directories needed to download file
92   -maxdepth=n       only recurse into N levels of directory
93   -nomtime                      don't preserve modification time of remote files
94 note <pattern> is a lua pattern, not a filesystem glob like *.JPG
95
96mupload (mup) [options] <local, local, ...> <target dir>: - upload file/directories to the camera
97 <local...> files/directories to upload
98 <target dir> directory to upload into
99 options:
100   -fmatch=<pattern> upload only file with path/name matching <pattern>
101   -dmatch=<pattern> only create directories with path/name matching <pattern>
102   -rmatch=<pattern> only recurse into directories with path/name matching <pattern>
103   -nodirs           only create directories needed to upload file
104   -maxdepth=n       only recurse into N levels of directory
105   -pretend          print actions instead of doing them
106   -nomtime          don't preserve local modification time
107 note <pattern> is a lua pattern, not a filesystem glob like *.JPG
108
109delete (rm)  [options] <target, target,...>: - delete file/directories from the camera
110 <target...> files/directories to remote
111 options:
112   -fmatch=<pattern> upload only file with names matching <pattern>
113   -dmatch=<pattern> only delete directories with names matching <pattern>
114   -rmatch=<pattern> only recurse into directories with names matching <pattern>
115   -nodirs           don't delete drictories recursed into, only files
116   -maxdepth=n       only recurse into N levels of directory
117   -pretend          print actions instead of doing them
118   -ignore_errors    don't abort if delete fails, continue to next item
119   -skip_topdirs     don't delete directories given in command line, only contents
120 note <pattern> is a lua pattern, not a filesystem glob like *.JPG
121
122mkdir        <directory> : - create directories on camera
123 <directory> directory to create. Intermediate directories will be created as needed
124
125version (ver)             : - print API versions
126connect (c)  [-b=<bus>] [-d=<dev>] [-p=<pid>] [-s=<serial>] [model] : - connect to device
127 If no options are given, connects to the first available device.
128 <pid> is the USB product ID, as a decimal or hexadecimal number.
129 All other options are treated as a Lua pattern. For alphanumerics, this is a case sensitive substring match.
130 If the serial or model are specified, a temporary connection will be made to each device
131 If <model> includes spaces, it must be quoted.
132 If multiple devices match, the first matching device will be connected.
133
134reconnect (r)             : - reconnect to current device
135disconnect (dis)             : - disconnect from device
136ls           [-l] [path] : - list files/directories on camera
137reboot       [options] [file]: - reboot the camera
138 file: Optional file to boot.
139  Must be an unencoded binary or for DryOS only, an encoded .FI2
140  Format is assumed based on extension
141  If not set, firmware boots normally, loading diskboot.bin if configured
142 options:
143   -norecon  don't try to reconnect
144   -wait=<N> wait N ms before attempting to reconnect, default 3500
145
146=Examples=
147start chdkptp in interactive mode and connect to the camera
148 chdkptp -i -c
149
150execute lua on host PC and print the result
151con> !return 1+1
152=2
153
154execute lua on the camera, and print the result
155con> =return get_buildinfo()
1561: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",}
157
158upload diskboot.bin to A/diskboot.bin, reboot camera, enter interactive mode
159 chdkptp -c -e"u bin/diskboot.bin" -ereboot -i
160
161upload interval.lua to A/CHDK/SCRIPTS/interval.lua, from the command line
162 chdkptp -c -e"u interval.lua CHDK/SCRIPTS/"
163
164download A/CHDK/CCHDK.CFG to BACKUP.CFG in the current directory
165 chdkptp -c -e"d CHDK/CCHDK.CFG BACKUP.CFG"
166
167connect to the device with name containing D10 on bus "bus-0",
168 chdkptp -c"D10 -b=bus%-0" -i
169note connect -b takes a lua pattern, so % is needed to escapes the -
170
171download some jpeg images (in 100CANON etc folders)
172con> mdl -fmatch=%.JPG$ DCIM C:\temp
173
174delete some raw images
175con> rm -nodirs -fmatch=%.CRW$ DCIM
176
177upload some scripts
178con> mup c:\CHDK\SCRIPTS CHDK/SCRIPTS
179
180ad hoc scripting on PC side - download some files
181con> !t=con:listdir('A/DCIM/100CANON',{match="%.JPG$"})
182con> !for i,n in ipairs(t) do con:download("A/DCIM/100CANON/"..n,"C:/TEMP/"..n) end
183note the mdownload cli command above is probably more convenient
184
185list devices and connect to a specific camera
186___> list
187 1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=12345678123456781234567812345678
188 2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil
189___> c 540
190con> list
191 1:Canon PowerShot D10 b=bus-0 d=\\.\libusb0-0001--0x04a9-0x31bc v=0x4a9 p=0x31bc s=12345678123456781234567812345678
192*2:Canon PowerShot A540 b=bus-0 d=\\.\libusb0-0002--0x04a9-0x311b v=0x4a9 p=0x311b s=nil
193
194=Running under linux=
195Under linux, the .lua files will not automatically found relative to the executable directory
196You can set LUA_PATH on the command line to allow them to be located:
197$ LUA_PATH="/path/to/chdkptp/lua/?.lua" /path/to/chdkptp ...
198
199Similarly, if you have built IUP and not installed the libraries to the system lib directory,
200you must also set LD_LIBARARY_PATH
201$ LD_LIBRARY_PATH=/path/to/iup LUA_PATH="/path/to/chdkptp/lua/?.lua" /path/to/chdkptp -g
202
203This can be done in a shell script, see chdkptp-sample.sh
204
Note: See TracBrowser for help on using the repository browser.