I've created a temporary branch for PTP improvements, because it's a bit complicated to keep track of without version control.
http://tools.assembla.com/chdk/browser/branches/reyalp-ptpI 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.
attached patch against chdkde ptpcam source implements pc side.
attached ptpmsg script demonstrates sending/recieving messages within script.
some examples
<conn> lua return get_mode()
<conn> getm
false
false
513 (201)
<conn> lua foo()
<conn> getm
runtime error: :1: attempt to call global 'foo' (a nil value)
<conn> lua 'blah
syntax error: :1: unfinished string near '<eof>'
execution failed!
<conn> luar get_mode
unsupported data type: function