Merge pull request #8 from lategoodbye/master
Introducing event handling
This commit is contained in:
commit
29aab5b395
@ -1,4 +1,4 @@
|
||||
# This file was generated by Autom4te Sun May 1 09:53:53 UTC 2011.
|
||||
# This file was generated.
|
||||
# It contains the lists of macros which have been traced.
|
||||
# It can be safely removed.
|
||||
|
||||
@ -14,55 +14,55 @@
|
||||
'configure.ac'
|
||||
],
|
||||
{
|
||||
'AM_PROG_F77_C_O' => 1,
|
||||
'_LT_AC_TAGCONFIG' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'AM_PROG_F77_C_O' => 1,
|
||||
'AC_INIT' => 1,
|
||||
'_AM_COND_IF' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'AC_CANONICAL_TARGET' => 1,
|
||||
'AC_SUBST' => 1,
|
||||
'_AM_COND_IF' => 1,
|
||||
'AC_CONFIG_LIBOBJ_DIR' => 1,
|
||||
'AC_FC_SRCEXT' => 1,
|
||||
'AC_SUBST' => 1,
|
||||
'AC_CANONICAL_HOST' => 1,
|
||||
'AC_FC_SRCEXT' => 1,
|
||||
'AC_PROG_LIBTOOL' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AM_PATH_GUILE' => 1,
|
||||
'AC_CONFIG_SUBDIRS' => 1,
|
||||
'AM_PATH_GUILE' => 1,
|
||||
'AM_AUTOMAKE_VERSION' => 1,
|
||||
'LT_CONFIG_LTDL_DIR' => 1,
|
||||
'AC_REQUIRE_AUX_FILE' => 1,
|
||||
'AC_CONFIG_LINKS' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'AC_REQUIRE_AUX_FILE' => 1,
|
||||
'm4_sinclude' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'AM_MAINTAINER_MODE' => 1,
|
||||
'AM_NLS' => 1,
|
||||
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
|
||||
'AM_MAKEFILE_INCLUDE' => 1,
|
||||
'_m4_warn' => 1,
|
||||
'AM_MAKEFILE_INCLUDE' => 1,
|
||||
'AM_PROG_CXX_C_O' => 1,
|
||||
'_AM_MAKEFILE_INCLUDE' => 1,
|
||||
'_AM_COND_ENDIF' => 1,
|
||||
'_AM_MAKEFILE_INCLUDE' => 1,
|
||||
'AM_ENABLE_MULTILIB' => 1,
|
||||
'AM_PROG_MOC' => 1,
|
||||
'AM_SILENT_RULES' => 1,
|
||||
'AC_CONFIG_FILES' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'include' => 1,
|
||||
'AM_PROG_AR' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'AM_GNU_GETTEXT' => 1,
|
||||
'AM_PROG_AR' => 1,
|
||||
'AC_LIBSOURCE' => 1,
|
||||
'AM_PROG_FC_C_O' => 1,
|
||||
'AC_CANONICAL_BUILD' => 1,
|
||||
'AM_PROG_FC_C_O' => 1,
|
||||
'AC_FC_FREEFORM' => 1,
|
||||
'AH_OUTPUT' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'AC_CONFIG_AUX_DIR' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'sinclude' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'AM_XGETTEXT_OPTION' => 1,
|
||||
'AC_CANONICAL_SYSTEM' => 1,
|
||||
'sinclude' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'AC_CANONICAL_SYSTEM' => 1,
|
||||
'AM_XGETTEXT_OPTION' => 1,
|
||||
'AC_CONFIG_HEADERS' => 1,
|
||||
'AC_DEFINE_TRACE_LITERAL' => 1,
|
||||
'AM_POT_TOOLS' => 1,
|
||||
@ -123,8 +123,8 @@
|
||||
'_m4_warn' => 1,
|
||||
'AC_LIBTOOL_OBJDIR' => 1,
|
||||
'gl_FUNC_ARGZ' => 1,
|
||||
'LTOBSOLETE_VERSION' => 1,
|
||||
'AM_SANITY_CHECK' => 1,
|
||||
'LTOBSOLETE_VERSION' => 1,
|
||||
'AC_LIBTOOL_LANG_GCJ_CONFIG' => 1,
|
||||
'AC_LIBTOOL_PROG_COMPILER_PIC' => 1,
|
||||
'LT_LIB_M' => 1,
|
||||
@ -138,19 +138,19 @@
|
||||
'_LT_WITH_SYSROOT' => 1,
|
||||
'LT_SYS_DLOPEN_DEPLIBS' => 1,
|
||||
'LT_FUNC_DLSYM_USCORE' => 1,
|
||||
'AC_LIBTOOL_CONFIG' => 1,
|
||||
'_LT_AC_LANG_F77' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'AC_LIBTOOL_CONFIG' => 1,
|
||||
'AC_LTDL_DLLIB' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'_AM_AUTOCONF_VERSION' => 1,
|
||||
'AM_DISABLE_SHARED' => 1,
|
||||
'_LT_PROG_ECHO_BACKSLASH' => 1,
|
||||
'_LTDL_SETUP' => 1,
|
||||
'AM_PROG_LIBTOOL' => 1,
|
||||
'_LT_AC_LANG_CXX' => 1,
|
||||
'AC_LIB_LTDL' => 1,
|
||||
'_LT_AC_FILE_LTDLL_C' => 1,
|
||||
'AM_PROG_LIBTOOL' => 1,
|
||||
'AM_PROG_LD' => 1,
|
||||
'_LT_AC_FILE_LTDLL_C' => 1,
|
||||
'AC_LIB_LTDL' => 1,
|
||||
'AU_DEFUN' => 1,
|
||||
'AC_PROG_NM' => 1,
|
||||
'AC_LIBTOOL_DLOPEN' => 1,
|
||||
@ -175,33 +175,33 @@
|
||||
'AC_LTDL_OBJDIR' => 1,
|
||||
'_LT_PATH_TOOL_PREFIX' => 1,
|
||||
'AC_LIBTOOL_RC' => 1,
|
||||
'AM_SILENT_RULES' => 1,
|
||||
'AC_DISABLE_FAST_INSTALL' => 1,
|
||||
'_LT_AC_PROG_ECHO_BACKSLASH' => 1,
|
||||
'_LT_AC_SYS_LIBPATH_AIX' => 1,
|
||||
'_LT_AC_TRY_DLOPEN_SELF' => 1,
|
||||
'AC_DISABLE_FAST_INSTALL' => 1,
|
||||
'AM_SILENT_RULES' => 1,
|
||||
'include' => 1,
|
||||
'_LT_AC_TRY_DLOPEN_SELF' => 1,
|
||||
'_LT_AC_SYS_LIBPATH_AIX' => 1,
|
||||
'LT_AC_PROG_SED' => 1,
|
||||
'AM_ENABLE_SHARED' => 1,
|
||||
'LTDL_INSTALLABLE' => 1,
|
||||
'_LT_AC_LANG_GCJ_CONFIG' => 1,
|
||||
'AC_ENABLE_SHARED' => 1,
|
||||
'AC_ENABLE_STATIC' => 1,
|
||||
'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1,
|
||||
'_LT_REQUIRED_DARWIN_CHECKS' => 1,
|
||||
'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1,
|
||||
'AC_ENABLE_STATIC' => 1,
|
||||
'_LT_AC_TAGVAR' => 1,
|
||||
'AC_LIBTOOL_LANG_F77_CONFIG' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'LT_LIB_DLLOAD' => 1,
|
||||
'LTDL_INIT' => 1,
|
||||
'_LT_PROG_F77' => 1,
|
||||
'_LT_PROG_CXX' => 1,
|
||||
'LTVERSION_VERSION' => 1,
|
||||
'AM_PROG_INSTALL_SH' => 1,
|
||||
'_LT_PROG_CXX' => 1,
|
||||
'_LT_PROG_F77' => 1,
|
||||
'LTDL_INIT' => 1,
|
||||
'm4_include' => 1,
|
||||
'AM_PROG_INSTALL_SH' => 1,
|
||||
'AC_PROG_EGREP' => 1,
|
||||
'_AC_AM_CONFIG_HEADER_HOOK' => 1,
|
||||
'AC_PATH_MAGIC' => 1,
|
||||
'_AC_AM_CONFIG_HEADER_HOOK' => 1,
|
||||
'AC_LTDL_SYSSEARCHPATH' => 1,
|
||||
'AM_MAKE_INCLUDE' => 1,
|
||||
'LT_CMD_MAX_LEN' => 1,
|
||||
@ -235,11 +235,11 @@
|
||||
'_AC_PROG_LIBTOOL' => 1,
|
||||
'_AM_IF_OPTION' => 1,
|
||||
'AC_PATH_TOOL_PREFIX' => 1,
|
||||
'AC_LIBTOOL_F77' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'AC_LIBTOOL_F77' => 1,
|
||||
'AM_SET_LEADING_DOT' => 1,
|
||||
'LT_AC_PROG_EGREP' => 1,
|
||||
'_LT_PROG_FC' => 1,
|
||||
'LT_AC_PROG_EGREP' => 1,
|
||||
'_AM_DEPENDENCIES' => 1,
|
||||
'AC_LIBTOOL_LANG_C_CONFIG' => 1,
|
||||
'LTOPTIONS_VERSION' => 1,
|
||||
@ -247,11 +247,11 @@
|
||||
'AM_PROG_NM' => 1,
|
||||
'AC_LIBLTDL_CONVENIENCE' => 1,
|
||||
'AC_DEPLIBS_CHECK_METHOD' => 1,
|
||||
'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1,
|
||||
'AC_LIBLTDL_INSTALLABLE' => 1,
|
||||
'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1,
|
||||
'AC_LTDL_ENABLE_INSTALL' => 1,
|
||||
'AC_LIBTOOL_SYS_DYNAMIC_LINKER' => 1,
|
||||
'LT_PROG_GCJ' => 1,
|
||||
'AC_LIBTOOL_SYS_DYNAMIC_LINKER' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AC_DISABLE_STATIC' => 1,
|
||||
'LT_PATH_NM' => 1,
|
||||
@ -259,25 +259,25 @@
|
||||
'_LT_AC_LOCK' => 1,
|
||||
'_LT_AC_LANG_RC_CONFIG' => 1,
|
||||
'LT_SYS_MODULE_PATH' => 1,
|
||||
'AC_LIBTOOL_POSTDEP_PREDEP' => 1,
|
||||
'LT_WITH_LTDL' => 1,
|
||||
'AC_LIBTOOL_POSTDEP_PREDEP' => 1,
|
||||
'AC_LTDL_SHLIBPATH' => 1,
|
||||
'AM_AUX_DIR_EXPAND' => 1,
|
||||
'_LT_AC_LANG_F77_CONFIG' => 1,
|
||||
'AC_LIBTOOL_PROG_COMPILER_NO_RTTI' => 1,
|
||||
'_AM_SET_OPTIONS' => 1,
|
||||
'_LT_AC_LANG_F77_CONFIG' => 1,
|
||||
'_LT_COMPILER_OPTION' => 1,
|
||||
'_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
|
||||
'_AM_SET_OPTIONS' => 1,
|
||||
'AM_RUN_LOG' => 1,
|
||||
'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1,
|
||||
'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1,
|
||||
'_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1,
|
||||
'AC_LIBTOOL_PICMODE' => 1,
|
||||
'LT_PATH_LD' => 1,
|
||||
'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1,
|
||||
'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1,
|
||||
'AC_CHECK_LIBM' => 1,
|
||||
'LT_PATH_LD' => 1,
|
||||
'AC_LIBTOOL_SYS_LIB_STRIP' => 1,
|
||||
'_AM_MANGLE_OPTION' => 1,
|
||||
'AC_LTDL_SYMBOL_USCORE' => 1,
|
||||
'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1,
|
||||
'AC_LTDL_SYMBOL_USCORE' => 1,
|
||||
'AM_SET_DEPDIR' => 1,
|
||||
'_LT_CC_BASENAME' => 1,
|
||||
'_LT_LIBOBJ' => 1
|
||||
@ -295,55 +295,55 @@
|
||||
'configure.ac'
|
||||
],
|
||||
{
|
||||
'_LT_AC_TAGCONFIG' => 1,
|
||||
'AM_PROG_F77_C_O' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'_LT_AC_TAGCONFIG' => 1,
|
||||
'AC_INIT' => 1,
|
||||
'_AM_COND_IF' => 1,
|
||||
'm4_pattern_forbid' => 1,
|
||||
'AC_CANONICAL_TARGET' => 1,
|
||||
'AC_SUBST' => 1,
|
||||
'_AM_COND_IF' => 1,
|
||||
'AC_CONFIG_LIBOBJ_DIR' => 1,
|
||||
'AC_FC_SRCEXT' => 1,
|
||||
'AC_SUBST' => 1,
|
||||
'AC_CANONICAL_HOST' => 1,
|
||||
'AC_FC_SRCEXT' => 1,
|
||||
'AC_PROG_LIBTOOL' => 1,
|
||||
'AM_INIT_AUTOMAKE' => 1,
|
||||
'AM_PATH_GUILE' => 1,
|
||||
'AC_CONFIG_SUBDIRS' => 1,
|
||||
'AM_PATH_GUILE' => 1,
|
||||
'AM_AUTOMAKE_VERSION' => 1,
|
||||
'LT_CONFIG_LTDL_DIR' => 1,
|
||||
'AC_REQUIRE_AUX_FILE' => 1,
|
||||
'AC_CONFIG_LINKS' => 1,
|
||||
'm4_sinclude' => 1,
|
||||
'AC_REQUIRE_AUX_FILE' => 1,
|
||||
'LT_SUPPORTED_TAG' => 1,
|
||||
'm4_sinclude' => 1,
|
||||
'AM_MAINTAINER_MODE' => 1,
|
||||
'AM_NLS' => 1,
|
||||
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
|
||||
'AM_MAKEFILE_INCLUDE' => 1,
|
||||
'_m4_warn' => 1,
|
||||
'AM_MAKEFILE_INCLUDE' => 1,
|
||||
'AM_PROG_CXX_C_O' => 1,
|
||||
'_AM_COND_ENDIF' => 1,
|
||||
'_AM_MAKEFILE_INCLUDE' => 1,
|
||||
'_AM_COND_ENDIF' => 1,
|
||||
'AM_ENABLE_MULTILIB' => 1,
|
||||
'AM_SILENT_RULES' => 1,
|
||||
'AM_PROG_MOC' => 1,
|
||||
'AC_CONFIG_FILES' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'include' => 1,
|
||||
'AM_PROG_AR' => 1,
|
||||
'LT_INIT' => 1,
|
||||
'AM_GNU_GETTEXT' => 1,
|
||||
'AM_PROG_AR' => 1,
|
||||
'AC_LIBSOURCE' => 1,
|
||||
'AM_PROG_FC_C_O' => 1,
|
||||
'AC_CANONICAL_BUILD' => 1,
|
||||
'AM_PROG_FC_C_O' => 1,
|
||||
'AC_FC_FREEFORM' => 1,
|
||||
'AH_OUTPUT' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'AC_CONFIG_AUX_DIR' => 1,
|
||||
'sinclude' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'_AM_SUBST_NOTMAKE' => 1,
|
||||
'm4_pattern_allow' => 1,
|
||||
'AM_XGETTEXT_OPTION' => 1,
|
||||
'AC_CANONICAL_SYSTEM' => 1,
|
||||
'AM_PROG_CC_C_O' => 1,
|
||||
'sinclude' => 1,
|
||||
'AM_CONDITIONAL' => 1,
|
||||
'AC_CANONICAL_SYSTEM' => 1,
|
||||
'AM_XGETTEXT_OPTION' => 1,
|
||||
'AC_CONFIG_HEADERS' => 1,
|
||||
'AC_DEFINE_TRACE_LITERAL' => 1,
|
||||
'AM_POT_TOOLS' => 1,
|
||||
|
@ -25,6 +25,30 @@ static char error_str[512];
|
||||
//------------------------------------------------------------------------------
|
||||
static mbus_slave_data slave_data[MBUS_MAX_PRIMARY_SLAVES];
|
||||
|
||||
//
|
||||
// init event callback
|
||||
//
|
||||
void (*_mbus_recv_event)(u_char src_type) = NULL;
|
||||
void (*_mbus_send_event)(u_char src_type) = NULL;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Register a function for receive events.
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
mbus_register_recv_event(void (*event)(u_char src_type))
|
||||
{
|
||||
_mbus_recv_event = event;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Register a function for send events.
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
mbus_register_send_event(void (*event)(u_char src_type))
|
||||
{
|
||||
_mbus_send_event = event;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Return a string that contains an the latest error message.
|
||||
//------------------------------------------------------------------------------
|
||||
@ -292,11 +316,11 @@ mbus_frame_verify(mbus_frame *frame)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((frame->control != MBUS_CONTROL_MASK_SND_NKE) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_REQ_UD1) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_REQ_UD1 | MBUS_CONTROL_MASK_FCB) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_REQ_UD2) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_REQ_UD2 | MBUS_CONTROL_MASK_FCB))
|
||||
if ((frame->control != MBUS_CONTROL_MASK_SND_NKE) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_REQ_UD1) &&
|
||||
(frame->control != (MBUS_CONTROL_MASK_REQ_UD1 | MBUS_CONTROL_MASK_FCB)) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_REQ_UD2) &&
|
||||
(frame->control != (MBUS_CONTROL_MASK_REQ_UD2 | MBUS_CONTROL_MASK_FCB)))
|
||||
{
|
||||
snprintf(error_str, sizeof(error_str), "Unknown Control Code 0x%.2x", frame->control);
|
||||
|
||||
@ -315,12 +339,12 @@ mbus_frame_verify(mbus_frame *frame)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((frame->control != MBUS_CONTROL_MASK_SND_UD) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_SND_UD | MBUS_CONTROL_MASK_FCB) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_RSP_UD) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_RSP_UD | MBUS_CONTROL_MASK_DFC) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_RSP_UD | MBUS_CONTROL_MASK_ACD) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_RSP_UD | MBUS_CONTROL_MASK_DFC | MBUS_CONTROL_MASK_ACD))
|
||||
if ((frame->control != MBUS_CONTROL_MASK_SND_UD) &&
|
||||
(frame->control != (MBUS_CONTROL_MASK_SND_UD | MBUS_CONTROL_MASK_FCB)) &&
|
||||
(frame->control != MBUS_CONTROL_MASK_RSP_UD) &&
|
||||
(frame->control != (MBUS_CONTROL_MASK_RSP_UD | MBUS_CONTROL_MASK_DFC)) &&
|
||||
(frame->control != (MBUS_CONTROL_MASK_RSP_UD | MBUS_CONTROL_MASK_ACD)) &&
|
||||
(frame->control != (MBUS_CONTROL_MASK_RSP_UD | MBUS_CONTROL_MASK_DFC | MBUS_CONTROL_MASK_ACD)))
|
||||
{
|
||||
snprintf(error_str, sizeof(error_str), "Unknown Control Code 0x%.2x", frame->control);
|
||||
|
||||
@ -3021,7 +3045,7 @@ mbus_data_variable_header_xml(mbus_data_variable_header *header)
|
||||
/// Generate XML for a single variable-length data record
|
||||
//------------------------------------------------------------------------------
|
||||
char *
|
||||
mbus_data_variable_record_xml(mbus_data_record *record, int record_cnt, int frame_cnt)
|
||||
mbus_data_variable_record_xml(mbus_data_record *record, int record_cnt, int frame_cnt, mbus_data_variable_header *header)
|
||||
{
|
||||
static char buff[8192];
|
||||
char str_encoded[768];
|
||||
@ -3095,7 +3119,7 @@ mbus_data_variable_xml(mbus_data_variable *data)
|
||||
for (record = data->record, i = 0; record; record = record->next, i++)
|
||||
{
|
||||
len += snprintf(&buff[len], sizeof(buff) - len, "%s",
|
||||
mbus_data_variable_record_xml(record, i, -1));
|
||||
mbus_data_variable_record_xml(record, i, -1, &(data->header)));
|
||||
}
|
||||
len += snprintf(&buff[len], sizeof(buff) - len, "</MBusData>\n");
|
||||
|
||||
@ -3285,7 +3309,7 @@ mbus_frame_xml(mbus_frame *frame)
|
||||
for (record = frame_data.data_var.record; record; record = record->next, record_cnt++)
|
||||
{
|
||||
len += snprintf(&buff[len], sizeof(buff) - len, "%s",
|
||||
mbus_data_variable_record_xml(record, record_cnt, frame_cnt));
|
||||
mbus_data_variable_record_xml(record, record_cnt, frame_cnt, &(frame_data.data_var.header)));
|
||||
}
|
||||
|
||||
// free all records in the list
|
||||
@ -3309,7 +3333,7 @@ mbus_frame_xml(mbus_frame *frame)
|
||||
for (record = frame_data.data_var.record; record; record = record->next, record_cnt++)
|
||||
{
|
||||
len += snprintf(&buff[len], sizeof(buff) - len, "%s",
|
||||
mbus_data_variable_record_xml(record, record_cnt, frame_cnt));
|
||||
mbus_data_variable_record_xml(record, record_cnt, frame_cnt, &(frame_data.data_var.header)));
|
||||
}
|
||||
|
||||
// free all records in the list
|
||||
|
@ -99,6 +99,12 @@ typedef struct _mbus_slave_data {
|
||||
|
||||
#define NITEMS(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
//
|
||||
// Supported handle types
|
||||
//
|
||||
#define MBUS_HANDLE_TYPE_TCP 0
|
||||
#define MBUS_HANDLE_TYPE_SERIAL 1
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MBUS FRAME DATA FORMATS
|
||||
//
|
||||
@ -453,6 +459,17 @@ typedef struct _mbus_data_secondary_address {
|
||||
#define MBUS_VARIABLE_DATA_MEDIUM_PRESSURE 0x18
|
||||
#define MBUS_VARIABLE_DATA_MEDIUM_ADC 0x19
|
||||
|
||||
//
|
||||
// Event callback functions
|
||||
//
|
||||
extern void (*_mbus_recv_event)(u_char src_type);
|
||||
extern void (*_mbus_send_event)(u_char src_type);
|
||||
|
||||
//
|
||||
// Event register functions
|
||||
//
|
||||
void mbus_register_recv_event(void (*event)(u_char src_type));
|
||||
void mbus_register_send_event(void (*event)(u_char src_type));
|
||||
|
||||
//
|
||||
// variable length records
|
||||
|
@ -166,7 +166,7 @@ mbus_serial_send_frame(mbus_serial_handle *handle, mbus_frame *frame)
|
||||
fprintf(stderr, "%s: mbus_frame_pack failed\n", __PRETTY_FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MBUS_SERIAL_DEBUG
|
||||
// if debug, dump in HEX form to stdout what we write to the serial port
|
||||
printf("%s: Dumping M-Bus frame [%d bytes]: ", __PRETTY_FUNCTION__, len);
|
||||
@ -177,7 +177,15 @@ mbus_serial_send_frame(mbus_serial_handle *handle, mbus_frame *frame)
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
if ((ret = write(handle->fd, buff, len)) != len)
|
||||
if ((ret = write(handle->fd, buff, len)) == len)
|
||||
{
|
||||
//
|
||||
// call the send event function, if the callback function is registered
|
||||
//
|
||||
if (_mbus_send_event)
|
||||
_mbus_send_event(MBUS_HANDLE_TYPE_SERIAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: Failed to write frame to socket (ret = %d: %s)\n", __PRETTY_FUNCTION__, ret, strerror(errno));
|
||||
return -1;
|
||||
@ -206,7 +214,17 @@ mbus_serial_recv_frame(mbus_serial_handle *handle, mbus_frame *frame)
|
||||
do {
|
||||
//printf("%s: Attempt to read %d bytes [len = %d]\n", __PRETTY_FUNCTION__, remaining, len);
|
||||
|
||||
if ((nread = read(handle->fd, &buff[len], remaining)) == -1)
|
||||
nread = read(handle->fd, &buff[len], remaining);
|
||||
|
||||
if (nread > 0)
|
||||
{
|
||||
//
|
||||
// call the receive event function, if the callback function is registered
|
||||
//
|
||||
if (_mbus_recv_event)
|
||||
_mbus_recv_event(MBUS_HANDLE_TYPE_SERIAL);
|
||||
}
|
||||
else if (nread == -1)
|
||||
{
|
||||
// fprintf(stderr, "%s: aborting recv frame (remaining = %d, len = %d, nread = %d)\n",
|
||||
// __PRETTY_FUNCTION__, remaining, len, nread);
|
||||
|
@ -138,7 +138,15 @@ mbus_tcp_send_frame(mbus_tcp_handle *handle, mbus_frame *frame)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ret = write(handle->sock, buff, len)) != len)
|
||||
if ((ret = write(handle->sock, buff, len)) == len)
|
||||
{
|
||||
//
|
||||
// call the send event function, if the callback function is registered
|
||||
//
|
||||
if (_mbus_send_event)
|
||||
_mbus_send_event(MBUS_HANDLE_TYPE_TCP);
|
||||
}
|
||||
else
|
||||
{
|
||||
char error_str[128];
|
||||
snprintf(error_str, sizeof(error_str), "%s: Failed to write frame to socket (ret = %d)\n", __PRETTY_FUNCTION__, ret);
|
||||
@ -167,8 +175,18 @@ mbus_tcp_recv_frame(mbus_tcp_handle *handle, mbus_frame *frame)
|
||||
len = 0;
|
||||
|
||||
do {
|
||||
|
||||
nread = read(handle->sock, &buff[len], remaining);
|
||||
|
||||
if ((nread = read(handle->sock, &buff[len], remaining)) == -1)
|
||||
if (nread > 0)
|
||||
{
|
||||
//
|
||||
// call the receive event function, if the callback function is registered
|
||||
//
|
||||
if (_mbus_recv_event)
|
||||
_mbus_recv_event(MBUS_HANDLE_TYPE_TCP);
|
||||
}
|
||||
else if (nread == -1)
|
||||
{
|
||||
mbus_error_str_set("M-Bus tcp transport layer failed to read data.");
|
||||
return -1;
|
||||
|
@ -89,7 +89,8 @@ main(int argc, char *argv[])
|
||||
|
||||
//mbus_frame_print(&reply);
|
||||
//mbus_frame_data_print(&frame_data);
|
||||
printf("%s", mbus_frame_data_xml(&frame_data));
|
||||
printf("%s", mbus_frame_data_xml_normalized(&frame_data));
|
||||
// printf("%s", mbus_frame_data_xml(&frame_data));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
<DataRecord id="0">
|
||||
<Function>Manufacturer specific</Function>
|
||||
<Value>5F 42 01 11 FF FF FF FF 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00</Value>
|
||||
</DataRecord>
|
||||
|
||||
</MBusData>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<Id>6855817</Id>
|
||||
<Manufacturer>KAM</Manufacturer>
|
||||
<Version>8</Version>
|
||||
<Medium>Heat</Medium>
|
||||
<Medium>Heat: Outlet</Medium>
|
||||
<AccessNumber>4</AccessNumber>
|
||||
<Status>00</Status>
|
||||
<Signature>0000</Signature>
|
||||
@ -174,6 +174,7 @@
|
||||
|
||||
<DataRecord id="27">
|
||||
<Function>Manufacturer specific</Function>
|
||||
<Value>00 00 00 00 E7 E4 00 00 63 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5B C9 A5 02 34 53 00 00 E0 B2 03 00 89 9C 68 00 00 00 00 00 01 00 01 07 07 09 01 03 00 00 00 00 00</Value>
|
||||
</DataRecord>
|
||||
|
||||
</MBusData>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<Id>1006089</Id>
|
||||
<Manufacturer>SVM</Manufacturer>
|
||||
<Version>9</Version>
|
||||
<Medium>Heat (Volume measured at flow temperature: inlet)</Medium>
|
||||
<Medium>Heat: Inlet</Medium>
|
||||
<AccessNumber>148</AccessNumber>
|
||||
<Status>70</Status>
|
||||
<Signature>0000</Signature>
|
||||
@ -89,7 +89,8 @@
|
||||
</DataRecord>
|
||||
|
||||
<DataRecord id="13">
|
||||
<Function>Manufacturer specific</Function>
|
||||
<Function>More records follow</Function>
|
||||
<Value></Value>
|
||||
</DataRecord>
|
||||
|
||||
</MBusData>
|
||||
|
Loading…
x
Reference in New Issue
Block a user