Entry Point and API Organization

SIL Kit Entry Point and API Organization

The main entry point of the C API is the function to obtain a SilKit_Participant:

SilKit_ParticipantConfiguration* participantConfiguration = NULL;
SilKit_Participant* participant = NULL;
const char* configString = "{ ... }";
const char* participantName = "CanWriter";
const char* registryUri = "silkit://localhost:8500";
SilKit_ReturnCode result;
result = SilKit_ParticipantConfiguration_FromString(&participantConfiguration, configString);
if (result != SilKit_ReturnCode_SUCCESS) { ... }
result = SilKit_Participant_Create(&participant, configString,
                                                        participantName, registryUri);
if (result != SilKit_ReturnCode_SUCCESS) { ... }

All further services of the C API of the SIL Kit are requested through this Participant.

Entities obtained through the Participant must not be destroyed/deleted by the user of the API. All entities, that are provided through the API expect for the SilKit_Participant are destroyed through the internals of the SIL Kit implementation.

After creation of a Participant it must be ensured that eventually SilKit_Participant_Destroy is called with the corresponding pointer to the SilKit_Participant entity.

API and Data Type Reference

General API

SilKit_ReturnCode SilKit_ReturnCodeToString(const char **outString, SilKit_ReturnCode returnCode)

Get the corresponding static error string for a given return code.

SilKit_GetLastErrorString()

Parameters
  • outString – The pointer through which the resulting human readable error string, encoded in UTF-8, will be returned.

  • returnCode – The return code for which the string should be obtained.

const char *SilKit_GetLastErrorString()

Get a human readable error description of the last error on the current thread.

This method is intended to get specific error messages in case of a non success return code. In comparison to SilKit_ReturnCodeToString this function returns dynamic and more specific error messages.

Returns

A specific string containing the last error message of the current thread.

Participant API

SilKit_ReturnCode SilKit_Participant_Create(SilKit_Participant **outParticipant, SilKit_ParticipantConfiguration *participantConfiguration, const char *participantName, const char *registryUri)

Join the SIL Kit simulation hosted by the registry listening at URI as a participant.

Join the SIL Kit simulation and become a participant based on the given configuration options.

Parameters
  • outParticipant – The pointer through which the simulation participant will be returned (out parameter).

  • participantConfiguration – Configuration of the participant (see SilKit_ParticipantConfiguration_FromString)

  • participantName – Name of the participant

  • registryUri – The silkit:// URI of the registry

SilKit_ReturnCode SilKit_Participant_Destroy(SilKit_Participant *participant)

Destroy a simulation participant and its associated simulation elements.

Destroys the simulation participant and its created simulation elements such as e.g. Can controllers.

Parameters

participant – The simulation participant to be destroyed.

Most creator functions for other objects (such as bus controllers) require a SilKit_Participant, which is the factory object, as input parameter.

Logger API

The Logger API can be used to write log messages.

SilKit_ReturnCode SilKit_Participant_GetLogger(SilKit_Logger **outLogger, SilKit_Participant *participant)

Obtain the logger of a particular simulation participant.

The lifetime of the returned logger is directly bound to the lifetime of the simulation participant. There is no futher cleanup necessary, except for destroying the simulation participant at the end of the simulation.

Parameters
  • outLogger – Pointer to the resulting logger instance (out parameter).

  • participant – The simulation participant whose logger should be returned.

SilKit_ReturnCode SilKit_Logger_Log(SilKit_Logger *logger, SilKit_LoggingLevel level, const char *message)

Log a message with a specified level.

Parameters
  • logger – The logger to use.

  • level – The log level for the message.

  • message – The message which shall be logged (UTF-8).

Enumerations and Typedefs

typedef uint32_t SilKit_LoggingLevel

Information level of log messages.