CHDK Wiki
(Adding categories)
Line 53: Line 53:
 
[[Category:CHDK internals]]
 
[[Category:CHDK internals]]
 
[[Category:CanonBasic]]
 
[[Category:CanonBasic]]
  +
[[Category:EventProcedure]]

Revision as of 02:27, 4 December 2010

Starting a draft page to document eventprocs this is an incomplete draft please update with your observations. Thread http://chdk.setepontos.com/index.php/topic,4417.0.html

Overview

An event procedure (or eventproc) is a function in the canon firmware associated with a text name. An API exists in the canon firmware to register, execute and un-register them.

Event procedures are available from Canon Basic

Event Procedure API functions

  • int ExecuteEventProcedure(const char *name,...)

executes the named eventproc, with the supplied arguments. Returns -1 if the eventproc isn't registered. Otherwise, returns the eventprocs return value.

note on newer cameras (most dryos ?), there are two versions of this function. One returns -1 if the eventproc isn't registered, while the other triggers an assert. The assert version is called from most ROM code, while the other is used if ExecuteEventProcededure is called from script.

  • void ExportToEventProcedure(const char *name,void *pfunc)

registers eventproc pfunc with name. Registering an event procedure with a name that is already registered replaces the existing eventproc.

Lua interface

Event procedures may be called from lua using the LUA/LUA Reference/Native Function Calls interface.

Event Procedures as hooks

Some event procedures can be called automatically from camera code at various points, allowing them to be used as hooks. Thread http://chdk.setepontos.com/index.php/topic,5690.0.html

Known event procedures

Below are some event procedures which have been found to be interesting or useful. Note that the existence, behavior and arguments expected are known to vary between camera models. When if something varies from the descriptions below for your camera, please note it.

see also Canon_Basic/Reference

Registration functions

Many event procedures are not registered by default. The following are known. Unless otherwise specified, they take no arguments and return 0 on completion.

Several of the registration functions have more than one possible name.

Early (most vxworks) cameras used the letters+underscores form. The Foo.Bar form was introduced on late vxworks or early dryos cameras, with the earlier form retained for compatibility. In newer cameras (dryos rel 43) the earlier form appears to have been dropped [1].

SystemEventInit/System.Create

registers AllocateMemory, FreeMemory, sprintf, memcpy, Fut functions, log ...

UI_RegistDebugEventProc/UI.Create

registers capture mode functions, PTM_ functions and much more

RegisterProductTestEvent/SS.Create

registers PT_ functions, and enables the PT_* hooks

Note: present on vxworks + digic II (A540) missing on dryos + digic III / digic 4 (A470,SD990).

RegisterShootSeqEvent

RegisterNRTableEvent

Note: Many of the *.Create functions only exist on newer cameras (dryos ?), while the alternate name appears to exist on both newer and older models.