how to check if native calls are enabled? - LUA Scripting - CHDK Forum  

how to check if native calls are enabled?

  • 9 Replies
  • 2198 Views
*

Offline Mlapse

  • *****
  • 583
  • S95 S110
how to check if native calls are enabled?
« on: 15 / March / 2022, 07:41:57 »
Advertisements
I was trying to check if native calls are enabled.

so tried: (with native calls enabled in CHDK)
get_config_value(require'GEN/cnf_core'.script_allow_lua_native_calls) == true
but it stated: expected number got nil

so i thought, maybe i'm wrong and tried
get_config_value(999) == true
but that appeared to be false too

isn't this available for readout?

frustration is a key ingredient in progress

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: how to check if native calls are enabled?
« Reply #1 on: 15 / March / 2022, 11:51:55 »
 ;) ... Written in Romlog.Lua:
Code: [Select]
if (type(call_event_proc) ~= "function") then
    error("ERROR: your CHDK does not support native function calls")
end
All lifetime is a loan from eternity.

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: how to check if native calls are enabled?
« Reply #2 on: 15 / March / 2022, 12:01:48 »
haven't tested that, because i thought this was only to see if your CHDK version supports native calls. and i'm looking for if it is set (active) or not
frustration is a key ingredient in progress

*

Offline Caefix

  • *****
  • 945
  • Sorry, busy deleting test shots...
Re: how to check if native calls are enabled?
« Reply #3 on: 15 / March / 2022, 12:12:55 »
... and i'm looking for if it is set (active) or not
All my CHDKs are compiled with FORCE_LUA_CALL_NATIVE.  :o
I can´t switch it off for testing, because then there´s no switch in the menu...
All lifetime is a loan from eternity.


*

Offline reyalp

  • ******
  • 14079
Re: how to check if native calls are enabled?
« Reply #4 on: 15 / March / 2022, 13:44:29 »
;) ... Written in Romlog.Lua:
Code: [Select]
if (type(call_event_proc) ~= "function") then
    error("ERROR: your CHDK does not support native function calls")
end
This is an old method that doesn't work on modern CHDK. For that script, it doesn't matter, because attempting to use a native call will generate a similar error.

You should be able to use
Code: [Select]
if get_config_value(1999) == 1
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: how to check if native calls are enabled?
« Reply #5 on: 15 / March / 2022, 13:56:01 »
You should be able to use
Code: [Select]
if get_config_value(1999) == 1

although i cannot find 1999 back in the conf.c file it seems to work, so it's a keeper.

looking at another value without testing i have usb enable: set_config_value(121, 1) but if i look at config.c i could not find usb enable.
so i thought it should be set_config_value(200,1) -- remote enable
so the numbers in config.c are not usable in a script?
 
« Last Edit: 15 / March / 2022, 14:23:14 by Mlapse »
frustration is a key ingredient in progress

*

Offline reyalp

  • ******
  • 14079
Re: how to check if native calls are enabled?
« Reply #6 on: 15 / March / 2022, 14:19:45 »
although i cannot find 1999 back in the conf.c file it seems to work, so it's a keeper.
The different conf files (core, osd etc) IDs are identified by offsets defined in conf.c
Code: [Select]
// ID offsets for ConfInfo mapping from Lua libraries
#define CONF_CORE   1000
#define CONF_OSD    2000
#define CONF_USER   3000
#define CONF_GPS    4000
ids lower than 1000 are mapped to be backward compatible with the ids used before the conf files were split, but that doesn't include the native calls option.
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: how to check if native calls are enabled?
« Reply #7 on: 15 / March / 2022, 14:35:04 »
ids lower than 1000 are mapped to be backward compatible with the ids used before the conf files were split, but that doesn't include the native calls option.

ah, so for usb enable i should use
Code: [Select]
set_config_value(1200,1)
as listed in cnf_core.lua
« Last Edit: 15 / March / 2022, 14:38:49 by Mlapse »
frustration is a key ingredient in progress


*

Offline reyalp

  • ******
  • 14079
Re: how to check if native calls are enabled?
« Reply #8 on: 16 / March / 2022, 00:49:41 »
Code: [Select]
set_config_value(1200,1)
as listed in cnf_core.lua
You can, but the cnf_* values are there so you can use them by name, which tends to be more readable, like
Code: [Select]
cnf_core = require'gen/cnf_core'
set_config_value(cnf_core.remote_enable,1)
(except the native calls one which isn't included for obscure reasons :-[)
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 583
  • S95 S110
Re: how to check if native calls are enabled?
« Reply #9 on: 16 / March / 2022, 03:02:59 »
(except the native calls one which isn't included for obscure reasons :-[)

i read something about it from an early post (2008?) that i can't trace back.
it has a warning if you enable it and was considered a risk if you could set it from script.
why it isn't listed for reading though is just as much a guess for me.

and i'll change to the more readable code for other items :)
frustration is a key ingredient in progress

 

Related Topics