_set_control_event() - General Discussion and Assistance - CHDK Forum

_set_control_event()

  • 5 Replies
  • 2104 Views
_set_control_event()
« on: 24 / July / 2011, 17:02:56 »
Advertisements
In CHKDE changeset 470 and CHDK changeset 1023, _set_control_event() is used to simulate connecting and disconnecting the USB cable.

Code: [Select]
    if ( mode == 0 ) {
        _Rec2PB();
        _set_control_event(0x80000902); // 0x10A5 ConnectUSBCable
    } else if ( mode == 1 ) {
        _set_control_event(0x902); // 0x10A6 DisconnectUSBCable
        _PB2Rec();

I want to see if the same works for the A/V cable.

I vaguely remember 0x10A5 ond 0x10A6 from early mode dial discussions but cannot find the required information for DRYOS in the disassembly.

0x80000902 and 902 are also vaguely familiar.

Can you remind me where this was discussed ?


*

Offline funnel

  • ****
  • 349
Re: _set_control_event()
« Reply #1 on: 24 / July / 2011, 17:22:34 »
I was looking for some stuff a few days ago and I found this page http://www.mweerden.net/chdk_ptp.html . Under Appendix he is discussing something about this.

Re: _set_control_event()
« Reply #2 on: 25 / July / 2011, 07:43:28 »
Thanks, that is where I must have seen it previously.

I still don't follow how mweerden arrived at those magic numbers or how I can do a similar thing for ConnectVideoCable.

*

Offline philmoz

  • *****
  • 3411
    • Photos
Re: _set_control_event()
« Reply #3 on: 25 / July / 2011, 08:23:02 »
Thanks, that is where I must have seen it previously.

I still don't follow how mweerden arrived at those magic numbers or how I can do a similar thing for ConnectVideoCable.

You need to work through the convoluted logic in the firmware.
There are functions that convert the control events to logical events and vice-versa.

Based on the G12 firmware:
Name                        Logical Event        Control Event
ConnectVideoCable     0x10A1                0x80000900
DisconnectVideoCable 0x10A2                0x900

No idea if these will work the same as the USBCable events; but it can't hurt to try.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)


Re: _set_control_event()
« Reply #4 on: 25 / July / 2011, 13:51:59 »
There are functions that convert the control events to logical events and vice-versa.


Thanks Phil, never knew that.
Must admit that I did not follow the disassembly trail very far.
That should keep me occupied.

Will report back.


David

*

Offline funnel

  • ****
  • 349
Re: _set_control_event()
« Reply #5 on: 05 / August / 2011, 11:05:56 »
By searching through the firmware I accidentally found the function that translates this numbers.

I use this simple lua script to translate it
Code: [Select]
result=call_func_ptr(0xFF1B0F18,0x10a5)
print(string.format("0x%x", result))

The function can be found here
Code: [Select]
FF08F414                 ADR     R1, aLogicalevent0x04xAdrPParaLd ; "LogicalEvent:0x%04x:adr:%p,Para:%ld"
FF08F418                 MOV     R0, #0x60
FF08F41C                 BL      _sub_FF087AC8__CameraLog_c__237 ; LOCATION: CameraLog.c:237
FF08F420                 MOV     R0, R5
FF08F424                 BL      sub_FF08F03C
FF08F428                 CMP     R0, #0
FF08F42C                 BEQ     loc_FF08F444
FF08F430                 MOV     R0, R5
FF08F434                 BL      sub_FF1B0F18     <-----------------------
FF08F438                 MOV     R1, R4
FF08F43C                 BL      sub_FF0913E4

Maybe useful for somebody.
« Last Edit: 05 / August / 2011, 11:07:44 by funnel »