Sporadic failure of click() and wheel(), why? - Script Writing - CHDK Forum supplierdeeply

Sporadic failure of click() and wheel(), why?

  • 9 Replies
  • 5934 Views
Sporadic failure of click() and wheel(), why?
« on: 14 / December / 2013, 08:46:58 »
Advertisements
Hello, I have a strange issue with the latest CHDK release. I have a script that first resets the camera to companies default values, and then should adjust shooting parameters by using click() and wheel().

The strange thing is, that some of the click() and wheel() simply get lost, although I have long sleep() between the calls.

The script sometimes behaves as it should, but sometimes it doesn't. There is no hint why it fails sometimes.

Since The script always rests the camera to its companies default, the starting configuration and parameters always are the same, thus it should always behave as supposed, but it does not.

I am running SX200IS with the newest build. Some time ago I had a much older CHDK installed, and everything worked well. Also the display is not updated reliable any more, sometimes it simply stucks while the script is still running. Is there any chance to find out what the reason for it might be?

Thanks! Martin.
« Last Edit: 17 / December / 2013, 12:26:14 by Karmaschinken »

Re: Sporadic failure of click() and wheel(), why?
« Reply #1 on: 14 / December / 2013, 09:16:02 »
The strange thing is, that some of the click() and wheel() simply get lost, although I have long sleep() between the calls.
The sleep() between calls gives the camera time to process the button clicks but it sounds like you have an additional problem.   It looks like maybe the timing of the click() or wheel_right(), wheel_left() is too tight.  You can test this by changing the  click(button_name)  to press(button_name) sleep(1000) release(button_name).

Or if you want,  as IIRC you build your own versions,  you can change the length of the click() commands in the  CHDK source code to see if that really is the problem.  Add the following to your platform_camera.h file :

Code: [Select]
#undef  CAM_KEY_PRESS_DELAY
#define CAM_KEY_PRESS_DELAY           120 
Unfortunately,  the wheel commands are direct calls the Canon firmware for the wheel - you can't really play with the timing there other than the sleep() code you already have.  But perhaps the issue is just with the clcik commands?

Quote
I am running SX200IS with the newest build. Some time ago I had a much older CHDK installed, and everything worked well. Also the display is not updated reliable any more, sometimes it simply stucks while the script is still running. Is there any chance to find out what the reason for it might be?
Probably need to see the script to comment on that one.
« Last Edit: 14 / December / 2013, 09:51:37 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Sporadic failure of click() and wheel(), why?
« Reply #2 on: 14 / December / 2013, 09:32:38 »
Hey thanks a lot! It took me more than 6 hours to deal with that thing. Actually Ione moment after posting this I stumpled upon press() and release(), I did not know them until now. I wrote my own button() function which uses press and release with some delay inbeteween, now it works like charme.

I managed to extend the chdkptp gui with buttons that upload whole scripts to all cameras plugged in and starts them without waiting to finish. now I will try to extend the button to multicamera mode, the get the shooting functionality.

Thanks a lot, waterwingz! I appreciate your work so much, i don't know how to thank you and the other hackers out there.

As soon as i make some money with my rig i promise to donate a larger ammount to the forum (again), thats for sure!

Re: Sporadic failure of click() and wheel(), why?
« Reply #3 on: 14 / December / 2013, 09:38:52 »
Hey thanks a lot! It took me more than 6 hours to deal with that thing. Actually Ione moment after posting this I stumpled upon press() and release(), I did not know them until now. I wrote my own button() function which uses press and release with some delay inbeteween, now it works like charme.
Might be worth adding the CAM_KEY_PRESS_DELAY change I posted above to the platform_camera.h file for your camera?  If so, you might not have to go all the way to 120 as I suggested.  The default value is 30 but several other cameras use 60 instead.
« Last Edit: 14 / December / 2013, 09:52:31 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Sporadic failure of click() and wheel(), why?
« Reply #4 on: 14 / December / 2013, 19:42:32 »
In the end I had some more issues with it. The press/release workaround did not work when sending them as a command-chain via ptp, so in the end I redefined the static values for the delay as you suggested. Thanks for that!  8)

Re: Sporadic failure of click() and wheel(), why?
« Reply #5 on: 14 / December / 2013, 20:08:12 »
In the end I had some more issues with it. The press/release workaround did not work when sending them as a command-chain via ptp, so in the end I redefined the static values for the delay as you suggested. Thanks for that!  8)
If that makes your camera work better,  its probably worth adding to the stable & dev autobuild. 

@reyalp :  probably not worth submitting a patch file if you can just change it?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14117
Re: Sporadic failure of click() and wheel(), why?
« Reply #6 on: 14 / December / 2013, 21:05:32 »
What delay value is required to make click work?

FWIW, the most likely reason that using press and release doesn't work with PTP is that they are being sent as individual scripts. When a script ends, all the currently pressed keys are released. You can get around this in several ways
1) send the press, sleep and release as one script
2) use a message script, like rlibs msg_shell, and then send code to call the presses and releases as needed.
3) use post_levent_to_ui to send the key presses with canon events.

edit: The above is just additional information in case someone runs into the same problem with PTP. We should still fix click to have the necessary delay.
Don't forget what the H stands for.

Re: Sporadic failure of click() and wheel(), why?
« Reply #7 on: 17 / December / 2013, 07:26:06 »
Thanks for your messages! After having added this code:

#undef  CAM_KEY_PRESS_DELAY
#define CAM_KEY_PRESS_DELAY           60 

to the platform_camera.h, as suggested by waterwingz, the camera runs fine. If I unterstood that right waterwingz will adjust that permanently for this model.

Thanks for your help!


Re: Sporadic failure of click() and wheel(), why?
« Reply #8 on: 03 / January / 2014, 07:52:22 »
Hello, once again this topic. I have the feeling that a similar problem exists with wheel_left + right.

Is there any similar WHEEL_TURN_DELAY or such? Thanks!

*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: Sporadic failure of click() and wheel(), why?
« Reply #9 on: 03 / January / 2014, 08:46:31 »
No, the function 'wheel_right/left' uses directly an inbuilt camera function.

See source code http://trac.assembla.com/chdk/browser/trunk/platform/sx200is/lib.c#L58

The second argument in '_PostLogicalEventForNotPowerType' is the stepwidth for the wheel function.

msl
CHDK-DE:  CHDK-DE links

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal