get_alt_mode (was Re: Multi-camera setup project.) - General Discussion and Assistance - CHDK Forum

get_alt_mode (was Re: Multi-camera setup project.)

  • 12 Replies
  • 6630 Views
get_alt_mode (was Re: Multi-camera setup project.)
« on: 13 / March / 2017, 15:58:34 »
Advertisements
Ran into a problem with some multicam development recently.

Why does get_alt_mode() check for (camera_info.state.gui_mode != 0)
rather than  (camera_info.state.gui_mode == GUI_MODE_ALT) ?

*

Online reyalp

  • ******
  • 14128
Re: get_alt_mode (was Re: Multi-camera setup project.)
« Reply #1 on: 13 / March / 2017, 17:22:30 »
I split this because it seems like a development question unrelated to mphx already very long thread https://chdk.setepontos.com/index.php?topic=11667.440

Regarding the question:
I don't remember the subtleties of this off the top of my head. It's complicated and a of evolution over a long period of time. Perhaps you could explain what issues are caused by using one vs the other?

ps: if you are going to quote me in your sig, attribution would be appreciated.
Don't forget what the H stands for.

Re: get_alt_mode (was Re: Multi-camera setup project.)
« Reply #2 on: 13 / March / 2017, 18:17:23 »
I decided I don't need this function in my script but do wonder how can it possibly work?

 If you are running a script you are in mode GUI_MODE_SCRIPT.
 If you are in GUI_MODE_ALT you are not running a script.
 
What is this function for?

PS:
Apologies, I had forgotten about the source of that signature long ago. I have deleted it.

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links

Re: get_alt_mode (was Re: Multi-camera setup project.)
« Reply #4 on: 13 / March / 2017, 21:59:19 »
=> http://chdk.wikia.com/wiki/CHDK_scripting#get_alt_mode

In gui.h we have
Code: [Select]
enum Gui_Mode_ {
    GUI_MODE_NONE = 0,
    GUI_MODE_ALT,
    GUI_MODE_MENU,
    GUI_MODE_SCRIPT,
    GUI_MODE_MBOX,
    GUI_MODE_OSD,       // OSD editor
    GUI_MODE_PALETTE,
    GUI_MODE_FSELECT,
    GUI_MODE_MPOPUP,
    GUI_MODE_MODULE,    // generic module
};

If we are already in GUI_MODE_SCRIPT we cannot be in GUI_MODE_ALT?

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: get_alt_mode (was Re: Multi-camera setup project.)
« Reply #5 on: 14 / March / 2017, 08:29:29 »
Why not? You can start or stop a script only in ALT mode.

But Gui_Mode_ is only relevant for some module functions and not for Lua get_alt_mode(). Search for gui_mode and gui_mode_alt in camera_info.h.

What is the main problem? Can you explain, what will you do?
CHDK-DE:  CHDK-DE links

Re: get_alt_mode (was Re: Multi-camera setup project.)
« Reply #6 on: 14 / March / 2017, 15:14:17 »
What is the main problem? Can you explain, what will you do?

Thanks for the information. I'll try to find some time soon to do more thorough investigation and come back with a better question (if it exists).

Re: get_alt_mode (was Re: Multi-camera setup project.)
« Reply #7 on: 15 / March / 2017, 11:30:40 »
What is the main problem? Can you explain, what will you do?

I don't have a workflow problem, however i'm still a little quizzical about a different matter (that I thought about while considering "get_alt_mode"). My original query [re: get_alt_mode()] is now no problem all.

Why not? You can start or stop a script only in ALT mode

Your comment prompted this quick investigation using multicam.lua - this a a trace of the test CLI I used:
Code: [Select]
__> !mc=require('multicam')
___> !mc:connect({list='C:/CHDKPTP/listfile'})
+ 1:Canon PowerShot SX150 IS b=\\.\libusb0-0001--0x04a9-0x3234 d=bus-0 s=9A95243
8E0A647E9AC0179DDC30582D5
___> !mc:start()
___> !return mc:cmdwait('test_alt')
test_alt
___> !return mc:cmdwait('enter_alt')
enter_alt
___> !return mc:cmdwait('test_alt')
test_alt
___> !return mc:cmdwait('exit_alt')
exit_alt
___> !return mc:cmdwait('test_alt')
test_alt
___> !mc:cmd('exit')
exit
___> !mc:start()
___> !return mc:cmdwait('test_alt')
test_alt
___> !mc:cmd('exit')
exit
___>

These are the extra cameraside multicam functions to enable that:
Code: [Select]
function cmds.enter_alt()                           
--e.g. to run !return mc:cmdwait('enter_alt')                           
    enter_alt()
    write_status(true)       
   
function cmds.exit_alt()                           
--e.g. to run !return mc:cmdwait('exit_alt')
    exit_alt()                   
    write_status(true)

--testing only below
function cmds.test_alt()                           
--e.g. to run !return mc:cmdwait('test_alt')

    local log_name = "A/get_alt_mode_log.csv"
    logalt = io.open(log_name,"a")
    local alt_value
   
    local alt_boolean_test = get_alt_mode()
   
    sleep(2000) --not sure if required
       
    if alt_boolean_test then
        alt_value_text = "true" else
        alt_value_text = "false"
    end
   
    logalt:write(alt_value_text,"\n")
       
    logalt:close()   
   
    write_status(true)
end


and this is the resulting content of "get_alt_mode_log.csv":
Code: [Select]
true
true
false
true

Since my last command, prior to exiting the script, was to exit_alt() [and that, correctly, tested as get_alt_mode "false"] i'm a bit unclear how, exactly, the chdkptp implementation of ptp.h:
Code: [Select]
  PTP_CHDK_ExecuteScript,   // data is script to be executed
                            // param2 is language of script
                            //  in proto 2.6 and later, language is the lower byte, rest is used for PTP_CHDK_SCRIPT_FL* flags
                            // return param1 is script id, like a process id
                            // return param2 is status, PTP_CHDK_S_ERRTYPE*

gets the camera into alt mode so that the script data sent over to the camera can start execution?

Edit: if it is the chdkptp implementation of that which does put it into alt mode.
« Last Edit: 15 / March / 2017, 12:01:24 by andrew.stephens.754365 »

*

Online reyalp

  • ******
  • 14128
Re: get_alt_mode (was Re: Multi-camera setup project.)
« Reply #8 on: 15 / March / 2017, 12:52:14 »
There is special handling for alt mode in PTP scripts, to avoid conflict between the GUI state and the rest of the CHDK state.

With regular non-PTP scripts, you must already be in alt mode to start a script, so script always starts in a consistent state. In PTP, the camera can be in either state, and in the original implementation, this lead to a state where the camera didn't appear to be in alt mode but also didn't respond to key presses.

See trunk revisions 2944 and 2945
Don't forget what the H stands for.

Re: get_alt_mode (was Re: Multi-camera setup project.)
« Reply #9 on: 15 / March / 2017, 13:22:35 »
There is special handling for alt mode in PTP scripts, to avoid conflict between the GUI state and the rest of the CHDK state.

Ok - thanks.

 

SimplePortal © 2008-2014, SimplePortal