chdkptp - alternative ptp client

  • 989 Replies
  • 137622 Views
*

Offline reyalp

  • ******
  • 10863
Re: chdkptp - alternative ptp client
« Reply #980 on: 10 / October / 2017, 23:52:03 »
Advertisements
Is it possible to modify "gui.lua" to be able to control touch-screen
models (such as IXUS 240 HS) with mouse clicking on UI Overlay screen?
Oops, I meant to respond to this earlier. Better late then never I guess...

This is a good idea, and would definitely be nice on cameras with tap to focus. Unfortunately, CHDK doesn't currently have the ability to simulate touch inputs (AFAIK... philmoz or waterwingz correct me if I'm wrong). It's possible something could be done with post_logical_event_to_ui. There are various touch related levents, but I don't know how coordinates are handled if they are usable at all.
Don't forget what the H stands for.

Re: chdkptp - alternative ptp client
« Reply #981 on: 12 / October / 2017, 00:11:05 »
Unfortunately, CHDK doesn't currently have the ability to simulate touch inputs (AFAIK... philmoz or waterwingz correct me if I'm wrong).
The Powershot N code intercepts touch events differently from philmoz's implemention (mostly because the Canon code was very different and I could not copy philmoz's original work). But AFAIK the result is pretty much the same. 

When active in <ALT> mode, the code interrupts the Canon firmware's touch processing software,  steals the x-y position of a touch, and prevents that touch from being passed to the Canon firmware for processing.

While it might be possible to inject a "touch" into the system at the point where it's hacked out,  I'm pretty sure that would not work - for a bunch of reasons. So adding the ability to create a "virtual touch" would be a new development project.  Not a huge effort compared to the original stuff srsa_4c does, but work none the less.

tl;dr : you are correct - not currently available.
Quote
It's possible something could be done with post_logical_event_to_ui. There are various touch related levents, but I don't know how coordinates are handled if they are usable at all.
That would be one approach to try prior to creating a lower level touch event insertion attempt.
Ported : A1200  SD940  G10  Powershot N  G16*

Re: chdkptp - alternative ptp client
« Reply #982 on: 19 / October / 2017, 17:06:35 »
My apologies for not reading this entire thread. I have tried searching and read about half of the General discussion thread. And of course I am humbled by the depth of knowledge I see here.
I have a few SD990ISs I am running CHDK ver 1.5. (I think.) CHDKPTP ver Host 2.7 cam2.8.
I would like to be able to do a time lapse from the computer with the pictures downloading, either as they are taken or in batches at night. I can’t seem to get ultimate.lua to work from CHDKPTP. It works great on the camera if executed from the camera. I need to bea able to control these remotely without touching the camera every day, sometimes for weeks.
If I start it with “.<ultimate.lua” or =<ultimate.lua I get a:142 attempt to perform arithmetic on global ‘start_hr’ (a nil value) ***TERMINATED*** error.
I have tried grouping commands and using source to call them but as I read somewhere in one of these threads the script takes time to complete and the next command tries to execute and fails.
Is there a way to get a modified ultimate.lua to execute so I could take pictures during the day and have the pictures download at night, automated of course. I can’t seem to figure out a sleep command in a source file that will make the camera wait between remoteshoot commands.

thanks

*

Offline reyalp

  • ******
  • 10863
Re: chdkptp - alternative ptp client
« Reply #983 on: 19 / October / 2017, 18:09:15 »
If I start it with “.<ultimate.lua” or =<ultimate.lua I get a:142 attempt to perform arithmetic on global ‘start_hr’ (a nil value) ***TERMINATED*** error.
This happens because the variables set by the CHDK script menu parameters aren't defined when you run it using chdkptp.

You can get around them by defining them yourself, but in this case you can't use the < shortcut because you need additional code.

If you the script is on the camera, you can do something like
Code: [Select]
.start_hr=1 [...similar code for all the other options in the script header...] loadfile('A/CHDK/SCRIPTS/ultimate.lua')()
You could also modify ultimate.lua to check if one of the menu options is nil, and set defaults.

Note in either case  the script has a lot of options and you'll need to translate them from CHDK menu syntax: http://chdk.wikia.com/wiki/CHDK_Script_Header

I know ultimate has some capability to support PTP download, but IIRC the original concept was the USB would only occasionally be plugged in to download, rather than the script being initiated over USB and constantly connected. Maybe waterwingz can elaborate.

Depending on your requirements, you might also consider using a chdkptp side script without involving ultimate at all. In that case, you could write a loop that shoots during the day and downloads everything at the end, or just downloads each shot as it's taken.
Don't forget what the H stands for.


Re: chdkptp - alternative ptp client
« Reply #984 on: 19 / October / 2017, 18:55:49 »
You could also modify ultimate.lua to check if one of the menu options is nil, and set defaults.  Note in either case  the script has a lot of options and you'll need to translate them from CHDK menu syntax : http://chdk.wikia.com/wiki/CHDK_Script_Header
I'll look at augmenting the code - the checking for nil idea is clever and makes for a nice side effect free upgrade to the code! Thanks for that idea.

Quote
I know ultimate has some capability to support PTP download, but IIRC the original concept was the USB would only occasionally be plugged in to download, rather than the script being initiated over USB and constantly connected. Maybe waterwingz can elaborate.
Yea - that was pretty much the idea.  Start the script by pressing the shutter button and then let the script & camera do its thing unattended.  Connect via USB to semi-regularly to download images.  IIRC "regularly" might have been every few weeks at a really remote bird nest on an island but daily would work just as well.

Quote
Depending on your requirements, you might also consider using a chdkptp side script without involving ultimate at all. In that case, you could write a loop that shoots during the day and downloads everything at the end, or just downloads each shot as it's taken.
This is probably the best option if you have a PC that you can leave powered up 24x7.  From a reliability standpoint I'd bet on a battery backed up camera running longer that any PC solution.  But then, having done both, I'm a little biased.

Ported : A1200  SD940  G10  Powershot N  G16*

Re: chdkptp - alternative ptp client
« Reply #985 on: 19 / October / 2017, 21:48:52 »
Thanks for your quick and helpful response.
I suspected that they are undefined variables. I added a line: start_hr = 6 right before it is math-ed into another variable and sure enough it the error moves onto start_min, and then moves on each time I set a parameter. But I wanted to check with the experts before I go and modify the whole program. This solves the first issue. Thanks!
I will probably modify ‘ultimate’ to only shoot for a day and exit this way I can now fiddle with the next problem.
Is there a way to Sleep in either lua executed on the computer or from the CLI? I am sure you know where I am going with this. (I am assuming that I can’t ‘push’ the pictures from the camera to the computer with lua via CHDKPTP so I am attempting to ‘pull’ them with CHDKPTP.
Here is pseudo code for what I want to do:
if Time between 5am and 11pm {execute ultimateModifiedForOneDayOnly (next command waits until this is done. Is that possible?)}
if Time between 11pm and 5am {download and delete all images from camera, and then sleep until 5am}
repeat as needed
Or
if Time between 5am and 11pm
 {
  remoteshoot
  sleep(x)
  }
if Time between 11pm and 5am {sleep}

thanks much

Re: chdkptp - alternative ptp client
« Reply #986 on: 19 / October / 2017, 22:00:57 »
I suspected that they are undefined variables.
Well, sort of.  When a CHDK script running normally, they are not undefined as the header code defines them.  It's part of the CHDK specification for Lua and legal syntax.  The issues is how chdkptp runs scripts and how it ignores the standard CHDK first pass Lua initialization. Which leads to something that looks like undefined variables in the script code.

Quote
I added a line: start_hr = 6 right before it is math-ed into another variable and sure enough it the error moves onto start_min, and then moves on each time I set a parameter.
You understand this correctly.  reyalp's suggestion was to bracket the additional code with a test to see if the first user parameter in the list shows up as undefined, and if so then manually set each one individually as you suggest here.

Quote
I will probably modify ‘ultimate’ to only shoot for a day and exit this way I can now fiddle with the next problem.
That's the really nice part about CHDK script - you can modify on the fly to your heart's content with minimal effort.

Quote
Is there a way to Sleep in either lua executed on the computer or from the CLI? I am sure you know where I am going with this. (I am assuming that I can’t ‘push’ the pictures from the camera to the computer with lua via CHDKPTP so I am attempting to ‘pull’ them with CHDKPTP.
Here is pseudo code for what I want to do:
if Time between 5am and 11pm {execute ultimateModifiedForOneDayOnly (next command waits until this is done. Is that possible?)}
if Time between 11pm and 5am {download and delete all images from camera, and then sleep until 5am}
repeat as needed
Or
if Time between 5am and 11pm
 {
  remoteshoot
  sleep(x)
  }
if Time between 11pm and 5am {sleep}
Ummm .. I'll leave this one to reyalp.
Ported : A1200  SD940  G10  Powershot N  G16*

Re: chdkptp - alternative ptp client
« Reply #987 on: 19 / October / 2017, 22:05:57 »
Quote
Yea - that was pretty much the idea.  Start the script by pressing the shutter button and then let the script & camera do its thing unattended.  Connect via USB to semi-regularly to download images.  IIRC "regularly" might have been every few weeks at a really remote bird nest on an island but daily would work just as well.

Let's call this a "really remote bird nest on an island" with an internet connection and an ac power adapter for the camera. Therefore I can't go touch anything for weeks at a time and the SD card can't hold more than a day's worth of pix. (Actually on some of my locations I don't have an internet connection, just a big battery powering the laptop and camera. But still can't visit but every week or so)


Quote
Depending on your requirements, you might also consider using a chdkptp side script without involving ultimate at all. In that case, you could write a loop that shoots during the day and downloads everything at the end, or just downloads each shot as it's taken.
This is probably the best option if you have a PC that you can leave powered up 24x7.  From a reliability standpoint I'd bet on a battery backed up camera running longer that any PC solution.  But then, having done both, I'm a little biased.
This solution sounds interesting. I just need the sleep syntax. thanks


*

Offline reyalp

  • ******
  • 10863
Re: chdkptp - alternative ptp client
« Reply #988 on: 20 / October / 2017, 00:17:51 »
This solution sounds interesting. I just need the sleep syntax. thanks
In chdkptp, you can use sys.sleep() to wait for a given number of milliseconds. You can use Lua standard os.date(), os.time() and os.difftime (http://www.lua.org/manual/5.2/manual.html#6.9) to do various things with time and date.

See https://app.assembla.com/spaces/chdkptp/wiki/Scripting_Guide for some general information about scripting chdkptp.

Quote
if Time between 5am and 11pm {execute ultimateModifiedForOneDayOnly (next command waits until this is done. Is that possible?)}
if Time between 11pm and 5am {download and delete all images from camera, and then sleep until 5am}
For a once (or a few times) per a day command, you might consider just using OS scheduling (cron on *nix, windows task scheduler) to run chdkptp. If you pass commands with -e it will run them and exit when complete. So you could have a job that runs at 5 AM and does
chdkptp -c -e"lua loadfile('A/CHDK/SCRIPTS/ultimate.lua')()"

and another that runs at 11:00 PM
chdkptp -c -e"imdl -rm"

It is possible to check if a script is running on the camera, but it might be simpler to just set up the scheduling so ultimate quits before the download runs.

Quote
if Time between 5am and 11pm
 {
  remoteshoot
  sleep(x)
  }
In chdkptp lua you could do this something like
Code: [Select]
interval = 1000*60*10 -- 10 minutes in milliseconds
while true do
 local hour=os.date('*t').hour
 if hour >= 5 and hour <23 do
   cli:execute('remoteshot')
 end
 sys.sleep(interval)
end

This would go in a file (say, myfile.lua) which you could run in chdkptp with
chdkptp -e"exec dofile('myfile.lua')"

caveats:
1) This is untested, off the top of my head
2) No way is provided to gracefully exit, to stop it you'd have to control+C or kill the process

A more complete example of this kind of approach can be found in https://chdk.setepontos.com/index.php?topic=13261.msg134971#msg134971


Don't forget what the H stands for.

Re: chdkptp - alternative ptp client
« Reply #989 on: 21 / October / 2017, 00:37:13 »
thanks so much. I will try these ideas.

 

Related Topics