Navigation

Basic API

file api.h

Include dependency graph for api.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "4" [label="eswb/errors.h" tooltip="eswb/errors.h"]
    "3" [label="eswb/types.h" tooltip="eswb/types.h"]
    "2" [label="eswb/topic_proclaiming_tree.h" tooltip="eswb/topic_proclaiming_tree.h"]
    "1" [label="/usr/src/eswb/src/lib/include/public/eswb/api.h" tooltip="/usr/src/eswb/src/lib/include/public/eswb/api.h" fillcolor="#BFBFBF"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "4" [dir=forward tooltip="include"]
}

Functions

eswb_rv_t eswb_local_init(int do_reset)

Reset local busses by flushing them and theirs topics registries. Important to to use this call when you have to restart initialization within one runtime cycle.

Parameters:

do_reset – must be non zero to take effect

Returns:

eswb_e_ok on success

eswb_rv_t eswb_create(const char *bus_name, eswb_type_t type, eswb_size_t max_topics)

Create a bus

Parameters:
  • bus_name

  • type – eswb_non_synced - no synchronization and mutual exclusion are provided for topics access eswb_inter_thread - with synchronized access to topics and with blocked updated calls eswb_inter_process - NOT SUPPORTED YET; will create a broker process

  • max_topics – number of topics to allocate inside a bus registry

Returns:

eswb_e_ok on success

eswb_rv_t eswb_delete(const char *bus_path)

Delete bus by its name

Parameters:

bus_path – path / name of the bus

Returns:

eswb_e_ok on success

eswb_rv_t eswb_delete_by_td(eswb_topic_descr_t td)

Delete bus by any of its topic descriptor

Parameters:

td – topic descriptor of any bus’s topic

Returns:

eswb_e_ok on success

eswb_rv_t eswb_mkdir(const char *path, const char *dir_name)

Create a directory within a path

Parameters:
  • path – root of the directory

  • dir_name – dir name or NULL if full path is presented in ‘path’ argument

Returns:

eswb_e_ok on success

eswb_rv_t eswb_mkdir_nested(eswb_topic_descr_t parent_td, const char *dir_name, eswb_topic_descr_t *new_dir_td)

Create directory as a child to a specified descriptor

Parameters:
  • parent_td

  • dir_name

Returns:

eswb_rv_t eswb_proclaim_tree(eswb_topic_descr_t parent_td, topic_proclaiming_tree_t *bp, eswb_size_t tree_size, eswb_topic_descr_t *new_td)

Publish tree of the topics to the topic with a specified descriptor

Parameters:
  • parent_td – topic descriptor of the root, must have type tt_dir

  • bp – tree initialized by usr_topic_* calls

  • tree_size – number of elements inside bp

  • new_td – pointer to topic descriptor variable assigned to the just published topic in case of success and if it non NULL.

Returns:

eswb_e_ok on success

eswb_rv_t eswb_proclaim_tree_by_path(const char *mount_point, topic_proclaiming_tree_t *bp, eswb_size_t tree_size, eswb_topic_descr_t *new_td)

Publish tree of the topics to the specified path

Parameters:
  • mount_point – path to the topic the root to publish, must have type tt_dir

  • bp – tree initialized by usr_topic_* calls

  • tree_size – number of elements inside bp

  • new_td – pointer to topic descriptor variable assigned to the just published topic in case of success, might NULL

Returns:

eswb_e_ok on success

eswb_rv_t eswb_proclaim_plain(const char *mount_point, const char *topic_name, size_t data_size, eswb_topic_descr_t *new_td)

Proclaim plain data

Parameters:
  • mount_point – path to the topic the root to publish, must have type tt_dir

  • topic_name – name of the plain topic

  • data_size – size of the plain data to allocate

  • new_td – pointer to topic descriptor variable assigned to the just published topic in case of success, might NULL

Returns:

eswb_rv_t eswb_update_topic(eswb_topic_descr_t td, void *data)

Update topic value and notify blocked subscribers

Parameters:
  • td – topic descriptor

  • data – data to publish; must have a size according to the topic size

Returns:

eswb_e_ok on success

eswb_rv_t eswb_connect(const char *path2topic, eswb_topic_descr_t *new_td)

Subscribe on topic

Parameters:
  • path2topic – path to the topic to subscribe

  • new_td – pointer to save new topic descriptor value in case of success

Returns:

eswb_e_ok on success

eswb_rv_t eswb_read(eswb_topic_descr_t td, void *data)

Non blocking read of topic’s current value

Parameters:
  • td – topic descriptor

  • data – data to read; must have a size according to the topic size

Returns:

eswb_e_ok on success

eswb_rv_t eswb_get_update(eswb_topic_descr_t td, void *data)

Blocking read of topic’s value, returned right after its value publication

Parameters:
  • td – topic descriptor

  • data – data to read; must have a size according to the topic size

Returns:

eswb_e_ok on success

eswb_rv_t eswb_get_topic_params(eswb_topic_descr_t td, topic_params_t *params)

Get topic’s information by its descriptor

Parameters:
  • td – topic descriptor

  • params – pointer to an allocated parameters strucutre to store parameters on success

Returns:

eswb_e_ok on success

eswb_rv_t eswb_get_next_topic_info(eswb_topic_descr_t td, eswb_topic_id_t *next2tid, struct topic_extract *info)

Retrieve topics

Parameters:
  • td – topic descriptor of the root to retrieve its children topics

  • next2tid – pointer to the id value for the topic, preceeding the desired. At the first call value at this ref (e.g. as local variable) must be zero. After successfull return it contains the id of just retrieved topic info

  • info – retrieved information on success must be pointer to topic_extract_t (might be NULL, for e.g. calc of nested topics)

Returns:

eswb_e_ok on success eswb_e_no_topic when there is no next topic (retrieve sequence is ended)

eswb_rv_t eswb_get_topic_path(eswb_topic_descr_t td, char *path)

Retrieve full path of the topic by its descriptor

Parameters:
  • td – topic descriptor

  • path – string with a size of ESWB_TOPIC_MAX_PATH_LEN + 1

Returns:

eswb_e_ok on success

eswb_rv_t eswb_fifo_subscribe(const char *path, eswb_topic_descr_t *new_td)

Subscribe on fifo topic

Parameters:
  • path – path to fifo

  • new_td – pointer to save new topic descriptor value in case of success

Returns:

eswb_e_ok on success

eswb_rv_t eswb_fifo_push(eswb_topic_descr_t td, void *data)

Push new value to fifo

Parameters:
  • td – fifo’s topic descriptor

  • data – pointer to data to push; must have a size according to the fifo element size

Returns:

eswb_e_ok on success

eswb_rv_t eswb_fifo_pop(eswb_topic_descr_t td, void *data)

Pop value from fifo

Parameters:
  • td – fifo’s topic descriptor

  • data – pointer to data to save popped element; must point to the data with a size equal to the proclaimed fifo’s element size

Returns:

eswb_e_ok on success eswb_e_no_update if FIFO is created on NSB bus type and there are no elements in queue

eswb_rv_t eswb_fifo_flush(eswb_topic_descr_t td)

Flush fifo for specified td

Parameters:

td – fifo’s topic descriptor

Returns:

eswb_e_ok on success

eswb_rv_t eswb_fifo_try_pop(eswb_topic_descr_t td, void *data)

Check if there was an update since the last call and pop it if so

Parameters:
  • td – fifo’s topic descriptor

  • data – pointer to data to save popped element; must point to the data with a size equal to the proclaimed fifo’s element size

Returns:

eswb_e_ok on success eswb_e_no_update if there were no updates since the last call

eswb_rv_t eswb_arm_timeout(eswb_topic_descr_t td, uint32_t timeout_us)

Arm timeout for getting updates from synchronized calls

Parameters:
  • td – topic descriptor

  • timeout_us – timeout value in microseconds

Returns:

eswb_e_ok on success

eswb_rv_t eswb_connect_nested(eswb_topic_descr_t mp_td, const char *topic_name, eswb_topic_descr_t *td)
Parameters:
  • mp_td

  • topic_name

  • td

Returns:

eswb_e_ok on success

eswb_rv_t eswb_wait_connect_nested(eswb_topic_descr_t mp_td, const char *topic_name, eswb_topic_descr_t *td, uint32_t timeout_ms)
Parameters:
  • mp_td

  • topic_name

  • td

  • timeout_ms

Returns:

eswb_e_ok on success eswb_e_timedout was not able to connect within specified timeframe

eswb_rv_t eswb_disconnect(eswb_topic_descr_t td)

Disconnect from topic

Parameters:

td – topic descriptor

Returns:

eswb_e_ok on success

const char *eswb_get_bus_prefix(eswb_type_t type)

Get a bus prefix associated with specific bus type

Parameters:

type – bus type

Returns:

string constant of bus prefix or NULL if type is invalid

eswb_rv_t eswb_path_compose(eswb_type_t type, const char *bus_name, const char *topic_subpath, char *result)

Compose full path to a topic

Parameters:
  • type – bus type

  • bus_name – name of the bus

  • topic_subpath – subpath wihtin a bus

  • result – pointer to resulting string with a size ESWB_TOPIC_MAX_PATH_LEN

Returns:

eswb_e_ok on success

eswb_rv_t eswb_path_split(const char *full_path, char *path, char *topic_name)

Split a full path to the specific topic

Parameters:
  • full_path – pointer to the full path to the topic

  • path – pointer to the basepath of the topic (string of size ESWB_TOPIC_MAX_PATH_LEN)

  • topic_name – pointer to the topic’s name (string of size ESWB_TOPIC_NAME_MAX_LEN)

Returns:

eswb_e_ok on success

void eswb_set_thread_name(const char *n)

Wrapper for a system’s specific calls to name calling a thread

Parameters:

n – name to set for calling thread

void eswb_set_delta_priority(int dp)

Change priority of the calling thread (works via pthread_getschedparam / pthread_setschedparam)

Parameters:

dp – delta priority

page api

Check api.h for calls descriptions

dir /usr/src/eswb
dir /usr/src/eswb/src/lib/include/public/eswb
dir /usr/src/eswb/src/lib/include
dir /usr/src/eswb/src/lib
dir /usr/src/eswb/src/lib/include/public
dir /usr/src/eswb/src