- mc:cmd('id') turned out to be really handy, I saw a similar thing by waterwingz (number and status in the display) and wanted to ask for a similar thing. This does it, but... First time I used it, the list numbered 3 cameras as 1, 2 &3, but in the display the cameras were offset by one number (2,3,&4). I unplugged my mouse (only usb thing I had connected to the laptop aside from cameras) tried again and numbers showed up correctly. Now tried again, with mouse plugged and it's working fine too...?? Are these numbers persistent? I suppose not, any way to make them persistent from session to session?
You can make them persistent using the camera list function I mentioned in the previous post.
Specifically, after you have all the cameras connected, you can do something like
!mc:save_list('cams.txt')
If you want to make a list of only some of the cameras, you can use mc:sel() to select them first.
-- select all available cameras
mc:sel('all')
-- select camera ID 1
mc:sel(1)
-- select cameras 1,3 ,5
mc:sel({1,3,5})
-- select cameras 3 through 9
mc:sel({min=3,max=9})
mc functions like mc:shoot and mc:cmdwait operate on all the selected cameras.
Once you have a list saved, you can connect to those cameras with the same IDs later, using the list option, like:
mc:connect({list='cams.txt'})
-I'd like to dig deeper into the variables for mc:shoot, where can I check them?
The major multicam functions are usually documented in multicam.lua. Find "function mc:shoot" and then look at the part above between --[[ and --]]
I've tried !mc:cmdwait('call <get_focus_ok>') but nothing happened, why do mc:shoot variables syntax differ from the cross reference page you linked? I think I'm not using this correctly
Because they're different things
mc:shoot() takes options, that are defined within mc:shoot. It interprets those options and builds a sequence of multicam commands to send with mc:cmd
mc:cmd / mc:cmdwait take "commands" which are defined within the camera side part of the multicam script, found at the bottom of the multicam.lua file, in chdku.rlibs:register
call in mc:cmdwait('call ...') is a command as described above, where the part following call is treated as camera side Lua, which is described on the wiki page.
Your example is almost right, but if you want to get a value back, you need to use return, and you need to display the result, like
!mc:print_cmd_status(mc:cmdwait('call return get_focus_ok()'))
That outputs a verbose structure like
1: {
done=true,
failed=false,
status={
status={
[1]=false,
},
cmd="call",
},
}
2: {
...
The outer 1 means the stuff in the following { } is for camera ID 1
The innermost status is what the lua code returned, in this case, it returned one value which was false (focus not OK)
If you want less verbose output, you can process the returned values with your own code instead of mc:print_cmd_status, like
!status,r=mc:cmdwait('call return get_focus_ok()') if status then for id,v in ipairs(r) do if v.failed then printf('%d: failed\n',id) else printf('%d %s\n',id,tostring(v.status.status[1])) end end end
(note above is all one line)
And finally, once i get the code properly set up, I'd like to create BAT executables with groups of orders sent to camera (one to initialize, one to set focus and lock it, one to set exposure, one to shoot in sync, and last one to download and delete images) instead of sending lines of code one by one.
I'd suggest using Lua files you can run from the chdkptp prompt rather than bat files for most of this, because if you quit chdkptp in between you'd need to re-connect and re-initialize between each one.
You can do this by creating a text file myinit.lua with with
mc=require'multicam'
mc:connect()
mc:start()
mc:rec()
And then in the chdkptp prompt, use
!dofile('myinit.lua')
Note that inside the myinit.lua file, the mc: commands do NOT have an ! in front of them. The ! in chdkptp is what tell chdkptp that the thing following it should be treated as chdkptp Lua code.
If you just give a file name like above, the file is expected to be in the same directory you started chdkptp from. You can use a full path like dofile('c:/whatever/files/myfile.lua'). Use forward slashes / to avoid confusion with \ being treated as an escape character.
You could create more files for shooting, download etc.
You can start the whole thing with myinit from a batch file like
chdkptp -e"exec dofile('myinit.lua')"