mirror of
https://github.com/emqx/neuron.git
synced 2026-10-17 04:40:42 +08:00
chore(modbus):improve log
This commit is contained in:
@@ -90,7 +90,7 @@ static int driver_init(neu_plugin_t *plugin)
|
||||
{
|
||||
plugin->events = neu_event_new();
|
||||
plugin->stack = modbus_stack_create((void *) plugin, modbus_send_msg,
|
||||
modbus_value_handle, modbus_write_resp);
|
||||
modbus_value_handle, modbus_write_resp);
|
||||
plog_notice(plugin, "%s init success", plugin->common.name);
|
||||
|
||||
return 0;
|
||||
@@ -98,6 +98,7 @@ static int driver_init(neu_plugin_t *plugin)
|
||||
|
||||
static int driver_uninit(neu_plugin_t *plugin)
|
||||
{
|
||||
plog_notice(plugin, "%s uninit start", plugin->common.name);
|
||||
if (plugin->conn != NULL) {
|
||||
neu_conn_destory(plugin->conn);
|
||||
}
|
||||
@@ -108,7 +109,7 @@ static int driver_uninit(neu_plugin_t *plugin)
|
||||
|
||||
neu_event_close(plugin->events);
|
||||
|
||||
plog_info(plugin, "node: modbus uninit ok");
|
||||
plog_notice(plugin, "%s uninit success", plugin->common.name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -116,12 +117,14 @@ static int driver_uninit(neu_plugin_t *plugin)
|
||||
static int driver_start(neu_plugin_t *plugin)
|
||||
{
|
||||
neu_conn_start(plugin->conn);
|
||||
plog_notice(plugin, "%s start success", plugin->common.name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int driver_stop(neu_plugin_t *plugin)
|
||||
{
|
||||
neu_conn_stop(plugin->conn);
|
||||
plog_notice(plugin, "%s stop success", plugin->common.name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -138,8 +141,8 @@ static int driver_config(neu_plugin_t *plugin, const char *config)
|
||||
neu_parse_param((char *) config, &err_param, 3, &port, &host, &timeout);
|
||||
|
||||
if (ret != 0) {
|
||||
plog_warn(plugin, "config: %s, decode error: %s", (char *) config,
|
||||
err_param);
|
||||
plog_error(plugin, "config: %s, decode error: %s", (char *) config,
|
||||
err_param);
|
||||
free(err_param);
|
||||
free(host.v.val_str);
|
||||
return -1;
|
||||
@@ -151,8 +154,9 @@ static int driver_config(neu_plugin_t *plugin, const char *config)
|
||||
param.params.tcp_client.port = port.v.val_int;
|
||||
param.params.tcp_client.timeout = timeout.v.val_int;
|
||||
|
||||
plog_info(plugin, "config: host: %s, port: %" PRId64 ", timeout: %" PRId64,
|
||||
host.v.val_str, port.v.val_int, timeout.v.val_int);
|
||||
plog_notice(plugin,
|
||||
"config: host: %s, port: %" PRId64 ", timeout: %" PRId64,
|
||||
host.v.val_str, port.v.val_int, timeout.v.val_int);
|
||||
|
||||
plugin->common.link_state = NEU_NODE_LINK_STATE_DISCONNECTED;
|
||||
if (plugin->conn != NULL) {
|
||||
@@ -182,7 +186,15 @@ static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag)
|
||||
|
||||
int ret = modbus_tag_to_point(tag, &point);
|
||||
if (ret == 0) {
|
||||
plog_debug(
|
||||
plog_notice(
|
||||
plugin,
|
||||
"validate tag success, name: %s, address: %s, type: %d, slave id: "
|
||||
"%d, start address: %d, n register: %d, area: %s",
|
||||
tag->name, tag->address, tag->type, point.slave_id,
|
||||
point.start_address, point.n_register,
|
||||
modbus_area_to_str(point.area));
|
||||
} else {
|
||||
plog_error(
|
||||
plugin,
|
||||
"validate tag error, name: %s, address: %s, type: %d, slave id: "
|
||||
"%d, start address: %d, n register: %d, area: %s",
|
||||
|
||||
Reference in New Issue
Block a user