Need advice on how to use CHDKPTP to retrieve file name of last picture taken

I'd like to use an AVR2560 or ARM Cortex-M4F microcontroller to somehow trigger a Canon to take a picture and then I'd like to retrieve that pictures filename (not the file itself, just an identifier of the picture) back into the microcontroller so that it can be stored in a log file. The microcontroller is actually a multicopter flight controller so it knows it's attitude, gps location, etc but I want to make sure that after the flight, when the user downloads the dataflash files from the microcontroller and the images from the camera that they can easily be tied together. So this is why I would like the microcontroller to get the file location so it can store it along with the position data.

imgname=string.format('%s/IMG_%04d.JPG',get_image_dir(),get_exp_count())Note in some situations, it might be sufficient to just store the number, or the number and time to disambiguate if it wraps around.

To get this from a microcontroller, you will need a USB stack, and a PTP client library, and implement enough of the CHDK PTP protocol to execute scripts and read the messages containing the script return value.

An alternate approach would be to trigger the shots using GPIO from your microcontroller with USB remote function http://chdk.wikia.com/wiki/USB_Remote and log enough information on the camera to correlate the images and flight controller data later.

A note on terminology."CHDK PTP" refers to the PTP extension in CHDK.

"chdkptp" generally refers to the PTP client I wrote: https://www.assembla.com/spaces/chdkptp/wikiThis can be built for normal linux distros and windows, but would probably be difficult to port to a microcontroller environment. It might be a useful example if you end up writing your own client.