bug report: @range - General Discussion and Assistance - CHDK Forum

bug report: @range

  • 5 Replies
  • 2888 Views
*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
bug report: @range
« on: 28 / November / 2014, 15:46:54 »
Advertisements
There is an issue with the script parameter values and @range.

The script parameter input range for numbers is -9,999 to 99,999. But @range only allows a range of 2 ^ 16 between minimum and maximum. A greater range leads to unexpected results and crashes.

msl
CHDK-DE:  CHDK-DE links

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: bug report: @range
« Reply #1 on: 28 / November / 2014, 19:05:31 »
There is an issue with the script parameter values and @range.

The script parameter input range for numbers is -9,999 to 99,999. But @range only allows a range of 2 ^ 16 between minimum and maximum. A greater range leads to unexpected results and crashes.

msl

In the current implementation script range values are stored as two shorts packed into a single int.
Range values are -9999 - 32767 (for signed range) and 0 - 65535 (for unsigned range).

The limits are in the code comments:
Code: [Select]
static int script_range_values[SCRIPT_NUM_PARAMS];          // Min/Max values for param validation
static char script_range_types[SCRIPT_NUM_PARAMS];          // Specifies if range values is signed (-9999-32767) or unsigned (0-65535)
                                                            // Note: -9999 limit on negative values is due to current gui_menu code

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: bug report: @range
« Reply #2 on: 28 / November / 2014, 19:31:55 »
In the current implementation script range values are stored as two shorts packed into a single int.
Range values are -9999 - 32767 (for signed range) and 0 - 65535 (for unsigned range).
The limits are in the code comments:
I'll add a note here   http://chdk.wikia.com/wiki/CHDK_scripting#The_Script_Header and here http://chdk.wikia.com/wiki/UBASIC/TutorialScratchpad#The_Script_Header

Sometime people actually read that stuff so I guess that's the best we can do?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: bug report: @range
« Reply #3 on: 29 / November / 2014, 07:28:10 »
The limits are in the code comments:
I had read the comments in gui_menu.c. I thought we could adjust this limits.

A SX20-owner had tried to write a test script for manual focus. He has defined a range from 0 to 66,000 and got fatal errors. The range was set to 465 as maximum (because of the unsigned range limit). That was the reason for my request.

And the subject distance range is the next problem. I do not understand why we define a minimum and maximum for the distance. E.g. the SX20 has a funny max. distance value in platform_camera.h: 66,490.

I think set_focus(0) returns the minimal subject distance und a too large value for set_focus() returns infinity (-1). There is no risk for wrong results without limits.

There are a lot of cameras whose subject distance range is greater than 65,535 - most of the SX series. But not all of these cameras have a special definition for CAMERA_MAX_DIST.

Also the setting of the hyperfocal distance is affected when the calculating a value greater than 65,535 gets.

msl
CHDK-DE:  CHDK-DE links

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: bug report: @range
« Reply #4 on: 29 / November / 2014, 18:21:25 »
The limits are in the code comments:
I had read the comments in gui_menu.c. I thought we could adjust this limits.

Not without re-writing some code.

Quote
A SX20-owner had tried to write a test script for manual focus. He has defined a range from 0 to 66,000 and got fatal errors. The range was set to 465 as maximum (because of the unsigned range limit). That was the reason for my request.

And the subject distance range is the next problem. I do not understand why we define a minimum and maximum for the distance. E.g. the SX20 has a funny max. distance value in platform_camera.h: 66,490.

I think set_focus(0) returns the minimal subject distance und a too large value for set_focus() returns infinity (-1). There is no risk for wrong results without limits.

There are a lot of cameras whose subject distance range is greater than 65,535 - most of the SX series. But not all of these cameras have a special definition for CAMERA_MAX_DIST.

Also the setting of the hyperfocal distance is affected when the calculating a value greater than 65,535 gets.

msl

Subject distance is really not going to work with the current @range option.

I'm not sure it's worth fixing just to handle SD overrides.

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: bug report: @range
« Reply #5 on: 29 / November / 2014, 18:29:01 »
I'm not sure it's worth fixing just to handle SD overrides.
Especially as you can just delete the @range line and things will "just work". After all,  it's just a limit on what the user can set - useful but not essential.

Having said that,  @range it is especially nice when you use

@range x 0 1

and get a Boolean check box rather than a choice of "0" or "1".  :xmas
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal