CHDK PTP interface - page 26 - General Discussion and Assistance - CHDK Forum

CHDK PTP interface

  • 1244 Replies
  • 525379 Views
Re: CHDK PTP interface
« Reply #250 on: 04 / September / 2010, 05:06:43 »
Advertisements
hello everybody
I am trying to write a value to the" PARAM_FILE_COUNTER"  by using  " set_parameter_data" but the camera crashes down ,
any idea why ?

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: CHDK PTP interface
« Reply #251 on: 05 / September / 2010, 05:00:20 »
Isn't this already taken care of by CAM_CHDK_PTP? (As far as I know the other cameras don't call task_start_hook.)

If that's true then it's all good. I didn't try building other platforms or studied the code closely enough.

Quote
If it works, great. I think it's also useful when rebooting; I've noticed that my just-wait-a-few-seconds approach didn't always work so well.

Actually this particular one probably doesn't help with rebooting because currently it exits if it can't find a suitable usb device at all. But that part could be retried just as well. The current way of restarting helped me overcome my connection issues, but I do have to wait a little while after powering up the camera for it to be enumerated in the PC's USB or ptpcam will just exit.

Quote
My intention was that you'd be able to type luar 2*21 and get 42 back without having to add return. If I understand the Lua semantics correctly, and I believe I tried it as well, without the return you don't get 42 back. Also, having more complex commands (or actually commands that take more time) can have undesired effects due to the fact that the PTP handler waits for completion.

I do understand the use of your version, but I'd probably either use (my) luar (function () body end)() (not tested) or make another command for it.

Actually...is there a reason for the lua command not to give a return value? Then your luar command could be left as is for faster command line debugging stuff like you intended. I've tried some commands and short scripts (without the return command) with my version of luar (which doesn't add return but does retrieve the return value) and they all worked fine, ptpcam just doesn't print a return value. In other words my version of the luar command seemed to work just the same as the lua command if the script didin't return anything.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: CHDK PTP interface
« Reply #252 on: 05 / September / 2010, 05:09:44 »
In ptp.c, the malloc/sprintf is now pretty useless; I'd remove that (together with the later free).

I'm not 100% certain which one you mean...

Quote
  • Apparently you have some automatic style changer or something. Diffing your version with mine gives a lot more than one wishes. (Deja vu! J/k ;))

Yea, sorry. I was away from home when I started modifying it and ended up with a mixed tabs/space indenting mayhem that made me sick... ;)

Quote
  • It seems open_camera tries a (MAXCONNRETRIES+1)th time or, in case of success before, always calls ptp_opensession another time. Perhaps moving the call in the condition and the code after (and just before) the loop inside (into a "big" if) is a solution.

Did I say it was a quick hack? :P

Quote
  • How about just a char *buf = chdkarg; in chdk()?

I didn't look at the code today, but I do remember using duct tape and bubble gum wrappers with them buffers after gcc rudely complained about my coding skills.

Quote
  • Something to be aware of for the CLI is that the reboot commands try to reconnect after issuing the reboot. It's probably still the right behaviour as it gives you the result of the reboot (without having to look at the camera).
The reboot command is something I won't be able to test as there is no such thing for the vxworks cams.

Re: CHDK PTP interface
« Reply #253 on: 05 / September / 2010, 07:52:06 »
The reboot command is something I won't be able to test as there is no such thing for the vxworks cams.


There is ExecuteFirmUpgrade  (or maybe LoadAndStartUpgrade) , but I have not managed to get it working so far.

On a G9, I have called reboot() from a script using a PS.FI2 file and an auto-start time-lapse script.

After extensive tests, the user reports it crashes after a random number of resets.

It does not seem to crash with an extremely simple test script.

I have no idea why  .....



David
« Last Edit: 05 / September / 2010, 10:40:56 by Microfunguy »


Re: CHDK PTP interface
« Reply #254 on: 05 / September / 2010, 07:54:39 »
I am trying to write a value to the" PARAM_FILE_COUNTER"  by using  " set_parameter_data" but the camera crashes down ,
any idea why ?

I have tried that from a script (not using PTP) and it sort of works but requires a camera reset.

Cannot remember the details but the next-used image numbers where not as expected.


Incidentally, anyone know the difference between firmware functions 'remove' and 'DeleteFile_Fut' ?


David
« Last Edit: 05 / September / 2010, 08:03:00 by Microfunguy »

Re: CHDK PTP interface
« Reply #255 on: 06 / September / 2010, 10:02:29 »
for canon powershot G11 100j

NHSTUB(add_ptp_handler, 0xFFA4DE90)           
NHSTUB(set_control_event, 0xFF894CE8)         
NHSTUB(PB2Rec, 0xFF898460)       
NHSTUB(Rec2PB, 0xFF8984A0)   
NHSTUB(reboot_fw_update, 0xFFA89780) 

Re: CHDK PTP interface
« Reply #256 on: 06 / September / 2010, 10:50:36 »
Actually...is there a reason for the lua command not to give a return value?
The reason is that at the moment the task handling the PTP command will wait until the script is done to send back the return value and I'm unsure of the consequences of waiting for a long time. Perhaps it's completely harmless. An alternative is to make it asynchronous, having the camera send an event on completion or having a command to poll for a result.

In ptp.c, the malloc/sprintf is now pretty useless; I'd remove that (together with the later free).

I'm not 100% certain which one you mean...
I only get one change you made in ptp.c:

1933,1936c1933,1934
< //    char *buf = (char *) malloc(7+strlen(script)+1);
< //    sprintf(buf,"return %s",script);
<     char *buf = (char *) malloc(strlen(script)+1);
<     sprintf(buf,"%s",script);
---
>     char *buf = (char *) malloc(7+strlen(script)+1);
>     sprintf(buf,"return %s",script);


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: CHDK PTP interface
« Reply #257 on: 07 / September / 2010, 16:35:58 »
The reason is that at the moment the task handling the PTP command will wait until the script is done to send back the return value and I'm unsure of the consequences of waiting for a long time. Perhaps it's completely harmless. An alternative is to make it asynchronous, having the camera send an event on completion or having a command to poll for a result.

I played around with this a little bit and ended up restoring your "luar" (prefix script with result and retrieve lua return value) and naming mine "luaw" (do not modify script, retrieve result, w as in for "wait" for result) and leaving the "lua" as is (do not modify script, do not retrieve result).

Waiting for a result too long does seem to be a problem, at least for me
luaw sleep(4500);return(22+1) -- works
luaw sleep(5000);return(22+1) -- fails

I also believe I fixed the connection retry thing and added another retry loop to device finding meaning it now should not immediately fail if a command is started during power-on (tested via cli interface) and firmware reboot (not tested).

I also wrote a simple timelapse script (simple as in no good for serious timelapse work but fine for an example) in bash to show how to transfer the latest photo off the camera to the PC and delete it from the camera. It uses disk.lua from mattkime's lua libs package so if you don't have those installed (on the camera), you'll need to do something like this first:

ptpcam --chdk="upload disk.lua A/CHDK/LUALIB/disk.lua"

The new versions are available for download in ptpcam-climod-2.zip at http://drop.io/a570_chdk_ptp.


Re: CHDK PTP interface
« Reply #258 on: 30 / September / 2010, 02:01:59 »
Please excuse me if this question has been asked.

I was wondering what bytes store the image on the LCD for the A590 IS. PTPCAM has the ability to read bytes which is quite useful. I want to stream whatever is on the LCD display live. I just don't know what bytes store the LCD display. What should I read to figure this out? Or, is it documented somewhere?

Thank you for your time.

-Sean

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: CHDK PTP interface
« Reply #259 on: 30 / September / 2010, 12:03:21 »
Please excuse me if this question has been asked.

I was wondering what bytes store the image on the LCD for the A590 IS. PTPCAM has the ability to read bytes which is quite useful. I want to stream whatever is on the LCD display live. I just don't know what bytes store the LCD display. What should I read to figure this out? Or, is it documented somewhere?

Doesn't ewavr's ptp builds+windows software do just that? If you can't use it for some reason (such as PC platform), you should be able to use his source code as an example.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal