Pixeldoc2000 (talk | contribs) m (added Color info to LCDMsg_ChangeColor) |
Pixeldoc2000 (talk | contribs) m (Printf updated) |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
=Canon Basic Reference= |
=Canon Basic Reference= |
||
+ | |||
+ | {{notice|Canon Basic Functions are basicly [[Event Procedure]] with slightly different syntax.}} |
||
+ | |||
Canons firmware includes a scripting language, which appears to be a flavor of basic. Thanks to recent work by Alfredo Ortega and Oren Isacson of [http://corelabs.coresecurity.com/ core labs], it is now known how to execute scripts in this language. They have made available their [http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=publication&name=Exploiting_Digital_Cameras defcon presentation] and [http://corelabs.coresecurity.com/index.php?module=Wiki&action=attachment&type=publication&page=Exploiting_Digital_Cameras&file=Exploiting_Digital_Cameras_IOBasic_-_BONUS.pdf some preliminary documentation], read more in this {{tagb|→}}[http://chdk.setepontos.com/index.php/topic,5549.0.html forum thread]. |
Canons firmware includes a scripting language, which appears to be a flavor of basic. Thanks to recent work by Alfredo Ortega and Oren Isacson of [http://corelabs.coresecurity.com/ core labs], it is now known how to execute scripts in this language. They have made available their [http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=publication&name=Exploiting_Digital_Cameras defcon presentation] and [http://corelabs.coresecurity.com/index.php?module=Wiki&action=attachment&type=publication&page=Exploiting_Digital_Cameras&file=Exploiting_Digital_Cameras_IOBasic_-_BONUS.pdf some preliminary documentation], read more in this {{tagb|→}}[http://chdk.setepontos.com/index.php/topic,5549.0.html forum thread]. |
||
+ | |||
+ | ==SystemEventInit== |
||
+ | Newest cams (DryOS rel 43 and later) only have System.Create(), on older dryos cams SystemEventInit() is an alias for System.Create(). Old cameras (mostly VxWorks) have only SystemEventInit. The following should work on all known cameras |
||
+ | |||
+ | <source lang="thinbasic"> |
||
+ | if System.Create() = -1 then |
||
+ | SystemEventInit() |
||
+ | end if |
||
+ | </source> |
||
==LCDMsg== |
==LCDMsg== |
||
The LCDMsg system is not available on older cameras. |
The LCDMsg system is not available on older cameras. |
||
+ | Call UI.CreatePublic() first to register LCDMsg_* functions: |
||
− | You need to call this first: |
||
UI.CreatePublic() |
UI.CreatePublic() |
||
+ | ===LCDMsg_Create=== |
||
− | + | Create "handle" for your LCD Message: |
|
a=LCDMsg_Create() |
a=LCDMsg_Create() |
||
Line 14: | Line 27: | ||
LCDMsg_SetStr(a,"Hello World") |
LCDMsg_SetStr(a,"Hello World") |
||
LCDMsg_SetStr(HANDLE, STRING) |
LCDMsg_SetStr(HANDLE, STRING) |
||
+ | |||
+ | Note: STRING is limited to 32 Characters. If function is called for example with 37 chars it will return: |
||
+ | warning: (Length > 32 length = 37) or (>SetStr " strings ") |
||
===LCDMsg_SetNum=== |
===LCDMsg_SetNum=== |
||
Line 25: | Line 41: | ||
|+ |
|+ |
||
|Number |
|Number |
||
− | |Color [[SD4000]] |
+ | |Color [[SD4000]] / [[SD940]] |
|Color [[A720]] |
|Color [[A720]] |
||
|- |
|- |
||
Line 95: | Line 111: | ||
Color depends on Canon Firmware Palette. |
Color depends on Canon Firmware Palette. |
||
− | Cameras have different Color Palettes defines as CAM_BITMAP_PALETTE in camera.h . |
+ | Cameras have different Color Palettes defines as CAM_BITMAP_PALETTE in camera.h used by CHDK GUI. |
===LCDMsg_Move=== |
===LCDMsg_Move=== |
||
LCDMsg_Move(a, 10, 10) |
LCDMsg_Move(a, 10, 10) |
||
LCDMsg_Move(HANDLE, LEFT, TOP) |
LCDMsg_Move(HANDLE, LEFT, TOP) |
||
+ | ==Wait== |
||
+ | |||
+ | Call ''System.Create()'' to register ''Wait()'' function: |
||
+ | |||
+ | if System.Create() = -1 then |
||
+ | SystemEventInit() |
||
+ | end if |
||
+ | |||
+ | Wait(5000) |
||
+ | |||
+ | Wait(DELAY_IN_MS) |
||
+ | |||
+ | ==Printf== |
||
+ | Output string to Camera Console (UART). |
||
+ | Printf("Script Foo started") |
||
+ | Printf(STRING) |
||
+ | |||
+ | Note: STRING is limited to 32 Characters. If String is longer with 32 chars it will return: |
||
+ | The string parameter is longer than 32char |
||
+ | Else function returns String lenght. |
||
+ | |||
+ | ==Console redirection StartRedirectUART/StopRedirectUART== |
||
+ | On DryOS cameras, the camera console output can be redirected to a file. See [[Debugging#UART_redirection_.28DryOS.29]] |
||
[[Category:Development]] |
[[Category:Development]] |
||
[[Category:CanonBasic]] |
[[Category:CanonBasic]] |
||
[[Category:Scripts]] |
[[Category:Scripts]] |
||
+ | [[Category:EventProcedure]] |
||
+ | [[Category:DryOS]] |
Latest revision as of 22:58, 11 February 2011
Canon Basic Reference
Canon Basic Functions are basicly Event Procedure with slightly different syntax. |
Canons firmware includes a scripting language, which appears to be a flavor of basic. Thanks to recent work by Alfredo Ortega and Oren Isacson of core labs, it is now known how to execute scripts in this language. They have made available their defcon presentation and some preliminary documentation, read more in this →forum thread.
SystemEventInit
Newest cams (DryOS rel 43 and later) only have System.Create(), on older dryos cams SystemEventInit() is an alias for System.Create(). Old cameras (mostly VxWorks) have only SystemEventInit. The following should work on all known cameras
if System.Create() = -1 then
SystemEventInit()
end if
LCDMsg
The LCDMsg system is not available on older cameras.
Call UI.CreatePublic() first to register LCDMsg_* functions:
UI.CreatePublic()
LCDMsg_Create
Create "handle" for your LCD Message:
a=LCDMsg_Create()
When a message is first created and no text has been set, the string "FAILED" is displayed. This may also be displayed when an invalid argument is given to an LCDMsg function.
LCDMsg_SetStr
LCDMsg_SetStr(a,"Hello World")
LCDMsg_SetStr(HANDLE, STRING)
Note: STRING is limited to 32 Characters. If function is called for example with 37 chars it will return:
warning: (Length > 32 length = 37) or (>SetStr " strings ")
LCDMsg_SetNum
LCDMsg_SetNum(a,999)
LCDMsg_SetNum(HANDLE, INTEGER)
LCDMsg_ChangeColor
LCDMsg_ChangeColor(a,3)
LCDMsg_ChangeColor(HANDLE, COLOR)
Number | Color SD4000 / SD940 | Color A720 |
0 | Black | n/a |
1 | Black | White |
2 | Orange | Red |
3 | White | Bright Grey |
4 | Grey | Dark Grey |
5 | Bright Orange | Green |
6 | Orange | Yellow |
7 | Bright Grey | |
8 | Orange | |
9 | Bright Blue | |
10 | Blue | |
11 | Bright Grey | |
12 | Dark Blue | |
13 | Dark Grey | |
14 | Bright Grey | |
15 | Black |
Color depends on Canon Firmware Palette.
Cameras have different Color Palettes defines as CAM_BITMAP_PALETTE in camera.h used by CHDK GUI.
LCDMsg_Move
LCDMsg_Move(a, 10, 10)
LCDMsg_Move(HANDLE, LEFT, TOP)
Wait
Call System.Create() to register Wait() function:
if System.Create() = -1 then SystemEventInit() end if
Wait(5000)
Wait(DELAY_IN_MS)
Printf
Output string to Camera Console (UART).
Printf("Script Foo started")
Printf(STRING)
Note: STRING is limited to 32 Characters. If String is longer with 32 chars it will return:
The string parameter is longer than 32char
Else function returns String lenght.
Console redirection StartRedirectUART/StopRedirectUART
On DryOS cameras, the camera console output can be redirected to a file. See Debugging#UART_redirection_.28DryOS.29