diff --git a/libipm/ercp.c b/libipm/ercp.c index a5ba61c9..e048f5fb 100644 --- a/libipm/ercp.c +++ b/libipm/ercp.c @@ -81,6 +81,32 @@ ercp_trans_from_eicp_trans(struct trans *trans, /*****************************************************************************/ +struct trans * +ercp_connect(const char *port, int (*term_func)(void)) +{ + struct trans *t; + + if ((t = trans_create(TRANS_MODE_UNIX, 128, 128)) != NULL) + { + t->is_term = term_func; + + if (trans_connect(t, NULL, port, 3000) != 0) + { + trans_delete(t); + t = NULL; + } + else if (ercp_init_trans(t) != 0) + { + trans_delete(t); + t = NULL; + } + } + + return t; +} + +/*****************************************************************************/ + int ercp_msg_in_check_available(struct trans *trans, int *available) { diff --git a/libipm/ercp.h b/libipm/ercp.h index aac0a8d6..c77bf984 100644 --- a/libipm/ercp.h +++ b/libipm/ercp.h @@ -88,6 +88,16 @@ ercp_trans_from_eicp_trans(struct trans *trans, ttrans_data_in callback_func, void *callback_data); +/** + * Connects to an ERCP endpoint. + * + * @param port Path to UDS object in filesystem + * @param term_func Function to poll during connection for program + * termination, or NULL for none. + */ +struct trans * +ercp_connect(const char *port, + int (*term_func)(void)); /** * Checks an ERCP transport to see if a complete message is