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 can immediately start sending commands
to the API by printing on stdout. No initial
ok
answer is sent in this case, in opposite to the other connection method,
described in the next paragraph. Answers from the API are available
for the application by reading on its 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 appropriated,
the application program need 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 treaded as a syntax error by sending answer
communication_error(...)
back to the application.
Unlike previous V1.x releases, daVinci V2.0 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 commands in the shell and send them to
the API by pressing return.
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, may 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.