how to check if in record or play when get_mode() not avialable - LUA Scripting - CHDK Forum supplierdeeply

how to check if in record or play when get_mode() not avialable

  • 6 Replies
  • 2266 Views
*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Advertisements
when i start my camera in play or shoot, activate and start the script it appears get_mode() has no value.
is there a value that i can use that would tell me for certain if the cam is in shooting mode or in play?
that is without using set_record() first. if the only option is something like:
Code: [Select]
if get_focus() > 10 then
it's fine with me :)

it's because when in record and move to play i need a long sleep because it takes a minute to retract the lens. and as far as i know there is no way to force the lens closed.
i like to avoid that sleep if script is started when in play mode.
« Last Edit: 17 / April / 2022, 13:59:25 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14117
Re: how to check if in record or play when get_mode() not avialable
« Reply #1 on: 17 / April / 2022, 17:06:23 »
when i start my camera in play or shoot, activate and start the script it appears get_mode() has no value.
What do you mean by "has no value" ? What is the affected code and specific symptom or error message?

In CHDK Lua, get_mode() always returns two boolean values and a number. The only way it could do otherwise is some kind of internal error in the Lua engine.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to check if in record or play when get_mode() not avialable
« Reply #2 on: 17 / April / 2022, 17:12:45 »
i mean that if at start of script i do
Code: [Select]
                while not get_mode() do
                    sleep(100)
                end

it will not end, what you are saying is i probably first have to use something like
rec,vid,mode=get_mode()
while not mode do
« Last Edit: 17 / April / 2022, 17:21:17 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14117
Re: how to check if in record or play when get_mode() not avialable
« Reply #3 on: 17 / April / 2022, 17:53:54 »
i mean that if at start of script i do
Code: [Select]
                while not get_mode() do
                    sleep(100)
                end

it will not end, what you are saying is i probably first have to use something like
rec,vid,mode=get_mode()
while not mode do
No.
The values returned by get_mode are  rec (is the camera in rec mode), video (is the current mode a video recording mode) and the mode number (a number, which in Lua is always true in a boolean context). In an expression like while get_mode() do, the first return value (rec in this case) is used and the others are discarded.

What you describe means that 'rec' stays false, meaning the camera is in playback under the conditions your script is running. If the logic of your script is trying to switch to rec, you need figure out why that is not working. Or if the camera actually switches to rec, there's some kind of bug in the port.

Note in chdkptp,  you can easily see what get_mode does, by using
Code: [Select]
=return get_mode()
Don't forget what the H stands for.


*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to check if in record or play when get_mode() not avialable
« Reply #4 on: 17 / April / 2022, 18:11:30 »
...i'll start investigating via chdkptp.
but it's in record while stating it's in play.
« Last Edit: 17 / April / 2022, 18:40:13 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14117
Re: how to check if in record or play when get_mode() not avialable
« Reply #5 on: 17 / April / 2022, 19:22:05 »
...i'll start investigating via chdkptp.
but it's in record while stating it's in play.
Is it really in record, or is it in play with the lens still extended? If it's actually in record, you should see the live view on the camera screen, and be able to shoot if you exit the script.

If get_mode says the camera is in play when it is actually in record, then that's a major bug in the port or CHDK. In that case, please tell us which camera, firmware version and what steps lead to the camera getting into that state.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: how to check if in record or play when get_mode() not avialable
« Reply #6 on: 18 / April / 2022, 03:53:38 »
the problem occured when i had usb remote with
set_config_value(121,1)
activated from script before the get_mode() request.
or when the cam had crashed and usb remote was still set active at boot. (after battery replace to get it going again)
if it was in record it would crash. if in play it would crash if i turned it off.

however the problem is no longer there after i have manually set USB remote a few times on and off in the menu.

i then copied the file to another s110 that i hadn't tried yet, but could not replicate the problem. so it appears this one cam got confused, but using the menu settings solved it
« Last Edit: 18 / April / 2022, 06:12:25 by Mlapse »
frustration is a key ingredient in progress

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal