nmc-utils  0.1.1
Handling events: token API

Functions

int easynmc_token_clear (struct easynmc_token *t)
struct easynmc_tokeneasynmc_token_new (struct easynmc_handle *h, uint32_t events)
const char * easynmc_evt_name (int evt)
int easynmc_token_wait (struct easynmc_token *t, uint32_t timeout)

Detailed Description

Tokens are a simple way to process events from Neuromatrix Core. You start by allocating a token with easynmc_token_new() and specifying a bitfield of events you are interested in. Starting from the point of allocation all new events will be stored onto the token. You can clear any pending events from the token at any time using easynmc_token_clear(). Finally, you can use easynmc_token_wait() to get the next event from the token. This function will block until the next event arrives.

You can have any number of tokens simultaneously listening for events, each event will arrive into every listening token. As an alternative, you can use polling. See polling_api

Function Documentation

const char* easynmc_evt_name ( int  evt)

Get a human-readable name of the event arrived.

Parameters
evt
Returns

Definition at line 1028 of file easynmc-core.c.

Referenced by do_mon(), and easynmc_boot_core().

int easynmc_token_clear ( struct easynmc_token t)

Clear any pending events from a token

Parameters
t
Returns

Definition at line 986 of file easynmc-core.c.

References dbg, easynmc_token::h, easynmc_handle::iofd, and easynmc_token::tok.

Referenced by easynmc_token_new().

struct easynmc_token* easynmc_token_new ( struct easynmc_handle h,
uint32_t  events 
)
read

Create a new token. Tokens are a convenient way to wait for different events from the Neuromatrix core. There can be any number of tokens listening for events simultaneously Each event will be dispatched to every listening token.

Parameters
h
events
Returns

Definition at line 1005 of file easynmc-core.c.

References easynmc_token_clear(), easynmc_token::h, and easynmc_token::tok.

Referenced by do_mon(), and easynmc_boot_core().

int easynmc_token_wait ( struct easynmc_token t,
uint32_t  timeout 
)

Block until a new event arrives onto the token or until timeout expires.

Parameters
t
timeouttimeout in ms
Returns
next event number

Definition at line 1055 of file easynmc-core.c.

References err, easynmc_token::h, easynmc_handle::iofd, and easynmc_token::tok.

Referenced by do_mon(), and easynmc_boot_core().