The disadvantage of this solution is that the application's stdin
and stdout are exclusively reserved for communication with
daVinci.
If more flexibility is needed, e.g. to use other file descriptors than
stdin and stdout, the application has to establish the
pipe communication with daVinci on its own, read
below for details.
Either daVinci connects the Application...
daVinci is able to connect an application program at start-up time
using command-line
option -startappl
or at run-time with menu
File/Connect Application....
By connecting an application, daVinci forks a new UNIX process,
creates two pipes for communication, binds stdin and stdout
of the new process to the end of the pipes and finally starts the specified
application which has to wait for an
initial ok
answer before start sending commands to the API by simply printing them on
stdout. Answers from the API are available for the application by
reading from stdin.
At any time, the user is able to shut-down the currently connected
application by selecting menu
File/Disconnect Application.
But this only works in case of support by the application
(it has to terminate after receiving answer
disconnect).
... or the Application connects daVinci
When the more comfortable connection method (described
above) is not appropriate,
the application program needs to start daVinci on its own.
To do so, the application has to perform the following tasks:
After establishing connection, daVinci sends an initial
ok
answer for synchronization. The application should not start sending commands
to the API before receiving this answer.
daVinci is not able to disconnect the application if it has not
established the connection before. So, menu
File/Disconnect Application
is always deactivated for the connection method described in this paragraph.
Transmitting Commands
After establishing connection between your application and daVinci,
you should test the communication by sending command nothing several
times to the API. The connection works if you receive an answer ok
for each sent command. daVinci only accepts valid commands according
to the
API syntax,
all other messages are treated as a syntax error by sending answer
communication_error(...)
back to the application.
Unlike previous V1.x releases, daVinci V2.x has now a robust API to
continue communication after a syntax error is detected. Tip: You can play with
the API by starting daVinci in a shell with option -pipe.
In this case, you are able to enter (or better: using copy/paste) commands into
the shell and send them to the API with one final return behind the command.
The answers from the API are also displayed in the shell in this case. You can
find some API examples in your daVinci distribution.
Note: API commands must not have newline or return characters inside. They must have exactly one newline at the end of the command to flush the write buffer. No other characters, even no spaces, must follow this concluding return, except of the next complete command. If these restrictions are not considered, pipe communication with the daVinci API will likely fail.