I've been working on the 0.82 engine, and have been adding two-way communication to the serial API to handle status requests from the engine, and making it possible to retrieve current parameters, etc.
For the time being, the 0.82 branch is available from SVN on sourceforge, and you can view it here: OpenMoco_Timelapse_Engine. The header of OM_Serial_Com_Client.pde lists the additional serial values.
(The new stats code is largely untested, but compiles properly as of this message)
The first part added is command response -- each command is responded to with a single response byte. Presently, there are two values: 0 (0x0) for error (such as unknown command), and 1 (0x1) for success.
Command response happens upon the completion of the given request, so if you're setting the interval time, for example, the response will be nearly instantaneous compared to the time it takes to respond to a request to move a motor 10,000 steps. Client code will need to use timeouts to prevent blocking forever should an issue occur. (The in-dev version of the perl API uses a default of 20 seconds.)
Following a command response, will be the length of data (in bytes) the engine is going to return in addition to the response - from 0 to 255. Neither the length byte nor the command response byte will be counted in the data length. Thus, a command with no data returned would be responded to with the following sequence:
[ 0x1, 0x0 ]
Naturally, the commands that set parameters or order the engine to do something do not return any additional data, so they will always have a data length of zero. If a command is unrecognized, or an error occurs, no bytes will follow the command response.
The following new capabilities have been added thus far:
- Status Check / NOOP
Does nothing, simply gives back a positive command response. You can use it to see if the engine is currently available to listen to commands.
- API Version
Responds with API version (one byte)
- Running status
Responds with Running or Stopped/Paused (one byte)
- Run time
Program running time (ms, 32 bits)
- Camera Enabled
Camera currently enabled (one byte)
- Shot Count
Current shot count (32 bits)
- Interval Time
Current interval time (secs, 16 bits)
- Exposure Time
Current exposure time (ms, 32 bits)
- Post Delay
Current post-exposure delay (ms, 16 bits)
- Camera Currently Exposing
Whether the shutter is currently triggered for the camera (one byte)
- Motor Enabled
Whether a given motor is enabled (one byte)
- Motor Dir
Motor direction (one byte)
- Steps Moved
Steps moved for a given motor (32 bits)
- Home Distance
Distance (in steps, positive or negative) from home position (signed 32 bits)
- Motor Steps Max
Maximum step count for given motor (32 bits)
- Motor Ramp
Motor ramp rate for given motor (one byte)
- Motor Backlash
Motor backlash compensation for given motor (one byte)
Still need to add protocol codes to retrieve keyframe and action data. Additionally, still need to add motor steps between shots parameter retrieval.
Any suggestions, questions, or feedback would be highly appreciated!