CHDKPTP: Kommando -erec

Fragen zur Bedienung und Funktionsweise des CHDKs
Forumsregeln
Überprüfe folgende Dinge:
Bist stets der Dokumentation gefolgt?
Hast du im Forum schon nach ähnlichen Problemen gesucht?
Hast du bei deiner Frage das Problem umfassend beschrieben?
Welche Kamera und CHDK-Version betrifft das Problem?

Probleme mit einem Skript sollten möglichst und wenn vorhanden in dem zugehörigen Thema zum Skript besprochen werden.

CHDKPTP: Kommando -erec

Beitragvon Joedi » 19.02.2020, 23:10

Hi, bin neu im Forum, hoffentlich bin ich hier richtig...
Bin noch etwas unerfahren, auch mit dem editor fürs posten...
Kamera PowerShot A570IS, FW 101a
mit: CHDK_DE 1.4.1 Rev. 4530
Version von CHDKPTP: 785
Offtopic :
1. Ein grosses Lob an CHDK und die CHDK-Gemeinde! Ich benutze vor allem die script-Funktion seit einiger Zeit und habe schon einiges in lua realisiert, z.B motion detect bei Tieraufnahmen und z.B. Feuerwerksaufnahmen..
2. CHDKPTP benutzte ich bisher für die Tests der eigenen lua.scripts, um das ständige SD-Karten-Wechseln zju umgehen, indem ich die im PC (Linux) editierten Scripts mit "upload" in die Kamera übertrage und dort dann starte.

3. Nun zu meiner konkreten Fage:
Ich möchte mittels chdkptp die Kamera fernbedienen und die Bilder dann in den PC übertragen; dazu habe ich ein bash shell script geschrieben, das jeweils die passenden chdkptp-Kommandos startet; das funktioniert auch so halbwegs, aber die Kamera schaltet nach dem booten vom display mode nicht immer auf "record" um. Näheres siehe im folgenden script-Ausschnitt:.

#! bin/bash
# MIND THIS:
# This is a b a s h shell script calling chdkptp commands
# ...
# dies funktioniert:
if [ -z "$(lsusb | grep -i "CANON")" ] ; then echo "Cam not present at usb con." ; exit; fi
D=$(pwd)
echo we\'re at\: $D

# Nötig und wichtig:
# gphoto2 abschiessen, falls geladen: funktioniert
sudo $D/killgphoto2access-3.shs
sudo $D/killgphoto2access-3.shs

# ein reboot verbessert nichts:
# -/chdkptp.sh -ec -ereboot
# sleep 3

# U M S C H A L T E N V O N D I S N A C H R E C
# Dies funktioniert leider oft nicht sofort,
# es kommt die chdkptp-Fehlermeldung "SWITCH ERROR" oder so ähnlich
# meistens funktioniert es aber nach dem
# Ausschalten und Wiedereinschalten der Kamera
# (dadurch dann Autoboot von CHDK) dann endlich doch.
Code: Alles auswählen
./chdkptp.sh -ec -erec # switch to recording mode


# diese Umschalte-Version zeigt dasselbe Verhalten:
# luacmd="set_record(1)"
# echo $luacmd >setrecord1.lua
# cat setrecord1.lua
# ./chdkptp.sh -ec -e'luar <setrecord1.lua'
sleep 4
....
# Es folgen weitere Kommandos, die im Prinzip funktionieren.

Hat jemand eine Idee, wie ich das umschalten stabiler hinbekomme?
Ich vermute, dass es irgendwie an dem CHDK in der Kamera liegt, das das Umschaltekommando mal mag und mal nicht, zumal weil Umschaltversuche mit dem chdkptp-GUI auch nicht gehen.
Bin für jeden Hinweis dankbar.
Grüsse von Joedi
P.S. Werde das gesamte Script und die lua-Progs natürlich posten, wenn alles vernünftig läuft.

Ergänzung: Start von CHDKPTP-GUI unter Linux
Hallo, beim Arbeiten mit CHDKPTP-gui, um z.B. Fernsteuerung und "live view" zu haben, gibt es ähnliche Probleme wie oben in den scripts, die chdkptp direkt aufrufen.
Es hat sich deshalb sehr bewährt, CHDKPTP nicht einfach mit
Code: Alles auswählen
./chdkptp_gui.sh

sondern so zu starten:
Code: Alles auswählen
#! /bin/bash
cd /home/jj/chdk-scripts-xp/chdkptp-r785   
# (das Arbeitsverzeichnis entsprechend anpassen)
until  [ -z $(ps -e | grep "gphoto2") ] ;
do
proz=$(ps -e | grep "gphoto2")
prozid=$(echo $proz | cut -d " " -f 1 ) ; echo $prozid ;
echo "muss gekillt werden!!" ; kill $prozid ; echo " - done." ;
done
./chdkptp_gui.sh

Gruss joedi
Zuletzt geändert von Joedi am 28.04.2020, 10:07, insgesamt 1-mal geändert.
Joedi
CHDK-Einsteiger
CHDK-Einsteiger
 
Beiträge: 17
Registriert: 17.02.2020, 21:02
Wohnort: MA/HD
Kamera(s): IXUS60, A470, A530, A570IS, A590IS, SX230, M10

Re: CHDKPTP: Kommando -erec

Beitragvon c_joerg » 20.02.2020, 10:17

Joedi hat geschrieben:Hi, bin neu im Forum, hoffentlich bin ich hier richtig... .

Hallo und herzlich willkommen…

Joedi hat geschrieben:mit: CHDK_DE 1.4.1 Rev. 4530.


Ich würde nur noch die Vorschauversion 1.5 verwenden.

Deine Frage ist schon ziemlich speziell. Ich würde die mal im internationalen Forum stellen.
https://chdk.setepontos.com/index.php

Grüße Jörg
c_joerg
CHDK-Begeisterter
CHDK-Begeisterter
 
Beiträge: 456
Registriert: 14.08.2014, 06:50
Wohnort: Bremen
Kamera(s): S110 103a
S45
2 * G1X 101a, 100e
G9xII 1.00c,
SX230 101a
SX50hs 100c
EOS M3 101a
EOS M100 100a

Re: CHDKPTP: Kommando -erec

Beitragvon Joedi » 02.03.2020, 14:40

Hi Joerg, vielen Dank für die Antwort und die Tips. Sorry, das ist vieleicht etwas linux-lastig, aber vielleicht interessiert's ja doch jemanden...
CHDK pre-1.5 habe ich in der Kamera installiert, das hat aber keine Änderung gebracht. Ich habe deshalb zwei Sachen geändert:
1) Das "abschiessen" der gphoto2-Treiber, die wohl viele Linux-Distributionen automatisch sehr schnell laden (bei mir z.B. Lubuntu, Ubuntu Stodio, aber nicht z.B. Knoppix 7.2), wenn eine Kamera angeschlossen wird (was ja eigentlich nett gement ist...), habe ich noch etwas verbessert.
2) Mein script zwingt praktisch den Benutzer, die Kamera erst einzuschalten, wenn der Mechanismus aus 1) bereit ist.
Dies ist mein derzeitiger "workaround", mit dem jetzt Kamerasteuerungen, Bilderübertragung usw. mit chdkptp funktioniert.
Ich füge mal eine sicher noch verbesserungsfähige Version des scripts bei. Ich finde es schon toll, was man mit chdk und hier speziell mit chdkptp machen kann!
Die nachste Version würde ich dann im internationalen Forum posten.

Gruss joedi

Code: Alles auswählen
#! /bin/bash
# MIND THIS:
# This is a linux BASH shell script calling chdkptp commands
# and has chdkptp execute in turn its commands and therein
# some lua funtions and in partikular a lua motion detect pgm
# (named MOT1XBULBSI.lua) in the camera;
# it then calls chdkptp for downloading the image to the pc,
# and deletes the original in the camera afterwards.
# conceived by Joedi, 2020-02 
echo -e "\n--------------------------------------......--------"
echo "THIS IS $0(.bak9xp2) -RM-Orig-"
echo "WITH  PROG-Name  AND SET-ZOOM (0...7) AS CL PARAM"
echo "---------------------------------------------------------"
# cl-params ($# is number of params):   
if [ "$#" -eq 0 ] ; then  zoom=1; camprogname="MOT1XBULBSI.lua"; fi
if [ "$#" -eq 1 ] ; then  zoom=$1; camprogname="MOT1XBULBSI.lua"; fi
if [ "$#" -eq 2 ] ; then  zoom=$2; camprogname=$1; fi
if [ ! -e $camprogname ] ; then echo $camprogname "not found in $(pwd)"; exit; fi
if [ -n "$(lsusb | grep -i "CANON")" ] ; then
echo -e "camera should NOT be > on < at program start.\n" ; exit; fi
# mind the user to become root!:
if [ $(whoami) != "root" ] ; then echo $0 " to be started as root!"
echo -e "e.g. by typing   sudo $0 [motion.lua] [7]  " ; exit; fi
if [ -z "$(lsusb | grep -i "CANON")" ] ; then
echo "...waiting for camera to be plugged in / switched on ..." ; fi
        while  [ -z "$(lsusb | grep -i "CANON")" ] ; do
        sleep 0.01 
        done
D=$(pwd)
echo we\'re at\: $D

# Erase any gphoto2 processes accessing usb:
:while [ "$(ps -e | grep -i "gphoto2")"  != "" ] ; do 
       proz=$(ps -e | grep "gphoto2" | tail -1) #  last of lines first
       prozid=$(echo $proz | cut -d " " -f 1 )
       echo -n $prozid;   
       echo -n " to be killed ";
       kill $prozid
       echo " - done."
       sleep 1
done
# |----------------------------------------------------------------------
# |Note: firing up chdkptp: some examples from  lit.:                   |
# |-e switch_mode_usb                                                   |
# |-e"rec"                                                              |
# |or:   (spaces separate commands in lua):                             |
# |-e"set_zoom(100) set_mf(1) set_focus(100) shoot() sleep(1000)" -e"play"
# |Basically  the following is supposed to work:                        |
# |chdkptp.sh -e"source myfile.txt"                                     |
# |FOR ME the only safe method seems to be the use of a program file:   |
# |chdkptp.sh -e'luar <myprogfile.lua' # so that´s what I´m using below |
# |<---------------------------------------------------------------------

# Just to be on the safe side, should there be any script running in the cam
./chdkptp.sh -ec -ekillscript # c is connect
 sleep 1
luacmd="set_capture_mode(4)"  # Av-mode; prep cmd for settiing Av mode
echo $luacmd >setcapturemode4.lua
cat setcapturemode4.lua
./chdkptp.sh -ec -e'luar <setcapturemode4.lua'
sleep 1
# SWITCH  TO  RECORDING  MODE
# occasionally, in particular  the switching into record mode didn't work.
# I presume it was due to interference with an unclean remove of
# gphoto2 usb access; often a restart of cam/chdk (power off, then on ) helped
:
# My final workaround now is to essentally force the user to be root and
# not switch the camera on until the scripts runs and chdkptp immediately gets
# a firm hold of the usb interface
# Also, though no visible diff, I changed over from chdk1.4 to pre-1.5 in the cams
# so now:
luacmd="set_record(1)"  #
echo $luacmd >setrecord1.lua
cat setrecord1.lua
./chdkptp.sh -ec -e'luar <setrecord1.lua'
# ./chdkptp.sh -ec -erec # much simpler indeed;...would equally work

sleep 4   # give the lens time to move out

#  SET ZOOM  STEP (as per command line  param)
luacmd="set_zoom($zoom)"  # prepare  a cmd for zoom step
echo $luacmd >setzoomstep.lua
cat setzoomstep.lua
./chdkptp.sh -ec -e'luar <setzoomstep.lua'
sleep 3 # give the lenses time to rearrange

# "displaying the camera display" for a preview of the scene
rm vp_*.ppm # clean-up
rm vffn2.ppm
mycmd="lvdumpimg  -vp  -count=1"  #
echo $mycmd
./chdkptp.sh -ec -e"$mycmd" 
vffn=$(ls vp*.ppm) # get the the file name of the viewfinder image
# correcting the image geometry:
pnmscale -xsize 600 -ysize 400 $vffn >vffn2.ppm
gpicview vffn2.ppm &
# the user will be checking the position of the view:
# the window may be closed by the user to immediately proceed
:sleep  8
# or will be closed afer some 8 seconds
proz=$(ps -e | grep "gpicview")
echo $proz
if [ "$proz" != "" ] ; then
prozid=$(echo $proz | cut -d " " -f 1 )
echo $prozid
kill $prozid
fi

# ---------------------------------------------
# MAIN LOOP: (can be stopped with  ctrl-c only!)
# ---------------------------------------------
while [ "1" = "1" ]
do
# take the time before shooting:
touch timeb4.tem
# starting a program  in the cam now:
# old: ./chdkptp.sh -ec -e'luar <MOT1XBULBSI.lua'
# new:
luacmd="$camprogname"  # prepare the lua cmd argument for use below...
echo $camprogname " running on cam, producing pictures... Use ctrl-c to stop."
 ./chdkptp.sh -ec -e"luar <$camprogname" # works fine!
# when  program finishes, we want the pictures:
echo "image transfer to PC now in progress"
# start the image downoad,  -rm  deletes the  original:
 ./chdkptp.sh -ec -eimdl'-last=1 -rm' -equit

# Now show newest pic sent from cam
# 1 close previous display
proz=$(ps -e | grep "gpicview")
echo $proz
if [ "$proz" != "" ] ; then
prozid=$(echo $proz | cut -d " " -f 1 )
echo $prozid
kill $prozid
fi
# 2 find newest file name; there should be only one...
lastfn=$(find $D -maxdepth 2 -anewer timeb4.tem -a -name "IM*.JPG")
echo $lastfn
# 3 dispiay it:
gpicview $lastfn &
if [ -z "$(lsusb | grep -i "CANON")" ] ; then echo "Cam disconnected from usb" ; exit; fi
done
# end of main loop --------------------------------------------------
Joedi
CHDK-Einsteiger
CHDK-Einsteiger
 
Beiträge: 17
Registriert: 17.02.2020, 21:02
Wohnort: MA/HD
Kamera(s): IXUS60, A470, A530, A570IS, A590IS, SX230, M10


Zurück zu Probleme

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 8 Gäste