chdkptp - alternative ptp client - page 28 - General Discussion and Assistance - CHDK Forum

chdkptp - alternative ptp client

  • 1106 Replies
  • 551894 Views
*

Offline reyalp

  • ******
  • 14118
Re: alternative ptp client
« Reply #270 on: 28 / October / 2012, 16:36:32 »
Advertisements
3. Pressed "play"
I was referring to the physical play/rec switch on the camera, not the chdkptp UI. Looking at pictures of this camera online, it looks like the switch doesn't stay in play/rec position. In that case, you should power it on initially using play rather than rec.

From your screenshot, everything appears to be working correctly. Did it hang after 'switch_mode_usb(1)' ?
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #271 on: 29 / October / 2012, 12:36:38 »
Yes, it did hang after 'switch_mode_usb(1)'.
When I connect the usb-cable to the camera, it always gets in to a "unresponsive play-mode" (it doesn't matter if I power it on using rec or play).
I can see the latest picture on the lcd but can't use any buttons on the camera.

Re: alternative ptp client
« Reply #272 on: 12 / December / 2012, 06:03:44 »
Hi,

I'm trying to use the chdkptp client on Raspbian, but from the command line.

Is it possible to use chdkptp without the GUI?

When I try to run it is just gives

Code: [Select]
starting gui...
pcall failed 2
error IupOpen: could not initialize
PANIC: unprotected error in call to Lua API (attempt to index a nil value)

Which is understandable since it won't open the GUI over SSH.

*

Offline nafraf

  • *****
  • 1308
Re: alternative ptp client
« Reply #273 on: 12 / December / 2012, 07:08:13 »
Hi, try with chdkptp -i
Code: [Select]
CHDK PTP control utility
Usage: chdkptp [options]
Options:
 -g  start GUI - default if GUI available and no options given
 -i  start interactive cli
 -c  connect at startup, with optional device spec e.g. -c"-d001 -bbus-0"
 -e  execute cli command, multiple allowed, e.g -e"u DISKBOOT.BIN" -ereboot
 -r  specify startup command file, if no file given skip default startup files
 -h  help


Re: alternative ptp client
« Reply #274 on: 12 / December / 2012, 11:08:37 »
Thanks for the reply.

That worked and it is chdkptp is working well with my Canon Ixus 220 HS (ELPH 300)



Next question..... is it possible when taking a photo via chdkptp to tell the camera to write the photo to a certain filename in a certain directory? Or will they always end up in DCIM/1xx_xxxx/IMG_xxxx.JPG style?

Re: alternative ptp client
« Reply #275 on: 12 / December / 2012, 14:50:30 »
Are there any tips on how to construct a command line command with chdkptp?

I can do everything I want via separate commands but I'd like to automate it via one bash script.

It's pretty simple...

Code: [Select]
sudo sh /home/pi/chdkptp/chdkptp-sample.sh -i -c
The commands I want to run are....

Code: [Select]
lua switch_mode_usb(1)
lua set_zoom(0)
lua shoot()
lua switch_mode_usb(0)
dis
quit

I can start by running

Code: [Select]
sudo sh /home/pi/chdkptp/chdkptp-sample.sh -i -c -e"lua switch_mode_usb(1)"
but how do I add the other commands?

Code: [Select]
sudo sh /home/pi/chdkptp/chdkptp-sample.sh -i -c -e"lua switch_mode_usb(1)" -e"lua set_zoom(0)" etc etc
doesn't seem to work.

*

Offline reyalp

  • ******
  • 14118
Re: alternative ptp client
« Reply #276 on: 12 / December / 2012, 23:53:46 »
I can start by running

Code: [Select]
sudo sh /home/pi/chdkptp/chdkptp-sample.sh -i -c -e"lua switch_mode_usb(1)"
but how do I add the other commands?

Code: [Select]
sudo sh /home/pi/chdkptp/chdkptp-sample.sh -i -c -e"lua switch_mode_usb(1)" -e"lua set_zoom(0)" etc etc
doesn't seem to work.
"doesn't seem to work" in what way?

You can use multiple -e commands from the command line. In that case, you don't need -i, which would leave it in interactive mode after the -e commands complete. The gui only tries to start if there are no command line options at all, if there's just -e commands it runs in batch mode, which executes all the -e commands and then exits. You also don't need dis, it will automatically close any open connections when it exits.

You can also make a file of chdkptp commands and run that with the 'source' cli command or the -r commandline option. see USAGE.TXT for more details.

You may have trouble doing  switch_mode_usb and set_zoom too close together.  The camera needs some time to actually switch modes, and may not be ready to move the zoom for some time after switch_mode_usb() finishes. You can use sys.sleep on the chdkptp side to force a delay, e.g.
exec sys.sleep(1000)
will wait one second.

Another problem you might have is that the 'lua' command does not wait for the script to finish on the camera, so may get an error that a script is already running. Use luar to wait for the script to complete on the camera. Or you could put all your camera commands in a single lua call, like

lua switch_mode_usb(1); set_zoom(0); shoot(); switch_mode_usb(0)

If you need delay between them, you can use sleep(<milliseconds>) in camera side lua.
Don't forget what the H stands for.

Re: alternative ptp client
« Reply #277 on: 13 / December / 2012, 05:54:13 »
Thanks for the reply. I should've given some more detail.

The error was that there was already a script running. I guess it was an issue with not giving it enough time.

I'll try the sleep suggestion when I get chance. Thanks for the tips and advice, it's appreciated.


Re: alternative ptp client
« Reply #278 on: 13 / December / 2012, 14:01:50 »
luar instead of lua works great. Thanks for that!

Next question.....

In USAGE.TXT for the command "download" (or d) it states that if a destination directory isn't stated it will download to the current directory.

I am trying to do

Code: [Select]
d DCIM
to download the DCIM folder. The error I get is

Code: [Select]
ERROR: A/DCIM is not a file
So I assume without stating a destination this is only possible for files? Not folders?

Is it also not possible to download a folder using "mdl" without stating a destination?

Am I right in thinking I can't use the matching feature of mdl with d?

*

Offline reyalp

  • ******
  • 14118
Re: alternative ptp client
« Reply #279 on: 13 / December / 2012, 22:34:16 »
Code: [Select]
d DCIM
to download the DCIM folder. The error I get is

Code: [Select]
ERROR: A/DCIM is not a file
the download command only operates on files, it doesn't know how do anything with directories, it just downloads a single file.
Quote
Is it also not possible to download a folder using "mdl" without stating a destination?
No, mdl accepts multiple source files or directories, so
Code: [Select]
mdl foo bar
would be ambiguous if the destination were optional. You can use . for the current directory, but any sub directories recursed into will be created as subdirectories in the destination.

Quote
Am I right in thinking I can't use the matching feature of mdl with d?
Correct. d is a bare bones interface to the chdk download API call. mdl is the bells and whistles version.

If you are up to writing some lua code, you can make your own custom download function to do whatever you want. The discussion in this thread http://chdk.setepontos.com/index.php?topic=8613.msg90496#msg90496 may help you get started.
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal