Sending set commands to specific camera in array on multi camera project - Script Writing - CHDK Forum

Sending set commands to specific camera in array on multi camera project

  • 5 Replies
Hi everyone,

I have set a camera array and am sending commands to all cameras connected. But I wonder if it is possible to send commands to individual camera(s). For example cam1,cam2,cam3,cam4 are connected via hub1 cam5,cam6,cam7,cam8 are connected via hub2. I want to set iso values of cameras on hub1 to a value and want to set iso values of cameras on hub2 to another value.

What occurs to me at first is disconnect hub1 and set camera array 1, and disconnect hub2 and set camera array 2. Is this a good idea or anyone else have a better solution.

Thanks in advance.


Offline reyalp

  • ******
  • 14098
multicam.lua has code for operating on subsets of cameras, and loading/saving lists of cameras.

Some discussion can be found in and

So for example, you could:
Power on all the cameras on hub 1

then later, when all cams are running, you could do something like
to select only the cameras on that hub. When you want go back to working on all cameras, you would use

Note the above is all off the top my head, and it's been a long time since I looked at this code. I'm also not sure how extensively this has been used in the real world, there may well be bugs.
Don't forget what the H stands for.

The command line will be a bit long with the following, but...

if you line up your serial numbers/camid in the listfile (continuous list of ID's, starting at 1, with isocam1 described below relating to camid 1 etc) , described here, I think you could add something like this to multicam.lua pc side code (2 cam example, tested with zoom):
Code: [Select]
function mc:set_iso_value_uniquely_cam(lcon,opts)
local ropts=util.extend_table({},opts)

        --add similar for all other cams:
if lcon.mc_id == 1 then camiso=ropts.isocam1 end
if lcon.mc_id == 2 then camiso=ropts.isocam2 end

local sendcmd = string.format('set_iso_uniquely %s',camiso)
local status,err = lcon:write_msg_pcall(sendcmd)

if not status then
warnf('%s: send %s cmd failed: %s\n',lcon.mc_id,tostring(sendcmd),tostring(err))

function mc:set_iso_value_uniquely(opts)
for lcon in self:icams() do

and add your own version of this to multicam.lua camera side script, eg:

Code: [Select]
function cmds.set_iso_uniquely()

Then call it like this (extend for all cams):

Code: [Select]
Edit: you'd need to connect using the listfile relationship every time.
« Last Edit: 31 / May / 2015, 08:45:13 by andrew.stephens.754365 »


Offline reyalp

  • ******
  • 14098
Replying to PM here. As I mentioned before, I prefer to have this kind of question in the public forum.
Quote from: simtek
Is this the right way:
Code: [Select]
cli:execute("!return mc:cmdwait('call set_tv96_direct(768) set_sv96(384)')")
I think it's valid syntax, if that's what you mean. Note the 768 and 384 were just numbers off the top of my head, they should be whatever APEX96 values you want.

In the CLI, ! means execute Lua code. So in general, cli:execute('!whatever()') is redundant. You can just call whatever() in your own code.

The return in an ! command causes the results to be printed, so if you want that when calling the code directly, you'll have to do it yourself.

Error handling is also slightly different, since the CLI will catch errors and print the result.

if so , my camera does not respond
What do you mean by "does not respond"? Does the camera freeze, or the settings are not used? Or ...?

The cli:execute should return some status value, as should the underlying mc:cmdwait. You should make a habit of checking or displaying the status values, especially if the code doesn't do what you expect.
Don't forget what the H stands for.

Freeze means that for instance I clicked a button and send command to camera.Then the program waits for code to return to be active.


Offline reyalp

  • ******
  • 14098
Freeze means that for instance I clicked a button and send command to camera.Then the program waits for code to return to be active.
I still don't really understand. If you mean chdkptp doesn't respond until the command is complete, that is is normal. chdkptp is single threaded.

It should possible to avoid completely blocking chdkptp using the coroutine method that is used for manually entered commands in the console, but some non-trivial coding is probably required. See btn_exec:action and gui.chdku_sleep. Eventually I'd like to make this more generic.

If you mean the cameras never responds to the command, that's a problem that needs to be debugged.
Don't forget what the H stands for.


Related Topics

SimplePortal 2.3.6 © 2008-2014, SimplePortal