Utility functions for data conversions API

Functions to convert KNX-specific data types to/from C-type variables. More...


Functions

unsigned int enmx_eis2value (int eis, unsigned char *datastream, int length, void *value)
 Convert KNX data stream - as returned by enmx_read() - to C variable.
unsigned int enmx_frame2value (int eis, void *cemiframe, void *value)
 Extract data from CEMI frame - as returned by enmx_monitor() - and convert to C variable.
int enmx_value2eis (int eis, void *value, unsigned char *datastream)
 Convert C variable to KNX data stream.
ENMX_ADDRESS enmx_getaddress (const char *KNXgroup)
 Convert KNX group address to ENMX_ADDRESS.
char * enmx_getgroup (ENMX_ADDRESS knxaddress)
 Convert KNX group address to string.

Variables

int enmx_EISsizeC [16] = { -1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 1, 4, 15 }
 Variable sizes for EIS types.
int enmx_EISsizeKNX [16] = { -1, 1, 1, 4, 4, 3, 2, 1, 1, 5, 3, 5, 5, 2, 2, 15 }
 Buffer sizes for EIS types.

Detailed Description

Functions to convert KNX-specific data types to/from C-type variables.

This API supports the following features:


Function Documentation

unsigned int enmx_eis2value ( int  eis,
unsigned char *  datastream,
int  length,
void *  value 
)

Convert KNX data stream - as returned by enmx_read() - to C variable.

Requests sent on the KNX bus have no indication as to how its data should be interpreted. Knowledge of the data format is part of the KNX group definition or assignment, respectively. It is expressed as the EIS (EIB Interchange Standard), a number in the range of 1-15 which defines the data type.

Given the correct EIS, this function allows to easily convert the data part of a KNX request to a C variable which then can be used for further calculations or displaying.

ATTENTION: Caller must ensure that buffer is large enough to hold result See enmx_EISsizeC[].

Parameters:
eis EIS type (range 1-15)
datastream pointer to KNX data stream as returned by enmx_read()
length length of KNX data stream
value pointer to the buffer receiving the converted result
Returns:
number indicating type of result (-1: error, 0: integer, 1: float: 2: char, 3:string)
Examples:
eibread.c.

unsigned int enmx_frame2value ( int  eis,
void *  cemiframe,
void *  value 
)

Extract data from CEMI frame - as returned by enmx_monitor() - and convert to C variable.

Requests sent on the KNX bus have no indication as to how its data should be interpreted. Knowledge of the data format is part of the KNX group definition or assignment, respectively. It is expressed as the EIS (EIB Interchange Standard), a number in the range of 1-15 which defines the data type.

Given the correct EIS, this function allows to easily convert the data part of a KNX request to a C variable which then can be used for further calculations or displaying.

ATTENTION: Caller must ensure that buffer is large enough to hold result See enmx_EISsizeC[].

Parameters:
eis EIS type (range 1-15)
cemiframe pointer to CEMIFRAME as returned by enmx_monitor()
value pointer to the buffer receiving the converted result
Returns:
number indicating type of result (-1: error, 0: integer, 1: float: 2: char, 3:string)
Examples:
eibtrace.c.

ENMX_ADDRESS enmx_getaddress ( const char *  KNXgroup  ) 

Convert KNX group address to ENMX_ADDRESS.

The KNX bus and, consequently, this library use a 16-bit integer to address a specific group. The value is formatted as follows:

      0mmm msss gggg gggg
where
  • m = maingroup
  • s = subgroup
  • g = group

This function converts a human-readable KNX group address of the form "x/y/z" to the 16-bit integer ENMX_ADDRESS.

Parameters:
KNXgroup group address, string in the form "x/y/z"
Returns:
ENMX_ADDRESS or -1 in case of an error
Examples:
eibcommand.c, and eibread.c.

char* enmx_getgroup ( ENMX_ADDRESS  knxaddress  ) 

Convert KNX group address to string.

The KNX bus and, consequently, this library use a 16-bit integer to address a specific group. The value is formatted as follows:

      0mmm msss gggg gggg
where
  • m = maingroup
  • s = subgroup
  • g = group

This function converts a 16-bit integer ENMX_ADDRESS into a human-readable KNX group address of the form "x/y/z".

ATTENTION: caller has to release returned buffer

Parameters:
knxaddress encoded KNX group address
Returns:
string containing KNX group address or NULL upon error
Examples:
eibcommand.c.

int enmx_value2eis ( int  eis,
void *  value,
unsigned char *  datastream 
)

Convert C variable to KNX data stream.

Requests sent on the KNX bus have no indication as to how its data should be interpreted. Knowledge of the data format is part of the KNX group definition or assignment, respectively. It is expressed as the EIS (EIB Interchange Standard), a number in the range of 1-15 which defines the data type.

Given the correct EIS, this function allows to easily create the data part of a KNX request from a C variable. The result can be used directly for enmx_write().

ATTENTION: Caller must ensure that buffer is large enough to hold result. See enmx_EISsizeKNX[].

Parameters:
eis EIS type (range 1-15)
value pointer to the buffer containing the C variable
datastream pointer to the buffer receiving the converted result
Returns:
0: ok, -1: error
Examples:
eibcommand.c.


Variable Documentation

int enmx_EISsizeC[16] = { -1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 1, 4, 15 }

Variable sizes for EIS types.

Client application developers can use the following table to determine the minimum buffer size required to convert KNX data to a C variable.

Retrieve the size as:

where 'eis' stands for the EIS number.

int enmx_EISsizeKNX[16] = { -1, 1, 1, 4, 4, 3, 2, 1, 1, 5, 3, 5, 5, 2, 2, 15 }

Buffer sizes for EIS types.

Client application developers can use the following table to determine the minimum buffer size required to convert a C variable to a KNX data stream.

Retrieve the size as:

where 'eis' stands for the EIS number.
Examples:
eibcommand.c.