Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/neuron/event/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef struct neu_events neu_events_t;
* thread.
* @return the newly created event.
*/
neu_events_t *neu_event_new(void);
neu_events_t *neu_event_new(const char *name);

/**
* @brief Close a event.
Expand Down Expand Up @@ -71,7 +71,7 @@ typedef struct neu_event_timer_param {
* @param[in] timer Parameters when creating timer.
* @return The added event timer.
*/
neu_event_timer_t *neu_event_add_timer(neu_events_t * events,
neu_event_timer_t *neu_event_add_timer(neu_events_t *events,
neu_event_timer_param_t timer);

/**
Expand Down
8 changes: 4 additions & 4 deletions plugins/modbus/modbus_rtu.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ static int driver_init(neu_plugin_t *plugin, bool load)
{
(void) load;
plugin->protocol = MODBUS_PROTOCOL_RTU;
plugin->events = neu_event_new();
plugin->events = neu_event_new(plugin->common.name);
plugin->stack = modbus_stack_create((void *) plugin, MODBUS_PROTOCOL_RTU,
modbus_send_msg, modbus_value_handle,
modbus_write_resp);
modbus_send_msg, modbus_value_handle,
modbus_write_resp);

plog_notice(plugin, "%s init success", plugin->common.name);
return 0;
Expand Down Expand Up @@ -146,7 +146,7 @@ static int driver_stop(neu_plugin_t *plugin)
static int driver_config(neu_plugin_t *plugin, const char *config)
{
int ret = 0;
char * err_param = NULL;
char *err_param = NULL;
neu_conn_param_t param = { 0 };

neu_json_elem_t link = { .name = "link", .t = NEU_JSON_INT };
Expand Down
16 changes: 8 additions & 8 deletions plugins/modbus/modbus_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ static int driver_init(neu_plugin_t *plugin, bool load)
{
(void) load;
plugin->protocol = MODBUS_PROTOCOL_TCP;
plugin->events = neu_event_new();
plugin->events = neu_event_new(plugin->common.name);
plugin->stack = modbus_stack_create((void *) plugin, MODBUS_PROTOCOL_TCP,
modbus_send_msg, modbus_value_handle,
modbus_write_resp);
modbus_send_msg, modbus_value_handle,
modbus_write_resp);

plog_notice(plugin, "%s init success", plugin->common.name);
return 0;
Expand Down Expand Up @@ -146,20 +146,20 @@ static int driver_stop(neu_plugin_t *plugin)
static int driver_config(neu_plugin_t *plugin, const char *config)
{
int ret = 0;
char * err_param = NULL;
char *err_param = NULL;
neu_json_elem_t port = { .name = "port", .t = NEU_JSON_INT };
neu_json_elem_t timeout = { .name = "timeout", .t = NEU_JSON_INT };
neu_json_elem_t host = { .name = "host",
.t = NEU_JSON_STR,
.v.val_str = NULL };
.t = NEU_JSON_STR,
.v.val_str = NULL };
neu_json_elem_t interval = { .name = "interval", .t = NEU_JSON_INT };
neu_json_elem_t mode = { .name = "connection_mode", .t = NEU_JSON_INT };
neu_conn_param_t param = { 0 };
neu_json_elem_t max_retries = { .name = "max_retries", .t = NEU_JSON_INT };
neu_json_elem_t retry_interval = { .name = "retry_interval",
.t = NEU_JSON_INT };
.t = NEU_JSON_INT };
neu_json_elem_t endianess_64 = { .name = "endianess_64",
.t = NEU_JSON_INT };
.t = NEU_JSON_INT };

ret = neu_parse_param((char *) config, &err_param, 5, &port, &host, &mode,
&timeout, &interval);
Expand Down
18 changes: 9 additions & 9 deletions simulator/modbus_simulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include "modbus_s.h"

zlog_category_t *neuron = NULL;
neu_events_t * events = NULL;
neu_event_io_t * tcp_server_event = NULL;
neu_conn_t * conn = NULL;
neu_events_t *events = NULL;
neu_event_io_t *tcp_server_event = NULL;
neu_conn_t *conn = NULL;
int64_t global_timestamp = 0;
bool exiting = false;

Expand All @@ -45,7 +45,7 @@ static bool mode_tcp = true;
struct client_event {
neu_event_io_t *client;
int fd;
void * user_data;
void *user_data;
};

struct client_event c_events[10] = { 0 };
Expand Down Expand Up @@ -146,7 +146,7 @@ int main(int argc, char *argv[])
.params.tcp_server.stop_listen = stop_listen,
};

events = neu_event_new();
events = neu_event_new("modbus_simulator");
conn = neu_conn_new(&param, NULL, connected, disconnected);

signal(SIGINT, sig_handler);
Expand Down Expand Up @@ -202,11 +202,11 @@ static int new_client(enum neu_event_io_type type, int fd, void *usr_data)
case NEU_EVENT_IO_READ: {
int client_fd = neu_conn_tcp_server_accept(conn);
if (client_fd > 0) {
struct cycle_buf * buf = calloc(1, sizeof(struct cycle_buf));
struct cycle_buf *buf = calloc(1, sizeof(struct cycle_buf));
neu_event_io_param_t io = {
.fd = client_fd,
.usr_data = (void *) buf,
.cb = recv_msg,
.fd = client_fd,
.usr_data = (void *) buf,
.cb = recv_msg,
};

neu_event_io_t *client = neu_event_add_io(events, io);
Expand Down
24 changes: 12 additions & 12 deletions src/adapter/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int adapter_command(neu_adapter_t *adapter, neu_reqresp_head_t header,
void *data);
static int adapter_response(neu_adapter_t *adapter, neu_reqresp_head_t *header,
void *data);
static int adapter_responseto(neu_adapter_t * adapter,
static int adapter_responseto(neu_adapter_t *adapter,
neu_reqresp_head_t *header, void *data,
struct sockaddr_in dst);
static int adapter_register_metric(neu_adapter_t *adapter, const char *name,
Expand Down Expand Up @@ -115,7 +115,7 @@ static void *adapter_consumer(void *arg)
{
neu_adapter_t *adapter = (neu_adapter_t *) arg;
while (1) {
neu_msg_t * msg = NULL;
neu_msg_t *msg = NULL;
uint32_t n = adapter_msg_q_pop(adapter->msg_q, &msg);
neu_reqresp_head_t *header = neu_msg_get_header(msg);

Expand Down Expand Up @@ -145,7 +145,7 @@ neu_adapter_t *neu_adapter_create(neu_adapter_info_t *info, bool load)
{
int rv = 0;
int init_rv = 0;
neu_adapter_t * adapter = NULL;
neu_adapter_t *adapter = NULL;
neu_event_io_param_t param = { 0 };

switch (info->module->type) {
Expand Down Expand Up @@ -173,7 +173,7 @@ neu_adapter_t *neu_adapter_create(neu_adapter_info_t *info, bool load)
}

adapter->name = strdup(info->name);
adapter->events = neu_event_new();
adapter->events = neu_event_new("adapter");
adapter->state = NEU_NODE_RUNNING_STATE_INIT;
adapter->handle = info->handle;
adapter->cb_funs.command = callback_funs.command;
Expand Down Expand Up @@ -563,7 +563,7 @@ static int adapter_response(neu_adapter_t *adapter, neu_reqresp_head_t *header,
return ret;
}

static int adapter_responseto(neu_adapter_t * adapter,
static int adapter_responseto(neu_adapter_t *adapter,
neu_reqresp_head_t *header, void *data,
struct sockaddr_in dst)
{
Expand Down Expand Up @@ -878,7 +878,7 @@ static int adapter_loop(enum neu_event_io_type type, int fd, void *usr_data)
case NEU_REQ_GET_TAG: {
neu_req_get_tag_t *cmd = (neu_req_get_tag_t *) &header[1];
neu_resp_error_t error = { .error = 0 };
UT_array * tags = NULL;
UT_array *tags = NULL;

if (adapter->module->type == NEU_NA_TYPE_DRIVER) {
error.error = neu_adapter_driver_query_tag(
Expand Down Expand Up @@ -1229,7 +1229,7 @@ static int adapter_loop(enum neu_event_io_type type, int fd, void *usr_data)
neu_req_get_ndriver_tags_t *cmd =
(neu_req_get_ndriver_tags_t *) &header[1];
neu_resp_error_t error = { .error = 0 };
UT_array * tags = NULL;
UT_array *tags = NULL;

// TODO
(void) cmd;
Expand Down Expand Up @@ -1585,7 +1585,7 @@ int neu_adapter_validate_tag(neu_adapter_t *adapter, neu_datatag_t *tag)
return error;
}

neu_event_timer_t *neu_adapter_add_timer(neu_adapter_t * adapter,
neu_event_timer_t *neu_adapter_add_timer(neu_adapter_t *adapter,
neu_event_timer_param_t param)
{
return neu_event_add_timer(adapter->events, param);
Expand All @@ -1610,7 +1610,7 @@ int neu_adapter_register_group_metric(neu_adapter_t *adapter,
}

int neu_adapter_update_group_metric(neu_adapter_t *adapter,
const char * group_name,
const char *group_name,
const char *metric_name, uint64_t n)
{
if (NULL == adapter->metrics) {
Expand All @@ -1622,8 +1622,8 @@ int neu_adapter_update_group_metric(neu_adapter_t *adapter,
}

int neu_adapter_metric_update_group_name(neu_adapter_t *adapter,
const char * group_name,
const char * new_group_name)
const char *group_name,
const char *new_group_name)
{
if (NULL == adapter->metrics) {
return -1;
Expand All @@ -1634,7 +1634,7 @@ int neu_adapter_metric_update_group_name(neu_adapter_t *adapter,
}

void neu_adapter_del_group_metrics(neu_adapter_t *adapter,
const char * group_name)
const char *group_name)
{
if (NULL != adapter->metrics) {
neu_node_metrics_del_group(adapter->metrics, group_name);
Expand Down
Loading
Loading