Open Lighting Architecture
Latest Git
|
Send and Receive DMX512 data using the C++ API.
This page introduces the OLA Client API, and provides sample programs to send and receive DMX512 data from olad. For information on how to use more advanced features of the API, see Advanced C++ Client API.
OLA comes with two C++ clients. The ola::client::StreamingClient is a simplified client that is limited to sending DMX512 data. ola::client::OlaClient is a full featured client that can both send and receive data, as well as control all aspects of OLA, like patching ports, configuring devices etc.
Once OLA is installed on your system, the examples can be built with:
g++ example.cpp $(pkg-config --cflags --libs libola)
The quickest way to get started is by using ola::client::StreamingClient The program below sends 100 frames of DMX data to the olad server on universe number 1. The frames are sent 25ms apart which gives a frame rate of 40 fps.
Each frame consists of 512 DMX data slots. The first slot is incremented by one each frame, the other slots are always 0. This produces the following sequence of DMX frames:
While ola::client::StreamingClient is easy to use, it has the drawback that it can only send DMX512 data. It's not possible to receive DMX512, use RDM or control the behavior of olad with the StreamingClient. To do that we need to use ola::client::OlaClient.
ola::client::OlaClient provides a much richer interface for interacting with the server and uses a Event Driven programming model. This makes it more complicated to use. For more examples showing the non-DMX512 aspects of OlaClient, see the Advanced C++ Client API.
The following code uses ola::client::OlaClient and behaves the same as the Streaming Client DMX512 Transmit example above.
Receiving DMX involves setting up a callback handler and then instructing the OlaClient to call the handler when new DMX512 data is received. The example below will print a line for each DMX512 frame received on universe 1.