set_zoom problems in uBASIC & Lua scripts - page 3 - General Discussion and Assistance - CHDK Forum supplierdeeply

set_zoom problems in uBASIC & Lua scripts

  • 91 Replies
  • 17448 Views
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #20 on: 11 / November / 2011, 14:59:53 »
Advertisements
Try adding:
       while (focus_busy) msleep(10);
before the call to _MoveZoomLensWithPoint
Will do - this could work. I was thinking of something much more complicated so this is better. 

If not,  an other choice might be to try and work backwards up the tree in the Canon source code to see what the camera does before & after it calls _MoveZoomLensWithPoint()  (assuming that's what it uses to move the zoom lens).  Or would that be a painful exercise with little chance of success in your experience ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Online philmoz

  • *****
  • 3138
    • Photos
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #21 on: 11 / November / 2011, 15:10:25 »
Try adding:
       while (focus_busy) msleep(10);
before the call to _MoveZoomLensWithPoint
Will do - this could work. I was thinking of something much more complicated so this is better. 

If not,  an other choice might be to try and work backwards up the tree in the Canon source code to see what the camera does before & after it calls _MoveZoomLensWithPoint()  (assuming that's what it uses to move the zoom lens).  Or would that be a painful exercise with little chance of success in your experience ?

If the focus_busy check doesn't work then digging deeper into what the MoveZoomLensWithPoint code is doing is probably the next step.

The function that generates the Assert is checking two memory values - it looks like it's the second check that is failing. The second check is against another value passed to the function in R0. I haven't tried to trace the full call stack between MoveZoomLensWithPoint and the asserting function yet.

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)

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #22 on: 11 / November / 2011, 19:08:46 »
If the focus_busy check doesn't work then digging deeper into what the MoveZoomLensWithPoint code is doing is probably the next step.
The focus_busy check did not help on either camera (double checked by commenting out MoveZoomLensWithPoint after and rebuilding/testing to be sure that was the problem line) .  It was worth a shot - but the camera still crashes after it completes the zoom step and then trys to refocus.  So I guess it makes sense that it did not help as the patch simply made sure there was no focus activity prior to the zoom step.

I've attached a couple of dumps from the SD940 running the same script and crashing the same way.   Looks like its in a different task when it dies ?

Has anyone posted how to interpret the romlog.log dumps ?  The task and stack dump seem obvious - what's the significance of the rest - lines like
Code: [Select]
00001240: UI:ScreenUnLock
« Last Edit: 11 / November / 2011, 20:35:56 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Online philmoz

  • *****
  • 3138
    • Photos
Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #23 on: 12 / November / 2011, 00:44:38 »
If the focus_busy check doesn't work then digging deeper into what the MoveZoomLensWithPoint code is doing is probably the next step.
The focus_busy check did not help on either camera (double checked by commenting out MoveZoomLensWithPoint after and rebuilding/testing to be sure that was the problem line) .  It was worth a shot - but the camera still crashes after it completes the zoom step and then trys to refocus.  So I guess it makes sense that it did not help as the patch simply made sure there was no focus activity prior to the zoom step.

I've attached a couple of dumps from the SD940 running the same script and crashing the same way.   Looks like its in a different task when it dies ?

Has anyone posted how to interpret the romlog.log dumps ?  The task and stack dump seem obvious - what's the significance of the rest - lines like
Code: [Select]
00001240: UI:ScreenUnLock


Haven't looked at the SD940; but the G10 could be tricky.
The assert is in sub_FF939340 @0xFF939378 - it compares the value @0x8C3C+0x4 to the value passed in from R0.
sub_FF939340 is called from sub_FFAD1734 @0xFFAD1784. It loads R0 from 0xF5E8+0xC; but it earlier stored a value in this location in sub_FF938AA8.
From what I can tell sub_FF938AA8 returns the value from 0x8C3C+0x4 unless the value in 0x8C3C is 0.
The memory @0x8C3C would appear to be related to the focus controller task - possibly a task control block. I haven't investigated how the task management and semaphore stuff works to add much more than this.

Perhaps reyalp can provide some insight here.

Unfortunately there is not enough stack trace in the log file to tell where sub_FFAD1734 is being called from, and when I try and trace it back in IDA it stops at sub_FFAD17B8 and there are no references to this being called anywhere.

Note sure what to recommend next. Possibly transferring a copy of MoveZoomLensWithPoint into CHDK code and seeing if you can debug it that way.

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)


Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #24 on: 12 / November / 2011, 10:35:02 »
It seems strange that I just happen to own the only two Canon camera models that just happen to have this problem.   More likely its a function that does not get a lot of use unless someone is doing USB remote stuff in KAP  type applications (and they don't use a relatively expensive and/or heavy camera for that).   I'll dig up camera models from the same general release date and see if I can identify active forum members who might be willing to try the script.

Meanwhile,  I took a brief look at the MoveZoomLensWithPoint code.   It does not seem to be called directly from anywhere else in the ROM code,  although its in a stream of about 5 very similiar code blocks so it might be called from some sort of computed jump table ?   Another possibly is that its in a section of code that's a  "library" and not used - there is a different code block used to control the zoom lens somewhere.   Unfortunately,  none of this makes things easier.

Update :  tried swapping  MoveZoomLensWithPoint with PT_MoveOpticalZoomAt like this
Code: [Select]
         //_MoveZoomLensWithPoint((short*)&newpt);
        extern void _PT_MoveOpticalZoomAt(long*);
        _PT_MoveOpticalZoomAt(&newpt);
The G10 code is identical to the SX30 for this function.  Still sometimes crashes at a random time later when it tries to refocus.

I'm pretty sure the stubs addresses are right.  There is just something else missing here.



 
« Last Edit: 12 / November / 2011, 12:46:31 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: set_zoom problems in uBASIC & Lua scripts -
« Reply #25 on: 12 / November / 2011, 13:02:28 »
I guess there is always a way to do something with a "brute force and violence" solution.

Update : works for the G10 but not the SD940. But I'm not sure that the SD940 actually support set_aflock().

Adding this to a script "solves" the problem :
Code: [Select]
  set_aflock(1)
  set_zoom(p)
  set_aflock(0)

With this change,  remote zooming is possible in scripts.   I'm not sure we need to fix anything else if that's the case?  Might be possible to embed the af_lock()'s into lens_set_zoom_point() although it might actually only work with the delays between script step execution.

Unless reyalp has some suggestions based on the previous posts.

That being said,  I'm still working through documenting and maybe fixing the USB_remote code - there is a scriptless remote zoom function buried in there that has never been documented and probably doesn't work anymore - just like the CA-1 code doesn't actually work - but that's a story for a different day.

Here's the modified Lua script for reference :

Code: [Select]
--[[
@title zoom test
@param r zoom speed
@default r 2
]]

function zoomout()
  p=get_zoom()
  if p<s then p=p+1
end
  print("zoom to ",p)
  set_aflock(1)
  set_zoom(p)
  set_aflock(0)
end


function zoomin()
  p=get_zoom()
  if p>0 then p=p-1
end
  print("zoom to ",p)
  set_aflock(1)
  set_zoom(p)
  set_aflock(0)
end

--start script

set_console_layout(10, 0, 40, 14)

s=get_zoom_steps()
print ("started - zoom steps=", s)
set_zoom_speed(r)
print("zoom speed set to ",r)

repeat
  sleep(100)
  wait_click()
  print("click ")
  if is_pressed("right") then zoomout()
end
  if is_pressed("left") then zoomin()
end
  until false


« Last Edit: 12 / November / 2011, 16:01:25 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #26 on: 12 / November / 2011, 14:24:51 »
Might be possible to embed the af_lock()'s into lens_set_zoom_point() although it might actually only work with the delays between script step execution.
Tried this in wrapper.c  - doesn't work.  Hangs up after the first zoom step every time.
Code: [Select]
_DoAFLock();
msleep(100);
    _MoveZoomLensWithPoint((short*)&newpt);
msleep(100);
_UnlockAF();
   
Oh well.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #27 on: 12 / November / 2011, 14:46:54 »
What happens if you remove the msleep after the zoom ?

Maybe it is in a hurry to immediately autofocus.


Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #28 on: 12 / November / 2011, 14:52:29 »
What happens if you remove the msleep after the zoom ?

Maybe it is in a hurry to immediately autofocus.
I added that to give it at little time to complete the zoom before turning autofocus back on ( the _UnlockAF(); is something I put in too).   If anything,   it probably needs a longer sleep - I might try five seconds and see what that does.

Ported :   A1200    SD940   G10    Powershot N    G16

Re: set_zoom problems in uBASIC & Lua scripts - help wanted with testing
« Reply #29 on: 12 / November / 2011, 15:15:06 »
Replace second msleep() with while (zoom_busy) msleep(10);

 

Related Topics