As I try and up my Lua scripting skills, it is clear I don't fully understand Event Procedures.Event Procedures
(aka eventprocs) are internal Canon functions built into the firmware, for their own development / service needs and scripting language
CHDK Lua is only involved to the extent that it provides an interface to call them.
Eventprocs are useful because they provide us with Canon's own names for some firmware functions, which in turn provides some clues about what they do. They also frequently do useful things. Because of this, the CHDK sig finders also detect many of them (along with many other functions), which generates the lists in the funcs_by_*.csv files.
So far I've explored FA and MECHA listings.
Note: Case matters, so it's FA.Create and Mecha.Create.
Let's say I'm only looking to code on my M3.
The first question is, do I need to call FA.create and MECHA.create?
If I don't, for example, FocusPositionWithLensCom works fine.
Eventprocs need to be "registered" to be used. Registering associates the name with address of the machine code. Some are registered by default, some are registered by calling other evenprocs, usually named something like Whatever.Create or RegisterWhateverSomething.
To find out whether an eventproc is registered, you either need to reverse engineer the firmware, or call it and check the return value. The return value will be -1 if the function isn't registered. Of course, a registered function could also return -1, but this is fairly rare, if the function doesn't otherwise return a value, Canon generally uses 0 for success.
If you have access to the camera UART
, the Event Shell
will also tell you whether a function is registered, or give you a list in response to ?
Then there is the question over what 'calls' to make, eg: FocusPositionWithLensCom vs MoveFocusLensWithPosition.
Tired: Judging books by their cover
Wired: Judging functions by their name
If you want more than just guessing based on the name, reverse engineering is required to understand more about the parameters, usage and purpose. Ghidra
is by far the best freely available tool for this, but a fair a bit of reverse engineering knowledge is required to use it effectively.