140 char *env = getenv (env_conf_path);
148 config_fname = argc > 1 ? argv[1] :
"./modbusd.json";
153 load_config (config_fname, &config_json);
156 zctx_t *zmq_context = zctx_new ();
157 void *zmq_sub = zsocket_new (zmq_context, ZMQ_SUB);
158 zsocket_bind (zmq_sub, ipc_sub);
159 zsocket_set_subscribe (zmq_sub,
"");
161 zmq_pub = zsocket_new (zmq_context, ZMQ_PUB);
162 zsocket_bind (
zmq_pub, ipc_pub);
166 while (!zctx_interrupted)
168 zmsg_t *msg = zmsg_recv (zmq_sub);
172 zframe_t *frame_mode = zmsg_pop (msg);
173 char *mode = zframe_strdup (frame_mode);
176 zframe_t *frame_json = zmsg_pop (msg);
177 char *req_json_string = zframe_strdup (frame_json);
181 zframe_destroy (&frame_mode);
182 zframe_destroy (&frame_json);
190 if (req_json_obj != NULL)
195 if (strcmp (mode,
"tcp") == 0)
237 else if (strcmp (mode,
"rtu") == 0)
264 zctx_destroy (&zmq_context);
265 save_config (config_fname, config_json);
char * set_modbus_fail_resp_str(char *tid, const char *reason)
Set modbusd fail response string.
Definition: mb.c:41
char * mbtcp_read_bit_req_fn(uint8_t fc, mbtcp_handle_s *handle, cJSON *req)
Help function.
Definition: mbtcp.c:288
char * json_get_char(cJSON *inJson, const char *key)
Get char string via key from cJSON object.
Definition: json.c:11
long json_get_long(cJSON *inJson, const char *key)
Get long integer value via key from cJSON object.
Definition: json.c:36
void cJSON_Delete(cJSON *c)
Definition: cJSON.c:81
void * zmq_pub
Definition: main.c:53
#define VERSION
Definition: main.c:12
char * mbtcp_multi_write_req_fn(uint8_t fc, mbtcp_handle_s *handle, cJSON *req)
Help function.
Definition: mbtcp.c:417
int enable_syslog
Definition: main.c:46
char * mbtcp_read_reg_req_fn(uint8_t fc, mbtcp_handle_s *handle, cJSON *req)
Help function.
Definition: mbtcp.c:337
cJSON * cJSON_Parse(const char *value)
Definition: cJSON.c:343
char * mbtcp_get_response_timeout(char *tid)
Get mbtcp response timeout.
Definition: mbtcp.c:270
int json_get_int(cJSON *inJson, const char *key)
Get integer value via key from cJSON object.
Definition: json.c:16
char * mbtcp_cmd_hanlder(uint8_t fc, cJSON *req, mbtcp_fc ptr_handler)
Generic mbtcp command handler.
Definition: mbtcp.c:220
char * mbtcp_single_write_req_fn(uint8_t fc, mbtcp_handle_s *handle, cJSON *req)
Help function.
Definition: mbtcp.c:386
char * mbtcp_set_response_timeout(char *tid, long timeout)
Set mbtcp response timeout in usec.
Definition: mbtcp.c:250
#define LOG(flag, fmt,...)
Definition: log.h:36
cmd_s
Definition: main.c:16