pips_publication_write()

Updated: April 19, 2023

Write a data sample to a publication's topic

Synopsis:

#include <pips/publication.h>
int pips_publication_write(pips_publication_t *const publication,
                           const pips_guid_t *const opt_guid,
                           const void *const data,
                           const pips_encoding_e data_encoding,
                           const size_t data_size)

Arguments:

publication
A pointer to the publication whose topic will have new data published
opt_guid
An optional GUID of a subscriber that will receive the data sample published by this function. This argument should be defined only if the publication was created with the PIPS_EXCL flag set; otherwise, it must be NULL.
data
A buffer containing the encoded topic data to publish
data_encoding
A flag indicating how the data is encoded in the buffer
data_size
The size, in bytes, of the encoded data

Library:

pips-client

Description:

This function decodes the data sample in the specified buffer and publishes its data to the topic associated with the given publication. The data is made available to all subscribers of the topic.

Returns:

On success, the number of bytes of data written to the publication. On error, -1 (errno is set).

Errors:

The following errors can be generated by the framework:
  • EFAULT: The GUID of a target subscriber has been provided but the publication wasn't created with the PIPS_EXCL flag set.
  • ENODATA: The provided data isn't valid.
  • ENODEV: The publication doesn't have a valid provider associated with it.
  • ENOSR: The publication isn't valid.
  • ENOSYS: The provider doesn't implement the write function.