Are these software upgrades possible? - page 4 - General Help and Assistance on using CHDK stable releases - CHDK Forum

Are these software upgrades possible?

  • 187 Replies
  • 36722 Views
*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #30 on: 07 / May / 2011, 20:37:02 »
Advertisements
OK,
Code: [Select]
!chdku.downloaddir("A/DCIM/100_0507","C:/IMG")works. Is it possible to make it even better by making it automatically parse through all subdirectories so that you could give it a command like this:
Code: [Select]
!chdku.downloaddir("A/DCIM/","C:/IMG") This way you don't have to figure out what the folder is called. Is this possible?
Recursing through the directories is possible. As I mentioned previously, chdkptp does not currently have the capability to create directories on the PC side, so it can't duplicate the directory structure. I do plan to add this at some point, along with functions for recursive download. I don't have any schedule.

In the meantime, you could build filenames from the directory names, so e.g.
A/DCIM/100_0507/IMG_0001.JPG becomes 100_0507_IMG_0001.JPG or IMG_100_0507_0001.JPG or whatever.

Implementing this is left as an exercise to the reader ;)

Quote
So it is possible for it to work correctly. Maybe comparing your code to ptpcam's reboot code will shed light on what the differences are.
Sigh. As I already said: .reboot() does exactly the same thing ptpcam "reboot" does.
ptpcam reboot just runs "reboot();" as lua on the camera. chdkptp .reboot() does the same thing
ptpcam sleeps 2 seconds and tries to reconnect automatically.
chdkptp doesn't try to reconnect automatically.

The only difference I see is that chdkptp will try to disconnect first when you do 'c', since it doesn't know the connection has gone away.

You can try this, which should emulate ptpcam more closely.
con> .sleep(3000); reboot()
con> dis
(wait for camera to reboot)
___> c

The sleep(3000) waits 3 seconds before rebooting. You will need to do the dis command before that time is up.
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #31 on: 07 / May / 2011, 20:48:54 »
Code: [Select]
con> .sleep(3000); reboot()
con> dis
(wait for camera to reboot)
___> c
that works repeatedly. It takes more steps than ptpcam but it works.

Quote
chdkptp does not currently have the capability to create directories on the PC side
that's fine but I need it to take this command:
Code: [Select]
!chdku.downloaddir("A/DCIM/","C:/IMG")and automatically search the sub-fiolders it finds too. Can we modify it to do that? or does it already do that?

*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #32 on: 07 / May / 2011, 21:07:12 »
that works repeatedly. It takes more steps than ptpcam but it works.
OK, thanks for confirming that. Cleaning up connected state detection is already on my TODO list, but I'll add a reboot command that does this automatically for now.
Quote
that's fine but I need it to take this command:
Code: [Select]
!chdku.downloaddir("A/DCIM/","C:/IMG")and automatically search the sub-fiolders it finds too.
If you download files from multiple canon directories into a single directory on the PC, you risk having more than one file with the same name. Therefore, you need to do *something* with the folder names.
Quote
Can we modify it to do that?
It would be relatively easy to make a functions that downloads multiple directories. Basically all you have to do is listdir A/DCIM, then iterate over that list calling downloaddir on each result. If you want to handle name collisions, you have to modify downloaddir slightly as well. Will I do it right now ? Probably not, I've already wasted a bunch of time today finding your typos. You have the code if you want to do it.

I will eventually add recursive downloads to chdkptp.
Quote
or does it already do that?
No.
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #33 on: 07 / May / 2011, 21:26:06 »
Quote
you risk having more than one file with the same name.
I should'nt have to worry about that. I would just set file naming to continuous in the canon firmware. The folder naming is predictable so for now, even though the code will be tedious, I can have the C# app figure out the folder name. it is always 100_mmdd. So 100_0507 is May 7th.

Quote
I've already wasted a bunch of time today finding your typos.
I am a very skilled typoist.


*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #34 on: 07 / May / 2011, 22:13:04 »
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #35 on: 07 / May / 2011, 22:49:32 »
I added the reboot command http://trac.assembla.com/chdkptp/changeset/51
I tested that and it works fine also.

I ran into a small problem. The set_zoom command (for example lua set_zoom=4) doesn't do anything. I have to use .click "zoom_in" which would be fine but it is really, really slow. Each command moves it the tiniest amount. Am I doing something wrong? Never mind. lua set_zoom(4) messes up the focus. It is better to use :
.press "zoom_in"; sleep(1000); release "zoom_in"
« Last Edit: 07 / May / 2011, 23:02:18 by John1234 »

*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #36 on: 07 / May / 2011, 23:03:40 »
I added the reboot command http://trac.assembla.com/chdkptp/changeset/51
I tested that and it works fine also.

I ran into a small problem. The set_zoom command (for example lua set_zoom=4) doesn't do anything.
That is not correct lua syntax. You are changing the value of set_zoom from a function to the number 4 ;)

You would want set_zoom(4)

Quote
I have to use .click "zoom_in" which would be fine but it is really, really slow. Each command moves it the tiniest amount. Am I doing something wrong?
No, on cameras with lots of zooms steps that's how it is. You can do something like
press("zoom_in"); sleep(500); release("zoom_in")
but from what I remember you can't monitor the zoom level until the key is released (get_zoom doesn't update), so you'd just have to guess the delay. You might be able to use that to get close, then use single steps to finish it off.

If the camera has two zoom speeds, that can also confuse things.
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #37 on: 07 / May / 2011, 23:43:17 »
ran into another issue. The destination directory path for !chdku.downloaddir() has spaces in it and it is fairly long (8 folders deep). Are the spaces preventing the function from working (because the command doesn't do anything)?

EDIT: spaces don't seem to matter..
EDIT: Fixed it. There can't be a foreward slash after the last folder name in the source directory.
« Last Edit: 07 / May / 2011, 23:49:22 by John1234 »


Re: Are these software upgrades possible?
« Reply #38 on: 11 / May / 2011, 21:54:20 »
Can we modify chdkptp so that it shows a time stamp (in 24hr time) every time a command is executed? it would be like this:
con 1 14:45> .click "shoot_full"
con 2 14:48> press("zoom_in"); sleep(1500); release("zoom_in")
etc.

This would really aid in debugging the timing of the sent commands. For example: sometimes the camera isn't given enough time to download all of the photos before it is told to delete them all (which crashes it). But here are several other possible crash points. I've got the whole thing implemented now but I'll come back the next day and the camera will have crashed. I have no idea when or why it happened though. time stamps would help a great deal.

*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #39 on: 11 / May / 2011, 23:09:07 »
What do you mean we kemosabe ? ;)

I'm not going to modify it specifically for your project, but you are certainly welcome to do it yourself

http://trac.assembla.com/chdkptp/browser/trunk/lua/cli.lua

cli:prompt is the function you want to change, os.date ( http://www.lua.org/manual/5.1/manual.html#5.8 ) will give you date/time in just about any format you could want.

You can actually override this from the CLI, e.g.
Code: [Select]
!cli.prompt=function() printf("con %s %s %s> ",tostring(chdk.is_connected()),tostring(chdk.get_script_id()),os.date('%H:%M:%S')) end

I used tostring on is_connected and script id because I didn't want type all the ifs on one line, but you can put whatever you want in there.
Don't forget what the H stands for.

 

Related Topics