librpc
Classes | Macros | Typedefs | Enumerations | Functions
bus.h File Reference
#include <stdint.h>
Include dependency graph for bus.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rpc_bus_node
 

Macros

#define RPC_BUS_EVENT_HANDLER(_fn, _arg)
 

Typedefs

typedef void(^ rpc_bus_event_handler_t) (rpc_bus_event_t event, struct rpc_bus_node *_Nonnull node)
 

Enumerations

enum  rpc_bus_event_t { RPC_BUS_ATTACHED, RPC_BUS_DETACHED }
 

Functions

int rpc_bus_open (void)
 
int rpc_bus_close (void)
 
int rpc_bus_ping (const char *_Nonnull serial)
 
int rpc_bus_enumerate (struct rpc_bus_node *_Nullable *_Nonnull result)
 
void rpc_bus_free_result (struct rpc_bus_node *_Nonnull result)
 
void rpc_bus_register_event_handler (_Nonnull rpc_bus_event_handler_t handler)
 
void rpc_bus_unregister_event_handler (void)
 

Detailed Description

Bus transport API

Definition in file bus.h.

Macro Definition Documentation

◆ RPC_BUS_EVENT_HANDLER

#define RPC_BUS_EVENT_HANDLER (   _fn,
  _arg 
)
Value:
^(rpc_bus_event_t _event, struct rpc_bus_node *_node) { \
_fn(_arg, _event, _node); \
}
rpc_bus_event_t
Definition: bus.h:45

Converts function pointer to an rpc_bus_event_t block type.

Definition at line 73 of file bus.h.

Typedef Documentation

◆ rpc_bus_event_handler_t

typedef void(^ rpc_bus_event_handler_t) (rpc_bus_event_t event, struct rpc_bus_node *_Nonnull node)

Hotplug event handler callback block type.

Definition at line 67 of file bus.h.

Enumeration Type Documentation

◆ rpc_bus_event_t

Bus hot-plug event type.

Enumerator
RPC_BUS_ATTACHED 

Device attached to the system

RPC_BUS_DETACHED 

Device detached from the system

Definition at line 45 of file bus.h.

Function Documentation

◆ rpc_bus_close()

int rpc_bus_close ( void  )

Closes the librpc bus connection.

Returns
0 on success, -1 on error
Examples:
bus.c.

◆ rpc_bus_enumerate()

int rpc_bus_enumerate ( struct rpc_bus_node *_Nullable *_Nonnull  result)

Enumerates connected devices on the RPC bus.

Parameters
resultArray of rpc_bus_node elements
Returns
0 on success, -1 on error
Examples:
bus.c.

◆ rpc_bus_free_result()

void rpc_bus_free_result ( struct rpc_bus_node *_Nonnull  result)

Frees struct rpc_bus_node array obtained in rpc_bus_enumerate call.

Parameters
resultArray of struct rpc_bus_node elements
Examples:
bus.c.

◆ rpc_bus_open()

int rpc_bus_open ( void  )

Opens the librpc bus connection.

Returns
0 on success, -1 on error
Examples:
bus.c.

◆ rpc_bus_ping()

int rpc_bus_ping ( const char *_Nonnull  serial)

Checks whether a node with specified serial is reachable.

Parameters
serialNode serial number
Returns
0 if reachable, -1 otherwise
Examples:
bus.c.

◆ rpc_bus_register_event_handler()

void rpc_bus_register_event_handler ( _Nonnull rpc_bus_event_handler_t  handler)

Configures an event handler block to be called whenever a bus event occurs.

Parameters
handlerBus event handler

◆ rpc_bus_unregister_event_handler()

void rpc_bus_unregister_event_handler ( void  )

Unsets the previously set event handler. If there was no handler previously configured, does nothing.