shooting script using Canon basic ? - page 5 - General Discussion and Assistance - CHDK Forum

shooting script using Canon basic ?

  • 51 Replies
  • 21303 Views
*

Offline srsa_4c

  • ******
  • 3814
Re: shooting script using Canon basic ?
« Reply #40 on: 19 / November / 2018, 16:12:21 »
Advertisements
get_parameter_data is (usually) equivalent to an eventproc named PTM_RestoreUIProperty which is registered by UI.Create or UI.CreatePublic. There can be cases when PTM_RestoreUIProperty is doing something different, but that is probably limited to special cases (just guessing: factory mode, cam was reset to defaults, etc).
To use it successfully, one needs to know the size of various params - some can be found in CHDK source, others can be found in a disassembly with some luck.
Not all permanent camera settings are handled via params.

Re: shooting script using Canon basic ?
« Reply #41 on: 20 / November / 2018, 04:01:41 »
To use it successfully, one needs to know the size of various params - some can be found in CHDK source, others can be found in a disassembly with some luck.
Not all permanent camera settings are handled via params.

I thought of a way to read out the shutter count for cameras that are not ported. With my cameras, the shutter count is always at the beginning of the parameter block.

M100 100a, M3 101a, 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 2*S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

*

Offline srsa_4c

  • ******
  • 3814
Re: shooting script using Canon basic ?
« Reply #42 on: 20 / November / 2018, 17:23:07 »
I thought of a way to read out the shutter count for cameras that are not ported.
I see. If it can be assumed that the shutter count param is among the first few, one could do these:
- simple script that shows the first few params as integer (and perhaps saves them in a file)
- a more complicated script that takes a sample of those params, takes a picture, and shows the changed params.

Re: shooting script using Canon basic ?
« Reply #43 on: 12 / March / 2019, 12:31:05 »
Attached a slightly changed script that attempts to let through the OFF events. I also changed the "hotkey", this time I used one of the "shortcut" events - see get_cam_keys() in camspec.m . There is no event in the logical event list that sounds like "M-Fn".
If you want something different, try the event code script I posted earlier to find codes that are actually used (and share them, if possible).
 
If I want to try it on the EOS M100 I need a special camspec.m right?
M100 100a, M3 101a, 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 2*S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd


*

Offline srsa_4c

  • ******
  • 3814
Re: shooting script using Canon basic ?
« Reply #44 on: 12 / March / 2019, 17:11:09 »
If I want to try it on the EOS M100 I need a special camspec.m right?
Yes. You can go through the m6-specific file and change the model specific values and addresses.
For example, the platform ID of m100 is 0x32d1 (use this in check_compat()).
Fix the IDs in get_cam_keys(), using the attached m100 levent table.
Leave get_uiprop() as is for now.
Finally, fix the propcase variables (those that are after dim).
Unfortunately, this cam has another new propset, as found by the sigfinder:
Code: [Select]
// Known propcases
// //      PROPCASE_AFSTEP 13
// #define PROPCASE_FOCUS_STATE 18
// #define PROPCASE_AV 23
// #define PROPCASE_BV 40
// //      PROPCASE_DELTA_DIGITALGAIN 85
// #define PROPCASE_DELTA_SV 87
// //      PROPCASE_DELTA_ND 88
//         PROPCASE_EV_CORRECTION_2 not found
// #define PROPCASE_ORIENTATION_SENSOR 232
// #define PROPCASE_SV_MARKET 260
// //      PROPCASE_SVFIX 261
// #define PROPCASE_TV 277
For reference this is the m6:
Code: [Select]
// Known propcases
// //      PROPCASE_AFSTEP 13
// #define PROPCASE_FOCUS_STATE 18
// #define PROPCASE_AV 23
// #define PROPCASE_BV 40
// //      PROPCASE_DELTA_DIGITALGAIN 85
// #define PROPCASE_DELTA_SV 87
// //      PROPCASE_DELTA_ND 88
//         PROPCASE_EV_CORRECTION_2 not found
// #define PROPCASE_ORIENTATION_SENSOR 231
// #define PROPCASE_SV_MARKET 259
// //      PROPCASE_SVFIX 260
// #define PROPCASE_TV 276
So, propcases are shifted by one somewhere between 88 and 231.

If you need to know the codes of certain buttons (sometimes the names in the levent table don't help), you can try the script from this thread, posted earlier.

Re: shooting script using Canon basic ?
« Reply #45 on: 13 / March / 2019, 04:25:27 »
For example, the platform ID of m100 is 0x32d1 (use this in check_compat()).

Done...

Fix the IDs in get_cam_keys(), using the attached m100 levent table.

I can’t find  *halfshoot = 0x9a1

Finally, fix the propcase variables (those that are after dim).

These propcase are missing:
PROPCASE_TV2
PROPCASE_AV2
PROPCASE_SV_BASE
PROPCASE_ISO_MODE

Attached a camspec for EOS 100. Should I try it?
M100 100a, M3 101a, 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 2*S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

*

Offline srsa_4c

  • ******
  • 3814
Re: shooting script using Canon basic ?
« Reply #46 on: 13 / March / 2019, 13:57:28 »
I can’t find  *halfshoot = 0x9a1
Yeah, did not mention that anywhere. Halfshoot is SwOne or SW1, full press is SwTwo or SW2.

Located the missing propcases and fixed some comments in the file. Set the hot key to the wifi button, hopefully that corresponds to the levent name.
Here's camspec.m for the M100.
Code: [Select]
' camera specific plugin
' m100 100a

public sub check_compat()
    if Peek16(0xe1f20270) =  0x32d1 then
        check_compat = 1
    else
        check_compat = 0
    end if
end sub

public sub get_shf_gen()
    ' camera has the newer ssfs eventprocs
    get_shf_gen=1
end sub

public sub get_cam_keys(set,menu,up,down,halfshoot,hotkey,nhotkey,pass1,pass2)
    ' these are the Press* event codes from the levent-table
    *set = 0x85c
    *menu = 0x82c
    *up = 0x824
    *down = 0x828
    *halfshoot = 0x9a1 ' PressSwOne

    *nhotkey = "Wifi"
    *hotkey = 0x100f ' PressWifiButton

    ' the following codes (and their unpress event) are always passed through
    *pass1 = 0x1005 ' PressOffButton
    *pass2 = 0x1008 ' PressPowerButton
end sub

public sub camspec_init()
end sub

public sub get_uiprop(id)
    if id>0xe7 then ' TODO, see @E025DC82 in M6 100b
        ' ID is over limit, letting it through would crash the camera
        get_uiprop = -1
    else
        get_uiprop = PTM_GetCurrentItem(0x8000+id) ' registered by UI.CreatePublic
        if get_uiprop>32767 then
            get_uiprop = get_uiprop - 65536
        end if
    end if
end sub

public sub get_prop(id,buf,len)
    get_prop = GetPropertyCase(id,len) ' registered by System.Create
    *buf = get_prop
end sub

private sub set_prop(id,buf,len)
    set_prop = SetPropertyCase(id,*buf,len) ' registered by System.Create
end sub

dim PROPCASE_TV=277
dim PROPCASE_TV2=276
dim PROPCASE_AV=23
dim PROPCASE_AV2=22
dim PROPCASE_SV_BASE=34
dim PROPCASE_SV=359
dim PROPCASE_ISO_MODE=158
dim PROPCASE_DELTA_SV=87
dim PROPCASE_SV_MARKET=260

public sub set_tv96(val)
    set_prop(PROPCASE_TV, &val, 2)
    set_prop(PROPCASE_TV2, &val, 2)
end sub

public sub set_av96(val)
    set_prop(PROPCASE_AV, &val, 2)
    set_prop(PROPCASE_AV2, &val, 2)
end sub

public sub set_sv96(val)
    ' trying to imitate shooting_set_sv96() of CHDK
    tmp = 0
    set_prop(PROPCASE_ISO_MODE, &tmp, 2)
    get_prop(PROPCASE_SV_BASE, &tmp, 2)
    set_prop(PROPCASE_SV_MARKET, &tmp, 2)
    ' following 0 is SV96_MARKET_OFFSET
    dsv = val + 0 - tmp
    set_prop(PROPCASE_SV, &val, 2)
    set_prop(PROPCASE_DELTA_SV, &dsv, 2)
end sub

public sub get_tv96(buf)
    tmp = 0
    get_prop(PROPCASE_TV, &tmp, 4)
    if tmp>32767 then
        *buf = tmp - 65536
    else
        *buf = tmp
    end if
end sub

public sub get_av96(buf)
    tmp = 0
    get_prop(PROPCASE_AV, &tmp, 4)
    if tmp>32767 then
        *buf = tmp - 65536
    else
        *buf = tmp
    end if
end sub

public sub get_sv96(buf)
    tmp = 0
    get_prop(PROPCASE_SV, &tmp, 4)
    if tmp>32767 then
        *buf = tmp - 65536
    else
        *buf = tmp
    end if
end sub

' identified from disassembly:
' PROPCASE_AV 23
' PROPCASE_USER_AV 29
' PROPCASE_SV_BASE 34 ' see E02FB192 in M6 100b
' PROPCASE_SHOOTING_MODE 56
' PROPCASE_QUALITY 65
' PROPCASE_DELTA_SV 87
' PROPCASE_DIGITAL_ZOOM_POSITION 104
' PROPCASE_ISO_MODE 158 ' see "GetPropertyFromCase Error [ISOSpeed]"
' PROPCASE_RESOLUTION 231 ' see "GetPropertyFromCase Error [Resolution]"
' PROPCASE_SV_MARKET 260 ' see E02FB160 in M6 100b
' PROPCASE_TV2 276 ' see E00F06C8 in M6 100b (UIFS_GetCurrentTvString)
' PROPCASE_TV 277
' PROPCASE_USER_TV 279
' PROPCASE_SV 359 ' see E02FB168 and E02FB218 in M6 100b
Now, it's very likely that you'll see what cedricb saw (at least one extra shot).

I probably never mentioned this here, but it's possible that Canon Basic doesn't behave well when multiple scripts run in different tasks, at the same time. The extra shot might be a result of that (but it can also be a mistake in the script).

If there are threading problems like that maybe we can try to move some of the script's functionality to native code...

Re: shooting script using Canon basic ?
« Reply #47 on: 14 / March / 2019, 12:58:33 »
Here's camspec.m for the M100.
Thanks

If there are threading problems like that maybe we can try to move some of the script's functionality to native code...

At ‘Shoot 1’ I got also 2 pictures
Code: [Select]
1/50s; f4.0; 400;
1/50s; f4.0; 400;

At " Shoot 3 Tv br" the script did not stop after 4 pictures.
Today I used a Canon EF-M 15-45mm. The Script stops after 12 pictures with Error “not enough memory”.  After the cam saves picture on SD Card, I still could use the cam.
Yesterday I used a Canon EF-S 55-250mm and the cam crashes after 9 pictures. I had to remove battery to get the cam alive.
I don’t think that the lens makes the different. I used AV Mode and shoot only RAW Data.


Code: [Select]
1/50s; f4.0; 400;
1/50s; f4.0; 400;
1/25s; f4.0; 400;
1/13s; f4.0; 400;
1/13s; f4.0; 400;
1/13s; f4.0; 400;
1/13s; f4.0; 400;
1/13s; f4.0; 400;
1/13s; f4.0; 400;
1/13s; f4.0; 400;
1/13s; f4.0; 400;
1/13s; f4.0; 400;


But Basically, the Canon Basic is a great extension for cams without CHDK support ...
M100 100a, M3 101a, 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 2*S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd


*

Offline srsa_4c

  • ******
  • 3814
Re: shooting script using Canon basic ?
« Reply #48 on: 14 / March / 2019, 14:23:18 »
At ‘Shoot 1’ I got also 2 pictures
(...)
At " Shoot 3 Tv br" the script did not stop after 4 pictures.
Today I used a Canon EF-M 15-45mm. The Script stops after 12 pictures with Error “not enough memory”.  After the cam saves picture on SD Card, I still could use the cam.
Yesterday I used a Canon EF-S 55-250mm and the cam crashes after 9 pictures. I had to remove battery to get the cam alive.
Well, thanks for trying.
The script seemed to work on my m10, but apparently doesn't work well at all on dual core DIGICs. I suspect that CBasic was not meant to be used multithreaded, and a script of this complexity completely fails on a system where two tasks can run at literally the same time.

Re: shooting script using Canon basic ?
« Reply #49 on: 15 / March / 2019, 14:22:00 »
I played something with the script today. It seems a timing problem. On the one hand I used a newer, faster SD card and put the camera on MF.
On the first run (only RAW), the camera took only three pictures :)
On the second and third runs the cam took 7 Pictures.
If I set the camera to only JPG, then the cam always make the 4 pictures (the first picture twice).
Have you tried only RAW?

But basically, I still have problems starting scripts (like the firmware dump). I have the problem synonymous with the new SD card. Sometimes I have to start the camera 10 times. Is there a specific timing at power on?
https://chdk.fandom.com/wiki/Canon_Basic/Card_Setup
Quote
Start the camera in Play Mode then click the FUNC./SET button to run the script.
How much time can be between pressing play and pressing set?
How long I have to press SET button?
It looks like, if I press ‘set’ once short and than press ‘set’ long I have more success…
If there are threading problems like that maybe we can try to move some of the script's functionality to native code...
What does that mean?
M100 100a, M3 101a, 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 2*S45,
Flickr https://www.flickr.com/photos/136329431@N06/albums
YouTube https://www.youtube.com/channel/UCrTH0tHy9OYTVDzWIvXEMlw/videos?shelf_id=0&view=0&sort=dd

 

Related Topics