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

Are these software upgrades possible?

  • 187 Replies
  • 36723 Views
*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #20 on: 06 / May / 2011, 23:22:02 »
Advertisements
3. Solve Power issue. ptpcam reboot commands just make the camera go black and hang. batteries have to be removed to fix it.
Maybe it's broken on your cameras build. You can try lua reboot("A/PS.FI2") and see if that works any better. (assuming you have a PS.FI2 for your cam)
Quote
4. download all media from camera. You can download individual files only IF you know their full file name. need a better solution...
Code: [Select]
./chdkptp -c -i
con 9> !t=chdku.listdir('A/DCIM/100CANON',{match=".JPG$"})
con 10> !for i,n in ipairs(t) do chdk.download("A/DCIM/100CANON/"..n,"img/"..n) end
Quote
I looked at your chdkptp project but didn't notice any extra functionality over what I already have.
You're sure ? OK :D

edit: above is using lua files from current svn head, not sure whats in the binary packages will work, but you can just replace the .lua files.
Quote
5. ability to change capmode. Where is the direct link to downlaod that specific library and where specifically do i put it on the SD card? What other specific steps, if any, have to be done to be able to use those commands?
As I said, capmode.lua is included in the standard full zips. If you didn't get one with your build, can use one from another camera and just replace the diskboot.bin and PS.FI2 with the ones from your port. The stuff you need is in CHDK/LUALIB

Once you have that you can use
lua require('capmode').set('VIDEO_STD')
You must be in record mode first. You can do that with
lua switch_mode_usb(1)
« Last Edit: 06 / May / 2011, 23:30:13 by reyalp »
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #21 on: 07 / May / 2011, 00:51:47 »
Quote
Maybe it's broken on your cameras build. You can try lua reboot("A/PS.FI2") and see if that works any better. (assuming you have a PS.FI2 for your cam)
I do have a PS.F12 but there is no response at all from that command. I double checked that I typed it correctly too. The only thing on the SD card is a .BIN file and the PS.F12 file. UPDATE: I took the CHDK folder from the SX100 build and put that on the SD card. the lua reboot("A/PS.FI2") command still doesn't do anything but the normal reboot command works so that is solved now. 2 more issues left.

I understand what the code you posted does (look in this directory for any files with .jpg extension and download each one, one by one) but what am I supposed to do with the code? It doesn't look like lua syntax.

Here are the commands available in ptpcam that I'm using:
Code: [Select]
q quit                         quit program
h help                         list commands
r reset                        reconnect to camera
  version                      get CHDK PTP version (ptpcam and camera)
  shutdown                     shutdown camera (soft)
  reboot                       reboot camera
  reboot <filename>            reboot camera using specified firmware update
  reboot-fi2                   reboot camera using default firmware update
m memory <address>             get byte at address
m memory <address>-<address>   get bytes at given range
m memory <address> <num>       get num bytes at given address
  set <address> <long>         set long value at address
c call <address> <arg1> ...    call function at address with given arguments
  upload <local> <remote>      upload local file to camera
  download <remote> <local>    download file from camera
  mode <val>                   set mode (0=playback,1=record)
  lua <code>                   execute lua code
  luar <code>                  execute "return <code>" and retreive result
  script-support               show supported script interfaces
  script-status                show script execution and message status
  getm                         get messages / return values from script
  putm <message>               send <message> to running script
and here are the commands available in your version:
Code: [Select]
The following CLI commands are available. () indicate short names for the commands
help (h,?)   [command]   : - help on [command] or all commands
#                        : - comment
exec (!)     <lua code>  : - execute local lua
quit (q)                 : - quit program
lua (l,.)    <lua code>  : - execute remote lua
getm                     : - get messages
putm         <msg string>: - send message
luar (=)     <lua code>  : - execute remote lua, wait for result
rmem         <address> [count]: -  read memory
list                     : - list devices
upload (u)   <local> [remote]: - upload a file to the camera
download (d) <remote> [local]: - download a file from the camera
version (ver)             : - print API versions
connect (c)              : - (re)connect to device
disconnect (dis)             : - disconnect from device
ls           [-l] [path] : - list files/directories on camera
I don't see any added ability vs what I'm already using. Your gui is nice but it is of absolutely no use in what I'm trying to do.

Quote
lua require('capmode').set('VIDEO_STD')
Awesome. That works (now that I have the CHDK folder uploaded). I just guessed that lua require('capmode').set('TV') would put it back in Tv mode and that worked too.

So to recap:
1. C# software tells the camera when to press the shutter button.    -DONE-
2. ability to delete all media from SD card without user intervention. -DONE-
3. Solve Power issue. (periodically send reboot command)                -DONE-
4. ability to change capmode.                                                        -DONE-
5. download all media from camera.

*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #22 on: 07 / May / 2011, 01:16:00 »
I understand what the code you posted does (look in this directory for any files with .jpg extension and download each one, one by one) but what am I supposed to do with the code? It doesn't look like lua syntax.
The two lines I pasted go directly in the chdkptp cli. With these two commands, I downloaded ~100 jpegs.
Quote
Code: [Select]
exec (!)     <lua code>  : - execute local lua
Everything after the ! is lua, executed locally in chdkptp, not on the camera.

chdk.* provides access to the CHDK PTP protocol, chdku.* is some higher level helper functions I've written in lua to make it more convenient. In particular, it can transparently take lua values returned by camera side lua, and use them in chdkptp lua.

Documentation may be found in the source.

Quote
I don't see any added ability vs what I'm already using.
Other than "download all media from camera" ? ;)
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #23 on: 07 / May / 2011, 10:36:29 »
I got an error:
Code: [Select]
con> !t=chdku.listdir('A/DCIM/100_0507',{match=".JPG$"})
con 1> !for i,n in ipiars(t) do chdk.download("A/DCIM/100_0507/"..n,"img/"..n) end
ERROR: call failed:[string "for i,n in ipiars(t) do chdk.download("A/DC..."]:1:
attempt to call global 'ipiars' (a nil value)

con 1>
1. Can you modify it so that you just type something simple like: downlaod_all_media(<destinationDir>) and it would automatically look in "A/DCIM" and all of its subdirectories and download anything that is a .jpg or .mov (or whatever format it uses for movies) while keeping the directory structure, and automatically handling any duplicate file issues?

2. I can't get any sort of reboot command to work with your version.

3. how do I make it so when I click chdkptp it automatically opens the cmd window for me and automatically goes into "chdk -c -i" mode (like ptpcam does). Right now I have to open a cmd window, drag chdkptp.exe to it to get its directory structure, then manually modify/type in a bunch of stuff to finally get it into that mode. I'm going to be using this over and over a million times so I'd like to get it as efficient as possible.
« Last Edit: 07 / May / 2011, 10:39:30 by John1234 »


*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #24 on: 07 / May / 2011, 17:11:47 »
I got an error:
Code: [Select]
con> !t=chdku.listdir('A/DCIM/100_0507',{match=".JPG$"})
con 1> !for i,n in ipiars(t) do chdk.download("A/DCIM/100_0507/"..n,"img/"..n) end
ERROR: call failed:[string "for i,n in ipiars(t) do chdk.download("A/DC..."]:1:
attempt to call global 'ipiars' (a nil value)
You've made a typo, should be ipairs (integer pairs) not ipiars. Note that I posted the above to show that you can easily script file downloads, not as a finished product. If you are going to do this a lot, you probably want to put it in a function somewhere in the lua files, do error checking and so on. I'm assuming if you can script lua on the camera, using it chdkptp shouldn't be a big problem.
Quote
1. Can you modify it so that you just type something simple like: downlaod_all_media(<destinationDir>) and it would automatically look in "A/DCIM" and all of its subdirectories and download anything that is a .jpg or .mov (or whatever format it uses for movies) while keeping the directory structure, and automatically handling any duplicate file issues?
It is my intention to do that eventually. Right now, ptpcam lua doesn't have all the needed functions to create directories and compare file times etc on the PC. ticket http://www.assembla.com/spaces/chdkptp/tickets/32-add-lfs-for-local-pc-filesystem-access
Quote
2. I can't get any sort of reboot command to work with your version.
.reboot()
does exactly the same thing ptpcam "reboot" does.

Note that you will have to reconnect ('c' command) after a reboot.
Quote
3. how do I make it so when I click chdkptp it automatically opens the cmd window for me and automatically goes into "chdk -c -i" mode (like ptpcam does).
You can make a shortcut, or a batch file, or you can hack the main.lua to connect and go into cli by default.  I thought you were going to be interacting with this from some kind of c# program ?  If so, can't you just start it from there with the correct command line arguments ?
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #25 on: 07 / May / 2011, 17:26:19 »
Got his error this time:
Code: [Select]
con 1> !t=chdku.listdir('A/DCIM/100CANON',{match=".JPG$"})
con 2> !for i,n in ipairs(t) do chdk.download("A/DCIM/100CANON/"..n,"img/"..n) e
nd
ERROR: call failed:[string "for i,n in ipairs(t) do chdk.download("A/DC..."]:1:
bad argument #1 to 'ipairs' (table expected, got boolean)

con 2>

.reboot() works usually only once. every rare once in a while I can reconnect to it.
Code: [Select]
con> .reboot()     //camera rebooted
con 1> c             //waited until camera was finished booting but still no luck
ERROR: Could not close session!
con 1> c
Could not find any device matching given bus/dev numbers, retrying in 1 s...
Could not find any device matching given bus/dev numbers, retrying in 1 s...
Could not find any device matching given bus/dev numbers, retrying in 1 s...
Could not find any device matching given bus/dev numbers, retrying in 1 s...
Could not find any device matching given bus/dev numbers, retrying in 1 s...
from there i have to turn the camera off and then back on with the power button.
« Last Edit: 07 / May / 2011, 17:48:23 by John1234 »

*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #26 on: 07 / May / 2011, 18:09:06 »
I'm guessing your camera doesn't have a 100CANON directory (you used 'A/DCIM/100_0507' before), so listdir returned an error instead of a table. As I said, this is an example for you to work from (if you want), not a finished product. If you aren't willing/able to do some hacking, this is probably not the solution for you yet. There is currently no solution using CHDK ptp interface that would not require some hacking somewhere.

chdku.listdir, like most chdku functions return false,errormessage on failure, so you'd want check that. I'd suggest putting the whole thing in a function in one of the .lua files, like the following (tested on my camera)
Code: [Select]
function imgdownload(srcpath,dstpath,pattern)
 local filenames,err = chdku.listdir(srcpath,{match=pattern})
 if not filenames then
  return false,err
 end
 for i,name in ipairs(filenames) do
  local src = srcpath .. '/' .. name
  local dst = dstpath .. '/' .. name
  printf("%s -> %s\n",src,dst)
  status,err = chdk.download(src,dst)
  if not status then
    return status,err
  end
 end
 return true
end
then you can just use
Code: [Select]
!return imgdownload("A/DCIM/100CANON","C:/images","%.JPG$")
Of course you can set src and dst with code instead of typing them in. The !return causes the return values of the function to be printed, so you'll see any error messages.

Regarding reboot crashes, I would suggest switching to play mode and waiting a bit before rebooting if you aren't already doing this.

edit:
I added the download function as chdku.downloaddir in chdkptp changeset 49
« Last Edit: 07 / May / 2011, 18:52:05 by reyalp »
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #27 on: 07 / May / 2011, 19:01:28 »
ok, got rid of the typos but still had an error:
Code: [Select]
con> !t=chdku.listdir('A/DCIM/100_0507',{match=".JPG$"})
con 1> !for i,n in ipairs(t) do chdk.download("A/DCIM/100_0507/"..n,"img/"..n) e
nd
could not open file 'img/IMG_0001.JPG'
could not open file 'img/IMG_0002.JPG'
could not open file 'img/IMG_0003.JPG'
con 1>


Quote
Regarding reboot crashes, I would suggest switching to play mode and waiting a bit before rebooting if you aren't already doing this.
I tried that too. Some times the c command works after the reboot but most of the time it doesn't and gives the errors explained previously.


Quote
I added the download function as chdku.downloaddir in chdkptp changeset 49
I copied the new lua file you changed and tried the new command but got no response but no error message either...
Code: [Select]
con> lua chdku.downloaddir("A/DCIM/100_0507","C/IMG")
con 1>
« Last Edit: 07 / May / 2011, 19:15:32 by John1234 »


*

Offline reyalp

  • ******
  • 13714
Re: Are these software upgrades possible?
« Reply #28 on: 07 / May / 2011, 19:49:10 »
ok, got rid of the typos but still had an error:
Code: [Select]
could not open file 'img/IMG_0001.JPG'
I'm guessing the directory "img" is not a  subdirectory of whatever directory you are running in ?

Quote
I tried that too. Some times the c command works after the reboot but most of the time it doesn't and gives the errors explained previously.
If the camera is still responsive (e.g. power button still works) but 'c' doesn't work, chances are something else in windows is connecting to the camera. Maybe windows native picture transfer software etc., or a dialog prompting you what to do.

Quote
I copied the new lua file you changed and tried the new command but got no response but no error message either...
Code: [Select]
con> lua chdku.downloaddir("A/DCIM/100_0507","C/IMG")
con 1>
"lua" (or .) runs lua *on the camera*.

chdku is *local* it runs inside chdkptp on your pc. You run that with "exec" (or !)

Also, "lua" doesn't wait for the script to end, so it only notices syntax errors, not runtime errors.  What you did would result in a runtime error, since chdku isn't defined on the camera. If you want to run lua and wait for results / errors, use "luar" (or =)

Also, C/IMG doesn't look like a valid path. Maybe you meant C:/IMG
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #29 on: 07 / May / 2011, 20:03:28 »
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?

Quote
Maybe windows native picture transfer software etc., or a dialog prompting you what to do.
nope. I type .reboot(), hit enter, the camera reboots, windows device disconnected sounds plays, device connected sounds plays. The good news is that the reboot command works repeatedly in ptpcam. 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.

 

Related Topics