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

shooting script using Canon basic ?

  • 82 Replies
  • 56397 Views
*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: shooting script using Canon basic ?
« Reply #60 on: 12 / October / 2021, 13:36:18 »
Advertisements
Now I have a little script  :D, that translates the
    ps="A/CHDK/LUALIB/GEN/propset"..pn..'.lua'-  to *.m files.
What sense does that make with a Canon Basic Script?

srsa_4c´s script has
Code: [Select]
    System.Create()
    ret = LoadScript("A/camspec.m")
with
Code: [Select]
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
in camspec.m (for M6)
So  ret = LoadScript("A/propset11.m") should be possible too. (reduced Lua´s require("propset"))
(Edit: While Lua´s loadstring(...), dofile(...) and require(...) enhance the script´s global environment, CBasic´s LoadScript(...) is more like a function call with it´s own local code.)   :-[

On N,N2 LCDMsg_SetStr is same color in play & rec mode.
Quote
    a=LCDMsg_Create()
    LCDMsg_ChangeColor(a,cl)
    LCDMsg_Move(a,1,lin)
    LCDMsg_SetStr(a,":o..,....1....,....2....,....3..")
        BeepDrive(3)
    Wait(5000)
'Still havn´t  found CB-script switch to <Rec> on Ns...'
Edit: (PBButton turns cam off, and no Evnt SW1/2 opens lens, (never does))

'Edit2: A single Quote for comment lets my editor see strings, needs a 2nd quote at eol.'
Edit3: I recall some/which? propcases are 'readonly' (e.g. metering_mode).

Is Canon Basic Nested If Bug proof?  :haha
« Last Edit: 20 / October / 2021, 14:32:24 by Caefix »
All lifetime is a loan from eternity.

*

Offline c_joerg

  • *****
  • 1251
Re: shooting script using Canon basic ?
« Reply #61 on: 14 / October / 2021, 12:10:52 »
You should be able to upload using standard PTP operations, for example from chdkptp like
Code: [Select]
chdkptp -c -e"exec require'extras/devutil'.init_cli()" -e"dptpsendobj extend.m extend.m"

I got the Error message:

Code: [Select]
E:\CHDK\chdkptp-r795>chdkptp -c -e"exec require'extras/devutil'.init_cli()" -e"dptpsendobj extend.m extend.m"
connected: Canon PowerShot G9 X Mark II, max packet size 512
WARNING: CHDK extension not detected
ERROR: unknown command 'dptpsendobj'
M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 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 reyalp

  • ******
  • 14128
Re: shooting script using Canon basic ?
« Reply #62 on: 14 / October / 2021, 13:32:16 »
Code: [Select]
E:\CHDK\chdkptp-r795>chdkptp -c -e"exec require'extras/devutil'.init_cli()" -e"dptpsendobj extend.m extend.m"
connected: Canon PowerShot G9 X Mark II, max packet size 512
WARNING: CHDK extension not detected
ERROR: unknown command 'dptpsendobj'
It looks like you are using chdkptp build 795, while I added standard PTP support in 921. The most recent release is 964 https://app.assembla.com/spaces/chdkptp/documents
Don't forget what the H stands for.

*

Offline c_joerg

  • *****
  • 1251
Re: shooting script using Canon basic ?
« Reply #63 on: 15 / October / 2021, 07:02:03 »
It looks like you are using chdkptp build 795, while I added standard PTP support in 921. The most recent release is 964 https://app.assembla.com/spaces/chdkptp/documents

Embarrassing, now it works ...
Code: [Select]
Received handle 0x10001, sending dataI guess I haven't updated CHDKPTP for a while. Never change a running system ;)

The fact that you don't always have to remove the SD card is very helpful. However, the script does not start while the USB cable is still connected. So I have to unplug the USB cable after transferring and before starting the script. But it is much faster than removing the SD card. Thank you very much for the help.
M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 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 c_joerg

  • *****
  • 1251
Re: shooting script using Canon basic ?
« Reply #64 on: 15 / October / 2021, 07:21:50 »
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?
I recall having problems starting scripts from time to time on various cameras. But unfortunately, I don't know what's behind that.
I think it is really a timing problem. I add now some beeps in my script, so I can hear if the scripts starts.

Code: [Select]
dim c
private sub Initialize()
    System.Create()
    Driver.Create()
    for c=1 to 2
      BeepDrive(3)
      Wait(500)
    next 
    CamInfo_Debug(1)
    for c=1 to 2
      BeepDrive(3)
      Wait(500)
    next
end sub
If I press the set key too quickly after switching on, the script sometimes does not start. If I wait 1-2s, it always works.
Does something speak against always inserting a beep in a script?



M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 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 Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: shooting script using Canon basic ?
« Reply #65 on: 15 / October / 2021, 12:44:25 »
Behavior seems also a bit camdependent.
The D30 doesn´t start  with battery cover open...  :-[
Clicking <set> once - after LED-flicker- script starts at once ...
or some seconds later. Looks like sometimes the _SetStr happens after or within the wait...
Code: [Select]
    s=LCDMsg_Create()
    LCDMsg_ChangeColor(s,cl)
    LCDMsg_Move(s,1,lin)
    LCDMsg_SetStr(s,":o..,....1....,....2....,....3..")
        BeepDrive(3)
    Wait(5000)
When the script ends, the key still triggers the Canon-UI at once.
( N&N2 are different, probably as other cams that run Cbasic with zoom-ring.)

... inserting a beep in a script?
BeepDrive( :)) is a nice bookmark in Romlogs...
« Last Edit: 16 / October / 2021, 10:41:27 by Caefix »
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14128
Re: shooting script using Canon basic ?
« Reply #66 on: 15 / October / 2021, 13:35:05 »
The fact that you don't always have to remove the SD card is very helpful. However, the script does not start while the USB cable is still connected.
Yes, Canon firmware locks the keyboard when USB is present. With CHDK (or maybe a Canon Basic script), you can use events to unlock, but I can't think of any way to do that from stock firmware while the cable is still connected.
Quote
So I have to unplug the USB cable after transferring and before starting the script. But it is much faster than removing the SD card.
You could probably do it over wifi if you use a chdkptp build with PTP/IP enabled. Not sure that would be more convenient than unpluging the cable, but I can provide a build and more detailed instructions if you want to try.
Don't forget what the H stands for.

*

Offline c_joerg

  • *****
  • 1251
Re: shooting script using Canon basic ?
« Reply #67 on: 16 / October / 2021, 04:40:05 »
On N,N2 LCDMsg_SetStr is same color in play & rec mode.
On M100 and G9xII never seen in play mode…

You should be able to upload using standard PTP operations, for example from chdkptp like
Code: [Select]
chdkptp -c -e"exec require'extras/devutil'.init_cli()" -e"dptpsendobj extend.m extend.m"
Should that also work on newer DIGIC 8 cameras like M50, SX70, SX740 (or R’s)?

You could probably do it over wifi if you use a chdkptp build with PTP/IP enabled. Not sure that would be more convenient than unpluging the cable, but I can provide a build and more detailed instructions if you want to try.
Thank you for the offer, but I can handle it for now. Maybe you can also insert a switch in the USB cable. I was just wondering how @srsa_4c managed to write the very complex scripts. Quite a few attempts were certainly necessary.

I should be more concerned with porting the G9xII than with Canon Basic  ;)
« Last Edit: 16 / October / 2021, 09:39:58 by c_joerg »
M100 100a, M3 121a, G9x II (1.00c), 2*G1x (101a,100e), S110 (103a), SX50 (100c), SX230 (101a), 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 Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: shooting script using Canon basic ?
« Reply #68 on: 16 / October / 2021, 10:40:26 »
On N,N2 LCDMsg_SetStr is same color in play & rec mode.
On M100 and G9xII never seen in play mode…
The colors vary from cam to cam. 19 is a green on M100, N2.
 ;)  The upperst line could be overwritten by Canon OSD.
Code: [Select]
'' m100 PLAYMODE
'' m100 white=2,4,129,162, green=3,13,184,191, yellow=0, beige=9,10
'' m100 ltyellow=10,30,199,250 brown=18,131,202,
'' ltgrey=16,87, black=35,106,113, DarkGrey=26,33,138,236
'' m100 DarkYellow=95,140,198,250, Orange=31,101,121 Red=186 LightRed=161,182
'' m100 Light Green=19,150,191, Blue=183, Cyan=?, Magenta= 185
« Last Edit: 16 / October / 2021, 15:29:11 by Caefix »
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14128
Re: shooting script using Canon basic ?
« Reply #69 on: 16 / October / 2021, 14:25:32 »
Should that also work on newer DIGIC 8 cameras like M50, SX70, SX740 (or R’s)?
Only way to know for sure is to try it ;)  Upload is a standard PTP operation, so I'd guess it's quite likely but the details of what file types are allowed and the exact parameters could vary (previous discussion https://chdk.setepontos.com/index.php?topic=4338.msg140108#msg140108)
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal