Executing Event Procedures by name - page 4 - General Discussion and Assistance - CHDK Forum supplierdeeply

Executing Event Procedures by name

  • 43 Replies
  • 27877 Views
*

Offline whim

  • ******
  • 2046
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: Executing Event Procedures by name
« Reply #30 on: 26 / December / 2009, 12:48:39 »
Advertisements
Quote
...Event Procedures...

AKA Adventure Procedures  ;)

wim

PS re "irresistable":
Quote
(wikipedia).. its odor is best described as pig-sh*t, turpentine and onions, garnished with a gym sock
« Last Edit: 26 / December / 2009, 12:54:53 by whim »

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Executing Event Procedures by name
« Reply #31 on: 26 / December / 2009, 12:58:15 »
I wanted to see what factory mode looked like.

I did this long time ago using non-destructive way:

a710: task_Startup()->sub_FFD95D74:

ROM:FFD95D74                 STMFD   SP!, {R4,LR}    ; Store Block to Memory
ROM:FFD95D78                 BL      sub_FFD77A8C    ; Branch with Link
ROM:FFD95D7C                 BL      IsFactoryMode   ; Branch with Link
ROM:FFD95D80                 CMP     R0, #1          ; Set cond. codes on Op1 - Op2
ROM:FFD95D84                 LDR     R4, =0x6C58     ; Load from Memory
ROM:FFD95D88                 BNE     loc_FFD95D98    ; Branch
ROM:FFD95D8C                 BL      sub_FFD9934C    ; Branch with Link
ROM:FFD95D90                 LDMFD   SP!, {R4,LR}    ; Load Block from Memory
ROM:FFD95D94                 B       StartFactoryModeController ; Branch
....

On a710 factory mode looks like reyalp says: black screen, some LEDs if on, "DCP connect" etc.
« Last Edit: 26 / December / 2009, 13:00:23 by ewavr »

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Executing Event Procedures by name
« Reply #32 on: 26 / December / 2009, 13:11:13 »
*EDIT: did you check the SD card ? maybe there are some log files, like DC97/MISC/CANON/FACTORY/RSTFNO
Warning: create this folder on own risk!
One guy from russian CHDK forum reported that creating folder with this name on card can reset file numbering in camera (a75 - digic1).
He also says (but he was not sure about this) that after this picture quality from camera decreases (not confirmed!).

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Executing Event Procedures by name
« Reply #33 on: 26 / December / 2009, 13:24:26 »
Alas, let's wait till ewavr bricks his ;)
Ad calendas graecas  :haha.


*

Online reyalp

  • ******
  • 14117
Re: Executing Event Procedures by name
« Reply #34 on: 26 / December / 2009, 16:50:27 »
Here's what lsusb -v -s [bus:dev] gave in factory mode. If I've understood the libusb "single" driver correctly, one could use it to act as a driver to talk to the camera in this mode, without actually writing a usb driver. Might be interesting if someone wants to dig through what the code does on the other end. I would guess that there's a fairly simple protocol for the terminal stuff.

*EDIT: did you check the SD card ? maybe there are some log files, like DC97/MISC/CANON/FACTORY/RSTFNO
No, it didn't create anything on the card by itself.
Don't forget what the H stands for.

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Executing Event Procedures by name
« Reply #35 on: 13 / January / 2010, 06:40:31 »
It is possiible to use pointers in Lua to call event procedures?
For example, EF.StartInternalPreFlash() requires pointer to structure as argument.

*

Online reyalp

  • ******
  • 14117
Re: Executing Event Procedures by name
« Reply #36 on: 15 / January / 2010, 03:47:52 »
It is possiible to use pointers in Lua to call event procedures?
For example, EF.StartInternalPreFlash() requires pointer to structure as argument.
Yes. Use AllocateMemory and peek/poke. TSTCALLF.LUA in CHDK\SCRIPTS\TEST uses this to get a buffer for sprintf. It also writes machine code to the buffer and runs it :D

You need to call "SystemEventInit" first to get AllocateMemory.
Don't forget what the H stands for.

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Executing Event Procedures by name
« Reply #37 on: 16 / January / 2010, 19:12:27 »
Use AllocateMemory and peek/poke.
Thanks.
I don't understand why, but EF.StartInternalFlash works without any pointers, for example call_event_proc("EF.StartInternalPreFlash", 1,10,0) ::).

So, my final mighty script:
Code: (lua) [Select]
call_event_proc("Capture.Create")
call_event_proc("EF.StartEFCharge")
while call_event_proc("EF.IsChargeFull")==0 do sleep(10) end
call_event_proc("EF.StopEFCharge")
call_event_proc("EF.StartInternalPreFlash", 1,10,0)
call_event_proc("EF.StartInternalPreFlash", 1,20,0)
call_event_proc("EF.StartInternalPreFlash", 1,30,0)


*

Online reyalp

  • ******
  • 14117
Re: Executing Event Procedures by name
« Reply #38 on: 30 / May / 2010, 04:34:03 »
Thanks.
I don't understand why, but EF.StartInternalFlash works without any pointers, for example call_event_proc("EF.StartInternalPreFlash", 1,10,0) ::).
I think understand this now.

There are different functions to register event procs, and ExecuteEventProcedure treats the arguments differently depending on that. So for example, if you look at asm for GetLogToFile, it takes one argument that is a pointer to a struct with a string and number. But if you use ExecuteEventProcedure to call it, it expects the string as the first argument. If you pass a pointer to the proper struct, it fails.

I've verified this by calling the function directly (with "call_func_ptr") vs. calling it with call_event_proc.  In the first way, I have to make the proper structure with malloc and poke, and in the second, I can just pass the string and number as arguments.

FWIW, this function is registered with what the IDA sigs call RegisterEventProcedure_im1
Don't forget what the H stands for.

Re: Executing Event Procedures by name
« Reply #39 on: 30 / May / 2010, 05:36:10 »
FWIW, this function is registered with what the IDA sigs call RegisterEventProcedure_im1

With the CHDK disassembly, especially the very first versions, where do the function names come from .. how were they worked-out ?


 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal