CHDK Wiki
Register
m (correct LUA->Lua)
(12 intermediate revisions by 4 users not shown)
Line 2: Line 2:
 
|__TOC__
 
|__TOC__
 
|}
 
|}
  +
{{notice|Look [[Canon Basic/Reference]] for details about syntax.}}
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
 
  +
 
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=
 
=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.
 
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 procedures are available from [[Canon Basic]].
   
 
=Event Procedure API functions=
 
=Event Procedure API functions=
Line 19: Line 21:
   
 
=Lua interface=
 
=Lua interface=
Event procedures may be called from lua using the [[LUA/LUA Reference/Native Function Calls]] interface.
+
Event procedures may be called from lua using the [[Lua/Lua Reference/Native Function Calls]] interface.
   
 
=Event Procedures as hooks=
 
=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
 
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
  +
  +
=UART=
  +
Event procedures are directly useable in [[Event Shell]] which is available via [[UART]] serial connection with Camera.
   
 
=Known event procedures=
 
=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.
+
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.
  +
  +
A list of event procedures identified on [[A540]] can be found at [[User:ReyalP/EventProcNotes]]
   
 
see also [[Canon_Basic/Reference]]
 
see also [[Canon_Basic/Reference]]
  +
  +
==Basic Functions==
  +
  +
These Functions are always available (DryOS)
  +
*Log functions
  +
**ShowCameraLog
  +
**ShowCameraLogInfo
  +
**StartCameraLog<br />StartCameraLog CameraLogLevel CameraLogBufferSize<br />Example: StartCameraLog 0x20 0x1000
  +
**StopCameraLog
  +
**PutsCameraLogEvent
  +
*StartRedirectUART, StopRedirectUART
  +
  +
*drysh<br />Start [[DryOS Shell]]
   
 
==Registration functions==
 
==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.
 
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.
+
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 [http://chdk.setepontos.com/index.php/topic,5295.msg55463.html#msg55463].
 
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 [http://chdk.setepontos.com/index.php/topic,5295.msg55463.html#msg55463].
   
 
'''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.
===SystemEventInit/System.Create===
 
  +
registers AllocateMemory, FreeMemory, sprintf, memcpy, Fut functions, log ...
 
 
===SystemEventInit / System.Create===
  +
Basic System Functions
  +
Registers following Functions:
  +
  +
*sprintf, Printf, CPrintf, CPutChar
  +
*Memory functions (memcpy, memset, memShow, AllocateMemory, FreeMemory)
  +
*Open, Close, Read, Write, Lseek
  +
*Fut functions (Fopen_Fut, Fclose_Fut, Fread_Fut, Fwrite_Fut, Fseek_Fut)
  +
*Task functions (CreateTask, SleepTask, ExitTask, ShowAllTaskInfo)
  +
*String functions (strlen, strcmp, atol)
  +
*GetLogToFile
  +
*GetBuildTime, GetBuildDate
  +
*GetFirmwareVersion
  +
*GetSystemTime, GetTimeOfSystem
  +
*MakeBootDisk, MakeScriptDisk
  +
*ExecuteEventProcedure
  +
*Peek8, Peek16, Peek32
  +
*Poke8, Poke16, Poke32
  +
*Dump, Dump32, SDump
  +
*Wait
  +
*StartWDT, StopWDT
  +
*exec
  +
*LoadScript, UnLoadScript, OpenForScrip
  +
*OpenConsole, CloseConsole
  +
*TakeSemaphore, DeleteSemaphore, GiveSemaphore, CreateCountingSemaphore
  +
*MonSelEvent, CreateProxyOfEventProcedure, ExportToEventProcedure
  +
*StartWDT
  +
*VerifyByte, CheckSumAll, EraseSignature, RomCheckSum
  +
*WriteToRom, EraseSectorOfRom
  +
*EraseLogSector
  +
*AdditionAgentRAM
  +
*MemoryChecker
  +
*TurnOffE1
  +
*sscanf
  +
  +
*...
  +
 
===UI_RegistDebugEventProc / UI.Create===
  +
Registers following Functions:
  +
  +
*capture mode functions
  +
**ModeDialToMovie<br />switch to Movie Record Mode
  +
**Still Image Record Mode
  +
***ModeDialToAuto
  +
***ModeDialToPortrait
  +
***ModeDialToKidsAndPets
  +
***...
  +
  +
*PTM_* functions
  +
  +
*UIFS
  +
**UIFS_Capture<br />start Capture in activ Record (Capture) Mode or switch to Record Mode from Playback
  +
**UIFS_SetDialStillRec<br />switch to Still Image Record (Capture) Mode
  +
**UIFS_CaptureNoneStop<br />switch to Still Image Record Mode in Continues Mode with Custom Timer
  +
**UIFS_SetDialPlay<br />switch to Playback Mode (not under all conditions ?)
  +
**UIFS_SetDialMovieRec
  +
**UIFS_StartMovieRecord, UIFS_StopMovieRecord, UIFS_GetMovieRecoadableNumber
  +
**UIFS_PostModeDial
  +
**UIFS_SetCaptureModeToP
  +
**UIFS_ChangeShootState
  +
**UIFS_GetStillShotableNumber
  +
**UIFS_IsAvailableShots
  +
**UIFS_GetAvItem, UIFS_IsAvailableAvTvMode, UIFS_GetAvItemCount, UIFS_GetCurrentAvString
  +
**UIFS_GetTvItem, UIFS_GetCurrentTvString, UIFS_GetTvItemCount
  +
**UIFS_IsAvailableMovieRecOptZoom, UIFS_IsAvailableMovieRecDigZoom
  +
**UIFS_SetCradleSetting
  +
**UIFS_ShootSeqToUI
  +
**UIFS_MoveZoomTo<br />set Optical Zoom Step as Number (depends on how much Zoom Steps Camera has)<br />[[SD4000]]: 0-63 (Optical)
  +
**UIFS_OpenPopupStrobe, UIFS_ClosePopupStrobe, UIFS_IsAutoPopupDownStrobe, UIFS_MountExtFlash, UIFS_UnmountExtFlash
  +
**UIFS_WriteFirmInfoToFile
  +
**UIFS_StartClockMode, UIFS_EndClockMode<br />show Fullscreen Clock
  +
**UIFS_ConnectVideo
  +
**UIFS_GetLastPath
  +
**UIFS_StopPostingUIEvent, UIFS_RestartPostingUIEvent
  +
**UIFS_IsAvailableServoAF
  +
**UIFS_DisconnectVideo
  +
  +
*Button press functions
   
  +
*...
===UI_RegistDebugEventProc/UI.Create===
 
registers capture mode functions, PTM_ functions and much more
 
   
===RegisterProductTestEvent/SS.Create===
+
===RegisterProductTestEvent / SS.Create===
 
registers PT_ functions, and enables the PT_* hooks
 
registers PT_ functions, and enables the PT_* hooks
   
 
Note: present on vxworks + digic II ([[A540]]) missing on dryos + digic III / digic 4 ([[A470]],[[SD990]]).
 
Note: present on vxworks + digic II ([[A540]]) missing on dryos + digic III / digic 4 ([[A470]],[[SD990]]).
  +
  +
===EngineDriver.Create===
  +
Registers following Functions:
  +
*EngDrvOut
  +
*EngDrvIn
  +
*EngDrvRead
  +
*EngDrvReadDump
  +
*EngDrvBits
  +
*Driver_EnableEventProc
  +
  +
===Mecha.Create===
  +
"Mechnical" related Functions
  +
Registers following Functions:
  +
*IsLensOutside
  +
*DisableFocusLens
  +
*MoveFocusLensWithPosition
  +
*GetMechaShutterStatus
  +
*GetLensErrorStatus
  +
*MechaTerminate
  +
*GetIrisAv
  +
*TurnOnNdFilter
  +
*...
  +
  +
===Capture.Create===
  +
Registers following Functions:
  +
*EF.*
  +
*ExecuteDefectRec
  +
*CrossDefDetect
  +
*CancelImager
  +
*ExecuteDefectRecAndSaveImage
  +
*SetDefectRecParam
  +
*QuietImager
  +
*ChangeGradeTable
  +
*ChangeImagerToDigiconMode
  +
*ChangeImagerToJetDraft
  +
*...
  +
  +
===DispDev.Create===
  +
Display related Functions
  +
  +
Registers following Functions:
  +
*DispDev_*
  +
*DispCon_*
  +
*LcdCon_*
  +
*...
  +
  +
===OpLog.Create===
  +
Registers following Functions:
  +
*OpLog.Start
  +
*OpLog.Stop
  +
*OpLog.Play
  +
*OpLog.Get
  +
*OpLog.ReadFromROM
  +
*OpLog.WriteToROM
  +
*OpLog.ReadFromSD
  +
*OpLog.WriteToSD
  +
  +
===Driver.Create===
  +
Registers following Functions:
  +
*ShowPhySwStatus
  +
*OnPrintPhySw
  +
*GetSwitchStatus
  +
*LEDDrive
  +
*GetSDDetect
  +
*SetSDPwrPort
  +
*i2c_write_event
  +
*ChangePowerState
  +
*...
  +
  +
===EngApp.Create===
  +
Registers following Functions:
  +
*EngApp.Delete
  +
*Scene.TestSunset
  +
*Scene.ForbidContiSceneDetect
  +
===ExMem===
  +
Registers following Functions:
  +
*ExMem.View
  +
*ExMem.AllocCacheable
  +
*ExMem.FreeCacheable
  +
*ExMem.AllocUncacheable
  +
*ExMem.FreeUncacheable
  +
  +
===FA.Create===
  +
FactoryMode / Debug / Log related Functions
  +
Registers following Functions:
  +
*GetCurrentMaximumLogSize<br />GetCurrentMaximumLogSize returned 4096(0x1000)
  +
*GetLogData, GetLogDataOnlyAddMemory
  +
*EnableDebugLogMode, DisableDebugLogMode
  +
*PrintFirmVersion
  +
*IsLogOutType
  +
*IsNormalCameraMode
  +
*FADBGPrintf, FADBGSingal
  +
*InitializeAdjustmentSystem, ActivateAdjLog, PrintAdjTableMap, ShowDefaultAdjTableVersion, DumpAdjMirror, LoadParamDataFromAdjTableBin
  +
*AddTransparentMemory, RemoveTransparentMemory, DumpTransparentMemoryItem, AttachToTransparentMemory, ShowTransparentMemory, GetTransparentMemoryPosition
  +
*InitializeSoundRec, StartSoundPlay, FreeBufferForSoundRec, StartSoundRecord
  +
*ExecuteTestRec, ExecuteTestRecSw1
  +
*Factory Mode
  +
**SetFactoryMode<br />Note: Set FactoryMode Flag in ROM. Camera will start in FactoryMode on Boot. In FactoryMode Camera does not show anything on Display and all Leds are off. To exit FactoryMode execute ClearFactoryMode and restart Camera.
  +
**ClearFactoryMode<br />Clears FactoryMode Flag in ROM. Camera will start in Normal Mode on next Boot.
  +
**StartFactoryModeController
  +
**DisplayFactoryMode
  +
**UndisplayFactoryMode
  +
*SetDefaultRecParameter
  +
*InitializeDigicon, ExecuteDigicon, TerminateDigicon
  +
*DeviceUniqueIDCheckSum
  +
*RefreshDefectTableMirrorSetDurianMode
  +
*SetDurianMode, ClearDurianMode
  +
*GetdccdFilterValue
  +
*WRITEADJTABLETOFROM
  +
*...
  +
 
===RegisterShootSeqEvent===
 
===RegisterShootSeqEvent===
  +
Probably VxWorks only. Not available on [[SD4000]].
  +
 
===RegisterNRTableEvent===
 
===RegisterNRTableEvent===
  +
Probably VxWorks only. Not available on [[SD4000]].
   
  +
See also: [http://magiclantern.wikia.com/wiki/IDAPython/Tracing_calls/register_func IDAPython/Tracing_calls/register_func].
'''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.
 
 
[[Category:Development]]
 
[[Category:Development]]
 
[[Category:CHDK internals]]
 
[[Category:CHDK internals]]
 
[[Category:CanonBasic]]
 
[[Category:CanonBasic]]
  +
[[Category:EventProcedure]]

Revision as of 02:04, 21 January 2012

Notice

Look Canon Basic/Reference for details about syntax.


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

UART

Event procedures are directly useable in Event Shell which is available via UART serial connection with Camera.

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.

A list of event procedures identified on A540 can be found at User:ReyalP/EventProcNotes

see also Canon_Basic/Reference

Basic Functions

These Functions are always available (DryOS)

  • Log functions
    • ShowCameraLog
    • ShowCameraLogInfo
    • StartCameraLog
      StartCameraLog CameraLogLevel CameraLogBufferSize
      Example: StartCameraLog 0x20 0x1000
    • StopCameraLog
    • PutsCameraLogEvent
  • StartRedirectUART, StopRedirectUART

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].

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.

SystemEventInit / System.Create

Basic System Functions Registers following Functions:

  • sprintf, Printf, CPrintf, CPutChar
  • Memory functions (memcpy, memset, memShow, AllocateMemory, FreeMemory)
  • Open, Close, Read, Write, Lseek
  • Fut functions (Fopen_Fut, Fclose_Fut, Fread_Fut, Fwrite_Fut, Fseek_Fut)
  • Task functions (CreateTask, SleepTask, ExitTask, ShowAllTaskInfo)
  • String functions (strlen, strcmp, atol)
  • GetLogToFile
  • GetBuildTime, GetBuildDate
  • GetFirmwareVersion
  • GetSystemTime, GetTimeOfSystem
  • MakeBootDisk, MakeScriptDisk
  • ExecuteEventProcedure
  • Peek8, Peek16, Peek32
  • Poke8, Poke16, Poke32
  • Dump, Dump32, SDump
  • Wait
  • StartWDT, StopWDT
  • exec
  • LoadScript, UnLoadScript, OpenForScrip
  • OpenConsole, CloseConsole
  • TakeSemaphore, DeleteSemaphore, GiveSemaphore, CreateCountingSemaphore
  • MonSelEvent, CreateProxyOfEventProcedure, ExportToEventProcedure
  • StartWDT
  • VerifyByte, CheckSumAll, EraseSignature, RomCheckSum
  • WriteToRom, EraseSectorOfRom
  • EraseLogSector
  • AdditionAgentRAM
  • MemoryChecker
  • TurnOffE1
  • sscanf
  • ...

UI_RegistDebugEventProc / UI.Create

Registers following Functions:

  • capture mode functions
    • ModeDialToMovie
      switch to Movie Record Mode
    • Still Image Record Mode
      • ModeDialToAuto
      • ModeDialToPortrait
      • ModeDialToKidsAndPets
      • ...
  • PTM_* functions
  • UIFS
    • UIFS_Capture
      start Capture in activ Record (Capture) Mode or switch to Record Mode from Playback
    • UIFS_SetDialStillRec
      switch to Still Image Record (Capture) Mode
    • UIFS_CaptureNoneStop
      switch to Still Image Record Mode in Continues Mode with Custom Timer
    • UIFS_SetDialPlay
      switch to Playback Mode (not under all conditions ?)
    • UIFS_SetDialMovieRec
    • UIFS_StartMovieRecord, UIFS_StopMovieRecord, UIFS_GetMovieRecoadableNumber
    • UIFS_PostModeDial
    • UIFS_SetCaptureModeToP
    • UIFS_ChangeShootState
    • UIFS_GetStillShotableNumber
    • UIFS_IsAvailableShots
    • UIFS_GetAvItem, UIFS_IsAvailableAvTvMode, UIFS_GetAvItemCount, UIFS_GetCurrentAvString
    • UIFS_GetTvItem, UIFS_GetCurrentTvString, UIFS_GetTvItemCount
    • UIFS_IsAvailableMovieRecOptZoom, UIFS_IsAvailableMovieRecDigZoom
    • UIFS_SetCradleSetting
    • UIFS_ShootSeqToUI
    • UIFS_MoveZoomTo
      set Optical Zoom Step as Number (depends on how much Zoom Steps Camera has)
      SD4000: 0-63 (Optical)
    • UIFS_OpenPopupStrobe, UIFS_ClosePopupStrobe, UIFS_IsAutoPopupDownStrobe, UIFS_MountExtFlash, UIFS_UnmountExtFlash
    • UIFS_WriteFirmInfoToFile
    • UIFS_StartClockMode, UIFS_EndClockMode
      show Fullscreen Clock
    • UIFS_ConnectVideo
    • UIFS_GetLastPath
    • UIFS_StopPostingUIEvent, UIFS_RestartPostingUIEvent
    • UIFS_IsAvailableServoAF
    • UIFS_DisconnectVideo
  • Button press functions
  • ...

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).

EngineDriver.Create

Registers following Functions:

  • EngDrvOut
  • EngDrvIn
  • EngDrvRead
  • EngDrvReadDump
  • EngDrvBits
  • Driver_EnableEventProc

Mecha.Create

"Mechnical" related Functions Registers following Functions:

  • IsLensOutside
  • DisableFocusLens
  • MoveFocusLensWithPosition
  • GetMechaShutterStatus
  • GetLensErrorStatus
  • MechaTerminate
  • GetIrisAv
  • TurnOnNdFilter
  • ...

Capture.Create

Registers following Functions:

  • EF.*
  • ExecuteDefectRec
  • CrossDefDetect
  • CancelImager
  • ExecuteDefectRecAndSaveImage
  • SetDefectRecParam
  • QuietImager
  • ChangeGradeTable
  • ChangeImagerToDigiconMode
  • ChangeImagerToJetDraft
  • ...

DispDev.Create

Display related Functions

Registers following Functions:

  • DispDev_*
  • DispCon_*
  • LcdCon_*
  • ...

OpLog.Create

Registers following Functions:

  • OpLog.Start
  • OpLog.Stop
  • OpLog.Play
  • OpLog.Get
  • OpLog.ReadFromROM
  • OpLog.WriteToROM
  • OpLog.ReadFromSD
  • OpLog.WriteToSD

Driver.Create

Registers following Functions:

  • ShowPhySwStatus
  • OnPrintPhySw
  • GetSwitchStatus
  • LEDDrive
  • GetSDDetect
  • SetSDPwrPort
  • i2c_write_event
  • ChangePowerState
  • ...

EngApp.Create

Registers following Functions:

  • EngApp.Delete
  • Scene.TestSunset
  • Scene.ForbidContiSceneDetect

ExMem

Registers following Functions:

  • ExMem.View
  • ExMem.AllocCacheable
  • ExMem.FreeCacheable
  • ExMem.AllocUncacheable
  • ExMem.FreeUncacheable

FA.Create

FactoryMode / Debug / Log related Functions Registers following Functions:

  • GetCurrentMaximumLogSize
    GetCurrentMaximumLogSize returned 4096(0x1000)
  • GetLogData, GetLogDataOnlyAddMemory
  • EnableDebugLogMode, DisableDebugLogMode
  • PrintFirmVersion
  • IsLogOutType
  • IsNormalCameraMode
  • FADBGPrintf, FADBGSingal
  • InitializeAdjustmentSystem, ActivateAdjLog, PrintAdjTableMap, ShowDefaultAdjTableVersion, DumpAdjMirror, LoadParamDataFromAdjTableBin
  • AddTransparentMemory, RemoveTransparentMemory, DumpTransparentMemoryItem, AttachToTransparentMemory, ShowTransparentMemory, GetTransparentMemoryPosition
  • InitializeSoundRec, StartSoundPlay, FreeBufferForSoundRec, StartSoundRecord
  • ExecuteTestRec, ExecuteTestRecSw1
  • Factory Mode
    • SetFactoryMode
      Note: Set FactoryMode Flag in ROM. Camera will start in FactoryMode on Boot. In FactoryMode Camera does not show anything on Display and all Leds are off. To exit FactoryMode execute ClearFactoryMode and restart Camera.
    • ClearFactoryMode
      Clears FactoryMode Flag in ROM. Camera will start in Normal Mode on next Boot.
    • StartFactoryModeController
    • DisplayFactoryMode
    • UndisplayFactoryMode
  • SetDefaultRecParameter
  • InitializeDigicon, ExecuteDigicon, TerminateDigicon
  • DeviceUniqueIDCheckSum
  • RefreshDefectTableMirrorSetDurianMode
  • SetDurianMode, ClearDurianMode
  • GetdccdFilterValue
  • WRITEADJTABLETOFROM
  • ...

RegisterShootSeqEvent

Probably VxWorks only. Not available on SD4000.

RegisterNRTableEvent

Probably VxWorks only. Not available on SD4000.

See also: IDAPython/Tracing_calls/register_func.