This document shows the functions that an autopilot (as library) has to implement in order to be loaded and run by the hardware-emulator.
These are simple entry points so that the hardware_emulator can easily communicate with the autopilot. The functions are simple pure C types and thus use simple function calling standards.
These functions can be implemented by including and implementing the library_interface.h header from the
This interface is implemented by autopilots generated using EMAM2CPP or one of its siblings.
EXPORT const char* DI__get_interface();
This function must return a JSON string corresponding to the ProgramInterface class.
EXPORT void DI__init();
Called at the start of a simulation to initialize the autopilot.
EXPORT void DI__execute();
Called each simulation cycle after the ports have been set.
set_port() and get_port()
EXPORT void DI__set_port(int i, const char* data, int is_json); EXPORT const char* DI__get_port(int i, int is_json);
These functions are used to exchange the port data with the autopilot.
i is an index starting at 0. It corresponds to the order of the ports as described in the
ProgramInterface returned by
is_json argument specifies whether the
data exchanged is JSON or binary.
is_json == 0 the content is binary else it is a JSON string.
In the case of binary, the first 4 bytes are the length of the rest of the data array.
(This value follows the serialization format of the BinaryWriter/BinaryReader used for serializing the binary data.)
In the case of
is_json argument is a "request" for the content of the returned array.