dsm-api-v2
Data Structures | Typedefs | Functions
Library

This group of API calls addresses the management of the dS485-Stack, connection to the ds485d daemon and the callback infrastructure. More...

Data Structures

struct  DsmApiCallback_t
 Data structure for dSM-API callback registration. More...

Typedefs

typedef void(* BusChange_callback_t )(void *arg, dsid_t *id, int flag)
 Callback function signature for the BusChange callback.
typedef void(* BusState_callback_t )(void *arg, bus_state_t state)
 Callback function signature for the BusState callback.
typedef void * DsmApiHandle_t
 Type of the library handle.

Functions

int DsmApiCleanup (DsmApiHandle_t handle)
 Free instance memory.
int DsmApiClose (DsmApiHandle_t handle)
 Close the connection to the dS485 bus.
int DsmApiGetBusMembers (DsmApiHandle_t handle, dsid_t *device_list, int device_list_size)
 Request a list of the current bus members.
int DsmApiGetBusState (DsmApiHandle_t handle, bus_state_t *state)
 Get the current state of the dS485 bus.
int DsmApiGetOwnDSID (DsmApiHandle_t handle, dsid_t *dsid)
 Get the dSID of the daeomon/socket interface.
DsmApiHandle_t DsmApiInitialize (void)
 Initialize the internal memory structures of the library.
int DsmApiLibraryVersion (void)
 Get the API version of the library.
int DsmApiOpen (DsmApiHandle_t handle, const char *connection, int flags)
 Open a new connection to the dS485 bus.
int DsmApiSetBusChangeCallback (DsmApiHandle_t handle, DsmApiCallback_t *callback_struct)
 Register a callback function for BusChange events.
int DsmApiSetBusStateCallback (DsmApiHandle_t handle, DsmApiCallback_t *callback_struct)
 Register a callback function for BusState events.
int DsmApiSetCallback (DsmApiHandle_t handle, container_type_t MessageType, uint8_t MessageId, uint8_t ModifierId, DsmApiCallback_t *callback_struct)
 Register callback functions for dsm-api asynchronous responses, requests and events.

Detailed Description

This group of API calls addresses the management of the dS485-Stack, connection to the ds485d daemon and the callback infrastructure.


Typedef Documentation

typedef void(* BusChange_callback_t)(void *arg, dsid_t *id, int flag)

Callback function signature for the BusChange callback.

typedef void(* BusState_callback_t)(void *arg, bus_state_t state)

Callback function signature for the BusState callback.

typedef void* DsmApiHandle_t

Type of the library handle.


Function Documentation

int DsmApiCleanup ( DsmApiHandle_t  handle)

Free instance memory.

Parameters:
[in]handleHandle to the library instance
Returns:
0 on success; negative on failure
int DsmApiClose ( DsmApiHandle_t  handle)

Close the connection to the dS485 bus.

Parameters:
[in]handleHandle to the library instance
Returns:
0 on success; negative on failure
int DsmApiGetBusMembers ( DsmApiHandle_t  handle,
dsid_t device_list,
int  device_list_size 
)

Request a list of the current bus members.

Parameters:
[in]handleHandle to the library instance
[out]device_listList of devices. Preallocate a buffer of size device_list_size * sizeof(dsid_t)
[in]device_list_sizedevice_list has space for this many devices.
Returns:
the number of devices in device_list; negative if an error occured
int DsmApiGetBusState ( DsmApiHandle_t  handle,
bus_state_t state 
)

Get the current state of the dS485 bus.

Parameters:
[in]handleHandle to the library instance
[out]statereturns the bus state
Returns:
0 on success; negative on failure
int DsmApiGetOwnDSID ( DsmApiHandle_t  handle,
dsid_t dsid 
)

Get the dSID of the daeomon/socket interface.

Parameters:
[in]handleHandle to the library instance
[out]dsidown dSID
Returns:
0 on success; negative on failure

Initialize the internal memory structures of the library.

Returns:
a handle to the library instance
int DsmApiLibraryVersion ( void  )

Get the API version of the library.

This function returns the API version as two bytes. The first byte is the MAJOR version, the second byte is the MINOR version. This version corresponds to the ApiVersion parameter read from the dSM with dSMInfo call. Differing MAJOR versions are binary incompatible. Higher MINOR versions contain additional functionality not previously available.

Returns:
API version
int DsmApiOpen ( DsmApiHandle_t  handle,
const char *  connection,
int  flags 
)

Open a new connection to the dS485 bus.

Parameters:
[in]handleHandle to the library instance
[in]connectionstring containing the connection method:
  • serial:///dev/ttyUSB0 (only when linked to the GPL version of the ds485-client library)
  • tcp://localhost:8442
[in]flags
Returns:
zero on success, negative on failure
int DsmApiSetBusChangeCallback ( DsmApiHandle_t  handle,
DsmApiCallback_t callback_struct 
)

Register a callback function for BusChange events.

Register NULL to delete the callback.

Parameters:
[in]handleHandle to the library instance
[in]callback_structa struct containing a callback_function and a user defined argument pointer. Contains the previously registered callback upon return
Returns:
ERROR_OK when ok
int DsmApiSetBusStateCallback ( DsmApiHandle_t  handle,
DsmApiCallback_t callback_struct 
)

Register a callback function for BusState events.

Register NULL to delete the callback.

Parameters:
[in]handleHandle to the library instance
[in]callback_structa struct containing a callback_function and a user defined argument pointer. Contains the previously registered callback upon return
Returns:
ERROR_OK when ok
int DsmApiSetCallback ( DsmApiHandle_t  handle,
container_type_t  MessageType,
uint8_t  MessageId,
uint8_t  ModifierId,
DsmApiCallback_t callback_struct 
)

Register callback functions for dsm-api asynchronous responses, requests and events.

Register NULL to delete a callback.

Parameters:
[in]handleHandle to the library instance
[in]MessageTypeRegister callback function for this MessageType
[in]MessageIdRegister callback function for this MessageId
[in]ModifierIdRegister the callback function for this ModifierId
[in]callback_structa struct containing a callback_function and a user defined argument pointer. Contains the previously registered callback upon return
Returns:
ERROR_OK when ok
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines