CHDK test scripts - General Discussion and Assistance - CHDK Forum

CHDK test scripts

  • 8 Replies
  • 6238 Views
*

Offline reyalp

  • ******
  • 14125
CHDK test scripts
« on: 03 / July / 2011, 19:47:09 »
Advertisements
I'd like to have a collection of scripts that test the different areas that can be tested via script. This should help people making new ports, and also help ensure things don't get broken in code changes.

I've started a general purpose ubasic script, attached below. This currently tests
* tv, sv and ND override
* exposure counter
* shoot/get_shooting
* key input and sending keys to the canon firmware
* sleep and get_tick_count
* print_screen logging
* play/rec + capture mode switching
Only some failures can be detected automatically by the script, others require watching the test run or examining the log output and images.

edit:
updated
fixed keyin goto, increased shoot half delay to 3 sec

edit:
now in svn http://tools.assembla.com/chdk/browser/trunk/CHDK/SCRIPTS/TEST/ubtest.bas


Usage:
Start the camera in play mode and run the script. The camera should be aimed at a scene where it can do AE and AF and get a a reasonable image. Script output is logged to CHDK/LOGS/LOG_0001.TXT

If the "interactive" option is set, it will allow you to press some keys and print the key name in response. set ends this section.

Next it tests sending key presses to the canon firmware, by opening the canon menu, pressing up and down, and closing it.

After that, it tries to switch to REC, P mode (called manual on cameras without a true manual) and shoot some pictures with different overrides.

Assuming the exposure counter is working, the number corresponding to each shot is recorded along with what is being tested, so you can see if the resulting images show the expected override effects.

I'd like to have a similar, more extensive test written in lua. Scripts covering the same are in both languages is desirable, since we may create bugs in the interface for a particular language.

Comments and suggestions are welcome. I'll probably add this to that standard CHDK package at some point. I'm particularly interested in ideas for tests where a clear pass/fail can be determined by the script, or easily determined from the resulting image.

Some other existing scripts in the CHDK distribution:
- http://chdk.wikia.com/wiki/Lua#Lua_library_test
Verifies lua libraries, which exercises quite a C library functions as well.
- Setmode http://chdk.wikia.com/wiki/Lua/Scripts:Standard/Test/Setmode
tests modemap and mode switching functions.
« Last Edit: 04 / July / 2011, 21:03:12 by reyalp »
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK test scripts
« Reply #1 on: 04 / July / 2011, 06:04:44 »
Nice, will help a lot with controlled testing :)

Couple of things.
- line 26 should be if a <> 1 then goto "keyin_done" (goto "key_done" fails if interactive turned off)
- on the G12 had to increase the loop count after 'press "shoot_half"' to 20 to give it time to register the half press and calculate exposure
- also on the G12 I had to add a 'sleep 1000' before doing the 'set_capture_mode 2' to give the camera time to finish switching from playback to record mode.

G12 runs with no failures after making the above changes.
SX30 only needed the first 'goto' fix.

Things that might be good to test (though not sure the best way to do these):
- set_focus & get_focus
- set_zoom & get_zoom

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: CHDK test scripts
« Reply #2 on: 04 / July / 2011, 12:08:06 »
Agreed - very nice.  Runs fine on my SD940 - made the philmoz line 26 change before I started as "key_done" did not seem to be defined ?   Naturally, I can't test the DISP key as that's the "ALT" key on my camera.

Also lengthened the sleeps by at least 2x - that would get old during coding/testing but helps when you are trying to follow the script in action for the first time.

 
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14125
Re: CHDK test scripts
« Reply #3 on: 04 / July / 2011, 17:51:29 »

- line 26 should be if a <> 1 then goto "keyin_done" (goto "key_done" fails if interactive turned off)
Oops, thanks for catching that. What I get for last minute changes ;)
Quote
- on the G12 had to increase the loop count after 'press "shoot_half"' to 20 to give it time to register the half press and calculate exposure
This will vary by scene, AF settings etc. I've updated it to 3 seconds, that should be enough if it's going to work at all.
Quote
- also on the G12 I had to add a 'sleep 1000' before doing the 'set_capture_mode 2' to give the camera time to finish switching from playback to record mode.
That's interesting, get_mode shouldn't change until the camera is actually ready, that's why the wait loop is there. I wonder if your  playrec_mode is equivalent to the one used on other cameras ? If many cameras need an additional wait, that's a good thing to know.

Also lengthened the sleeps by at least 2x - that would get old during coding/testing but helps when you are trying to follow the script in action for the first time.
Good point. Maybe a menu parameter for the delays between steps that shouldn't affect test results.
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK test scripts
« Reply #4 on: 04 / July / 2011, 18:34:39 »
That's interesting, get_mode shouldn't change until the camera is actually ready, that's why the wait loop is there. I wonder if your  playrec_mode is equivalent to the one used on other cameras ? If many cameras need an additional wait, that's a good thing to know.

Will do some more testing. It appeared that the camera switched briefly to P mode after changing from playback to record mode; but the camera was still doing it's animated mode display (annoying little feature) and when it was done it had changed back to M (which is what I had set on the dial).

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)

*

Offline reyalp

  • ******
  • 14125
Re: CHDK test scripts
« Reply #5 on: 04 / July / 2011, 21:02:29 »
I have checked this into SVN and added a wiki page for testing: http://chdk.wikia.com/wiki/Testing

Please feel free to add your testing suggestions, reorganize etc.
Don't forget what the H stands for.

Re: CHDK test scripts
« Reply #6 on: 05 / July / 2011, 16:41:47 »
Hi Reyalp.

I tried your script on my sx130, it worked just fine. I even added a line near the end so the camera goes back to the same shooting mode it was before the scipt switches to "P".

Just by curiosity, what command should I use to make the camera go back  to PLAY mode just before the script quits?

Thank you!

Jeff
La parcimonie, c'est bien beau, mais faut pas trop en mettre.

*

Offline reyalp

  • ******
  • 14125
Re: CHDK test scripts
« Reply #7 on: 06 / July / 2011, 01:03:31 »
Just by curiosity, what command should I use to make the camera go back  to PLAY mode just before the script quits?
set_record 0
Don't forget what the H stands for.

Re: CHDK test scripts
« Reply #8 on: 06 / July / 2011, 14:40:17 »
Hi everybody,

just my little 2 cents:  I added a few lines on reyalp's code so the camera goes back to its original state just before the script quits.

Thank you reyalp!

jeff
La parcimonie, c'est bien beau, mais faut pas trop en mettre.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal