Which scripting practices are considered to be more dangerous? - Script Writing - CHDK Forum

Which scripting practices are considered to be more dangerous?

  • 5 Replies
  • 386 Views
Advertisements
What should I avoid trying as a beginner (not in programming but in CHDK programming)?

*

Offline reyalp

  • ******
  • 12630
Re: Which scripting practices are considered to be more dangerous?
« Reply #1 on: 28 / March / 2020, 17:06:12 »
What should I avoid trying as a beginner (not in programming but in CHDK programming)?
If you mean "dangerous" in terms of permanently damaging the camera, the risk should be very low if you stick to standard script functions.  In the > 10 years CHDK has been around, there have been only handful of cases of suspected damage. See https://chdk.fandom.com/wiki/Camera_failures_suspected_to_be_caused_by_CHDK and https://chdk.fandom.com/wiki/FAQ#Q._Can_CHDK_damage_your_camera.C2.A0.3F

You could damage the camera if you deliberately call firmware functions that modify the onboard flash that holds the firmware, but it's nearly impossible to do this by accident. It might also be possible to cause damage by commanding hardware to move in an unexpected way (like say, moving the zoom while the camera is shooting) but in general, the firmware seems to have pretty good sanity checks.
Don't forget what the H stands for.

Re: Which scripting practices are considered to be more dangerous?
« Reply #2 on: 28 / March / 2020, 17:37:48 »
Thanks for your reply, I've checked those links.

Recently my SX260HS froze twice with open lens soon after running a motion detection script*.  This wasn't funny but I guess there's no damage in this.
Anyway now after updating the 3 year old 1.2.0 CHDK version this script works well.

When you talk about "modifying the onboard flash" what can cause this? I guess changing focus, shutter speed, aperture etc. is on the safe side. 

Is it imperative also to take sleep() breaks after every click or when the camera is busy?
If yes how can I know for how long?


*probably this one:
@title Motion Detect Plus
rem Version 0.3.1 - Sept 16, 2012
rem Build 27
rem This file is a CHDK LUA script and should have the name "motionp.lua"
rem by Andrew Hazelden

Re: Which scripting practices are considered to be more dangerous?
« Reply #3 on: 28 / March / 2020, 18:20:07 »
Thanks for your reply, I've checked those links.

Recently my SX260HS froze twice with open lens soon after running a motion detection script*.  This wasn't funny but I guess there's no damage in this.
Anyway now after updating the 3 year old 1.2.0 CHDK version this script works well.

When you talk about "modifying the onboard flash" what can cause this? I guess changing focus, shutter speed, aperture etc. is on the safe side. 

Is it imperative also to take sleep() breaks after every click or when the camera is busy?
If yes how can I know for how long? I saw the get_mode function but what about busy time while writing movies to the SD card?


*probably this one:
@title Motion Detect Plus
rem Version 0.3.1 - Sept 16, 2012
rem Build 27
rem This file is a CHDK LUA script and should have the name "motionp.lua"
rem by Andrew Hazelden
« Last Edit: 28 / March / 2020, 18:35:19 by nubicon »


*

Offline reyalp

  • ******
  • 12630
Re: Which scripting practices are considered to be more dangerous?
« Reply #4 on: 28 / March / 2020, 20:46:02 »
Recently my SX260HS froze twice with open lens soon after running a motion detection script*.  This wasn't funny but I guess there's no damage in this.
This usually means the camera crashed. Sometimes the ROMLOG https://chdk.fandom.com/wiki/Debugging#Camera_crash_logs_.28romlog.29 has hints about why, but I wouldn't bother getting one for a crash that happened using CHDK 1.2.

Quote
When you talk about "modifying the onboard flash" what can cause this?
I meant the flash ROM memory where the firmware and settings are stored. As I said, there is essentially no chance of doing this by accident, you'd need to intentionally call firmware functions with call_func_ptr or call_event_proc to do that.

Quote
Is it imperative also to take sleep() breaks after every click or when the camera is busy?
No. You should use sleep if you are waiting for something to happen, like waiting for the camera to be ready after half press.

In some cases, you might need additional waits, for example, maybe between switching to rec mode and then setting the capture mode. There is no hard and fast rule, it's something you can try if your script crashes the camera or if the some script actions seem to be ignored.

Quote
I saw the get_mode function but what about busy time while writing movies to the SD card?
get_video_recording and get_movie_status can tell you something about whether movies are recording. This is a case where you may need a bit of additional wait after the status goes to not recording. How long you have to wait (if at all) would need to based on testing.

In case you haven't already found it, https://chdk.fandom.com/wiki/CHDK_Scripting_Cross_Reference_Page is a good place to start for script functions.
Don't forget what the H stands for.

Re: Which scripting practices are considered to be more dangerous?
« Reply #5 on: 29 / March / 2020, 06:25:04 »
Thank you reyalp. You helped me a lot.

 

Related Topics