Intricacies of chdkptp and the S95 - General Help and Assistance on using CHDK stable releases - CHDK Forum  

Intricacies of chdkptp and the S95

  • 4 Replies
  • 4147 Views
Intricacies of chdkptp and the S95
« on: 22 / August / 2011, 23:54:26 »
Advertisements
Ok, I'm learning a lot here. With the kind help of reyalp and a couple wiki pages like http://chdk.wikia.com/wiki/UBASIC/TutorialScratchpad, I'm getting to where I need to be with controlling my S95 from my Linux computer.

So far I've gotten the camera to display "hello world" through chdkptp with something like this:

Code: [Select]
$ ./chdkptp -i
___> c
con> lua print "hello, world" sleep "1000"

But what I can't do (using the S95) is get it to capture an image through chdkptp, maybe I'm going about it the wrong way?

Code: [Select]
con> lua shoot
ERROR: :68: '=' expected near '<eof>'
user code: 1

I thought that was the correct syntax for lua to capture. Even when I try to simulate the button press to capture an image, it doesn't do anything, though:

Code: [Select]
con> lua click "shoot_full"

But then nothing happens. Now the camera starts up in playback mode, so I imagine I would have to set it to record mode for it to be able to take a picture, right? I haven't seen anywhere that has the syntax to do that in lua or through chdkptp, though.

I usually have the camera turned off, then plug into the computer, then turn on, and that starts it up in playback mode. But even if I turn it on and switch it to record mode (usually just by pressing the capture button) and then plug it into the computer, once it's plugged in, it goes to playback mode. When it's in playback mode (or whatever mode it's in when it's plugged in), even when I push the capture button on the camera to try to put it in record mode, nothing happens except a counter in the upper right part of the LCD screen shows up and increments each time.

So obviously I'm pretty new to this and any help would be greatly appreciated. Basically I just need to be able to capture and download pictures in Linux via the command line. Eventually I would like to get into setting parameters like ISO, shutter speed, etc from the computer as well, but baby steps for now.

Re: Intricacies of chdkptp and the S95
« Reply #1 on: 23 / August / 2011, 16:21:56 »
Ok, been trying some other stuff since my last post, I finally found the wiki page http://chdk.wikia.com/wiki/Script_commands and I've been trying to pass some of those through chdkptp to see what happens.

First off, I think I solved the first problem in my last post by sticking parentheses after shoot:

Code: [Select]
lua shoot()

But nothing happens when that runs. I've even tried "luar shoot()" but it just hangs.

I've tried to use set_record(1) and get_mode() to try to put the camera into record mode, but nothing seems to happen with those, either.

I've tried using the CHDK version of ptpcam, but it's showing some strange behavior, too. When I do "luar get_mode()" right after I connect to the camera, it returns "false" which I'm assuming means that it is in playback mode (0, according to that wiki page). Then when I try to do "luar set_record(1)" and then "luar get_mode()" it returns an error: "unexpected return code 0x2fe while retrieving result execution failed!".

I just need chdkptp or ptpcam to be able to capture a picture and then download it for me, so any help in that direction would be great!

*

Offline reyalp

  • ******
  • 14117
Re: Intricacies of chdkptp and the S95
« Reply #2 on: 24 / August / 2011, 01:06:55 »
You need to use switch_mode_usb(1) instead of set_record to get into record mode. Yes, this doesn't make much sense ;)

See http://chdk.wikia.com/wiki/Lua/PTP_Scripting
Don't forget what the H stands for.

Re: Intricacies of chdkptp and the S95
« Reply #3 on: 24 / August / 2011, 13:06:53 »
Thank you!

Now I wonder, is there a way to check to see if the camera is currently taking a picture or a script is currently running through chdkptp? For example, say I want to take a picture (./chdkptp -ec -e"lua shoot()" is working fine for me), then download it as soon as possible. I don't see anything right now that allows me to know how long it took for a picture to be taken or to know if the camera is ready to take another picture again.

I do see this note on the Lua/PTP wiki page:
Quote
To check whether your script has terminated, you can use the script status command (script-status in ptpcam.)
But I see no information on how to actually use script-status.
« Last Edit: 24 / August / 2011, 13:12:53 by jmonty »


*

Offline reyalp

  • ******
  • 14117
Re: Intricacies of chdkptp and the S95
« Reply #4 on: 25 / August / 2011, 01:24:56 »
If you use luar , it will wait until the function completes.

The chdkptp cli doesn't expose script_status direclty but you can call it from PC side lua in chdkptp. E.g.
Code: [Select]
con> exec return con:script_status()
={
 run=false,
 msg=false,
}
You can find examples of the PC side lua API in the lua/ directory, especially in cli.lua and chdku.lua. The C part of the API is documented in chdkptp.c

Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal