CHDK PTP interface

Hi all, sorry for the interruption. I am very new to PTP extension and I am trying to get my computer to control the camera A710IS. Right now I have the lastest build from CHDKDE and loaded onto my SD card, but when I try to issue the command "ptpcam.exe --chdk" in windows console, it says "Could not find any device matching given bus/dev numbers, retrying in 1 s...". It seems that somehow the connection is not setup between my computer and the camera. Can someone tell me which part I did it wrong? ThanksJLI just posted a new thread about the questions I have, so please ignore above. ThanksJL

I do now some more test with the non working switch to record mode on my Ixus 1000 HS.

I add in wrapper.c when should switch to record mode a keyb_stopusb = 1 in a global variable that is access from keyboard task too.This tell the keyboard task my_kbd_read_keys() function that it should do action.

This code work, without crash and switch to record mode, but when the time is over to clear the USB bit, then the Camera move in Lens and go to playback mode.

I am trying to modify PTPCamGUI (simply changing ptpcamgui.au3) to allow for deleting of files after transfer. I have added a checkbox which when checked deletes the files you are transferring to your computer. I have tested it with all of the download options (all, new, number of pics), and because it works from the same file list as downloading, shouldn't interfere with anything.. BUT it does reboot the camera to accurately reflect the current number of pictures. If checked you will also get the "Download and Delete these files now" confirmation/cancel dialog.

Also, I was having trouble with the timelapse "STOP" button not really stopping anything but ptpcamgui. I changed some lines and fixed that too. (at least for myself!) I'm using an SX130IS, and everything works like a charm!

As of build #82, the line numbers in this text file were accurate to make changes in the ptpcamgui.au3 and ptpcamgui_obfuscated.au3 files, but the notation is written so that I understand it. If you try to use this file, I hope you can figure it out. EDIT Attachment removed to avoid confusion

I noticed what I think is a typing error around line 1260' if fd~=nli and #fd>0 then' & @LF & _I think should be ' if fd~=nil and #fd>0 then' & @LF & _

Yes, that's true. I've change in ptpcamGUI rev.#80. Thanks achillies!

Usually, I write the routine for new feature at first and chage then the GUI. Sorry, but delete files on cam is not the topmost feature for implement in moment.

an other theme: "table results with ptpcam.exe"I provide a solution for return results from simple lua-tables with ptpcam. The most tables have one or two dimensions. My code convert tables to a formatted string for retrieve.

From some clues (A480 needs to be a specific fw version, SD card needs to be dealt with some wizard) I'm temped to guess that they didn't get any help from Canon, but are instead selling modified or rewritten CHDK and CHDK PTP.

"inPhoto ID PS works only with Canon A480, Canon A495, Canon SX200 IS and Canon SX210 IS cameras. Next camera will be Canon SX130 IS."

an other theme: "table results with ptpcam.exe"I provide a solution for return results from simple lua-tables with ptpcam. The most tables have one or two dimensions. My code convert tables to a formatted string for retrieve.

Good. This is important.

Some thoughts:C code seems complex, could be better to do this in lua. We can have lua code in a C string if we want hardcoded in CHDK.

Would be good to have a standard library of lua functions to use with PTP somehow. Not sure the best way to do this, loading from SD card every time would be slow, sending over PTP every time not so nice either.

Format is OK to display values, but it's ambiguous in some cases and quite limited. Doesn't support non-numeric keys in second level table, e.g. {t={a='a',b='b'}}, showing nil in one and not the other is a bit odd.

OK for now, but I think we'll want to revisit, real work crunch is over for a while.

My plan was to format table returns as a string of lua code, using lua (but only simple types as you have, and no cyclic references etc.) When the PC side has lua this is very convenient. It's also quite readable on it's own, but maybe not easy to parse in autoit.

I'll have a little more time to work on CHDK now.

lua version of table format code. Could be simpler, but I was trying to match output of rudi's code as closely as possible. There are probably some minor differences still

I intend this branch to a short lived. If no one says this is a horrible idea, it will go into the trunk after a few things are cleaned up. I want to give everyone (especially chdkde / ptpcamgui developers) a chance to comment first.

This basically merges my earlier ptp script message and result code.

Highlights:- all lua script return values are returned as messages (the way luar adds return(...) doesn't support multiple return so e.g. luar get_mode() will only return the first value, and luar 1,2 fails.)- messages from script->pc now have lua types, like old result code. Tables are returned as string, in rudi's format using lua as described in previous post.- lua compile and runtime error messages are returned as messages. Return values, script generated messages, and error message are all identified, so the pc software can ignore whatever it isn't interested in.- protocol is changed, but ptpcam commands/output are almost 100% compatible.- scripts now have a 'process id', returned when you start the script. This allows camera and pc side to discard messages that were from/to a previous script invocation.

Other stuff- ptpcam doesn't take advantage of all the new features, new client will use them.- error messages can be lost if queue is full. - would probably be better to flush all messages when a new script starts.

Hi reyalp,very good work and implementation!Now I had some time for tests only with modified ptpcam.exe and reyalp-brunch/modified CHDK-DE (identical results) - my result: great! more informations about states and errors, more result values. On this time 'ptpmsg.lua' untested.

some comments:TEST 'function usb_msg_table_to_string(arg)':The function fails is arg not a table.

<conn> lua return usb_msg_table_to_string(os.stat('A/ptpmsgB.lua'))<conn> getmnilA/ptpmsgB.lua: error0 (0)TEST script id and results:Very good idea, but how much results are from current id and how much from script-id 24?For example we can use a text 'message' to separate old id from current id?