Powershell hook-script for gPhoto2 running on Windows10

0

I try to use a hook-script on gPhoto2 running on Windows10 installed via MSYS2 MinGW. gPhoto2 is working quite well. My problem is now that I like to run a hook-script reacting on the events from the camera. I start the gPhoto tethered capture with this code:



    $env:CAMLIBS="C:\msys64\mingw64\lib\libgphoto2\2.5.23\"
    $env:IOLIBS="C:\msys64\mingw64\lib\libgphoto2_port\0.12.0\"
    
    gphoto2 --auto-detect
    
    gphoto2 --capture-tethered --filename "%Y-%m-%d_%H%M%S.%C" --hook-script "D:\gphoto2Testing\Test.ps1"

For testing purposes the code of 'Test.ps1' is just

exit 0

because as far as I understood the gPhoto2 documentation one need a zero exit code for the init action. Nevertheless I get the following error:



    gphoto2 : Hook script returned error code -1 (0xffffffff)
    In D:\gphoto2Testing\gPhoto2.ps1:6 Zeichen:1
    + gphoto2 --capture-tethered --filename "%Y-%m-%d_%H%M%S.%C" --hook-scr ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (Hook script ret...-1 (0xffffffff):String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
     
    Hook script "D:\gphoto2Testing\Test.ps1" init failed. Aborting.

In general the hook-script should be script-type agnostic (see https://github.com/gphoto/gphoto2/issues/217). The demo hook-script which ships with gPhoto2 reads:


    self=`basename $0`
    
    case "$ACTION" in
        init)
        echo "$self: INIT"
        # exit 1 # non-null exit to make gphoto2 call fail
        ;;
        start)
        echo "$self: START"
        ;;
        download)
        echo "$self: DOWNLOAD to $ARGUMENT"
        ;;
        stop)
        echo "$self: STOP"
        ;;
        *)
        echo "$self: Unknown action: $ACTION"
        ;;
    esac
    
    exit 0

The docs of gPhoto2 reads:

Execute the hook script FILENAME every time a certain event happens within gphoto2. The hook script reads the environment variable ACTION. It must ignore ACTION values unknown to it.

Maybe my problem is somehow related to the environment variable ACTION or the above mentioned exit code. I searched on google but without any sucess. Any help to solve this problem is much appreciated.

powershell
libgphoto2
asked on Stack Overflow Aug 28, 2020 by joking

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0