The CHDK PTP interface mostly works by sending Lua code to the camera to run.
Using Lua, you can get the last file name using something like
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.
Information about the PTP protocol can be found at
http://chdk.wikia.com/wiki/PTP_ExtensionSome people have successfully implemented PTP support on Arduino, see
http://chdk.setepontos.com/index.php?topic=6969.msg84799#msg84799http://chdk.setepontos.com/index.php?topic=6041.msg60665#msg60665An 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.