Exiting script - General Help and Assistance on using CHDK stable releases - CHDK Forum

Exiting script

  • 3 Replies
  • 2594 Views
Exiting script
« on: 25 / February / 2019, 01:31:12 »
Advertisements
Before I exit my script via a return from the main, I wish to check that the camera has completed all the script's operations.

At the moment if I call return immediately after a shoot() call, the image associated with that shoot() doesn't appear to be captured.

I can 'solve' the problem by putting a sleep(1000) between the shoot and return.

Is there a better way to detect that shoot has finished writing?

*

Offline reyalp

  • ******
  • 14128
Re: Exiting script
« Reply #1 on: 25 / February / 2019, 03:16:18 »
Before I exit my script via a return from the main, I wish to check that the camera has completed all the script's operations.

At the moment if I call return immediately after a shoot() call, the image associated with that shoot() doesn't appear to be captured.

I can 'solve' the problem by putting a sleep(1000) between the shoot and return.

Is there a better way to detect that shoot has finished writing?
That's strange, shoot() should normally blocks until the shot is pretty much done. It might not be totally done, but once the shooting process is started, the script ending shouldn't have any effect on it. What camera, and can you post a minimal example that reproduces the problem?
Don't forget what the H stands for.

Re: Exiting script
« Reply #2 on: 25 / February / 2019, 13:04:46 »
@reyalp

Have just tried to reproduce the issue I was having on my G7X yesterday and am embarrassed to say I can't  >:(
BTW here are the relevant code snipets

Code: [Select]
function bookend()
    if b == 1 then
        set_tv96(960)
        set_av96(640)
        shoot()
        set_tv96_direct(s)
        set_av96_direct(av)
    end
end

function X_bracket()
    set_tv96_direct(s)
    count = count + 1
    if p == 0 then
        shoot()
    elseif p < 4 and j == 0 then
        shoot()
        set_tv96_direct(s-96*p)
        shoot()
        set_tv96_direct(s+96*p)
        shoot()
    elseif p < 4 and j == 1 then
        shoot()
        set_tv96_direct(s+96*p)
        shoot()
        set_tv96_direct(s+2*96*p)
        shoot()
    elseif p < 4 and j == 2 then
        shoot()
        set_tv96_direct(s-96*p)
        shoot()
        set_tv96_direct(s-2*96*p)
        shoot()
    elseif p == 4 then
        local iso = get_sv96()
        set_sv96(sv96_market_to_real(iso_to_sv96(100)))
        shoot()
        set_sv96(sv96_market_to_real(iso_to_sv96(800)))
        shoot()
        set_sv96(iso)
    elseif p == 5 then
        local iso = get_sv96()
        set_sv96(sv96_market_to_real(iso_to_sv96(100)))
        shoot()
        set_sv96(sv96_market_to_real(iso_to_sv96(1600)))
        shoot()
        set_sv96(iso)
    elseif p == 6 then
        shoot()
        set_tv96_direct(s-96*4)
        shoot()
    end
    set_tv96_direct(s)
end

if u == 2 or u == 3 then
    dof = get_dofinfo()
    x = dof.focus -- register actual x
    last_x = x
    sleep(c*1000)
    bookend()
    if u == 3 then x_start = x_start+m end
    repeat -- to capture focus brackets from min focus up to x
        X_bracket()
        temp = get_exp_count().." @ "..x.."mm"
        if v == 1 then print(temp) end
        x = (x*(h*10 - 2*fl))/(h*10 - 2*x*10) -- position of next focus bracket
        if (x - last_x) == 0 then x = last_x + 1 end
        if x < last_x or x == -1 then
            print("Unknown Error")   
            refocus(x_start)
            return
        end   
        refocus(x) -- request move to x
        dof = get_dofinfo()
        x = dof.focus -- register actual x moved by cam
        last_x = x
    until ((x <= 0) or (x > x_start))
    refocus(x_start)
    dof = get_dofinfo()
    x = dof.focus -- register actual x moved by cam
    X_bracket()
    bookend()
    temp = get_exp_count().." @ "..x.."mm"
    if v == 1 then print(temp) end
    --sleep(1000)
    return -- exit script
end

As I say, yesterday I had to insert the sleep call at the end to get the bookend function to work as expected.

Today the bookend call works without the sleep commented out (as above) !!!!!

Strange.

*

Offline reyalp

  • ******
  • 14128
Re: Exiting script
« Reply #3 on: 25 / February / 2019, 16:02:33 »
Have just tried to reproduce the issue I was having on my G7X yesterday and am embarrassed to say I can't  >:(
Hate it when that happens. Update us if it comes back...

I'm pretty confident that shoot blocks when it's working correctly (I frequently use just shoot() as a standalone script through PTP), but there could certainly be some other bug causing the symptom.

There are cases where shoot() can fail to shoot completely.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal