Parse replyonbroadcast config option value #75

This commit is contained in:
Victor Antonovich 2021-07-06 16:37:36 +03:00
parent 6a95a732d4
commit a2272c5793
5 changed files with 8 additions and 9 deletions

View File

@ -94,8 +94,8 @@ Usage:
Specifies response wait time in milliseconds.
-T timeout
Specifies connection timeout value in seconds (0 disables timeout).
-b
Reply on a Broadcast
-b
Instructs **mbusd** to reply on a broadcast.
Please note running **mbusd** on default Modbus TCP port (502) requires root privileges!

View File

@ -47,4 +47,4 @@ pause = 100
wait = 500
# Reply on Broadcast
#replyonbroadcast
replyonbroadcast = no

View File

@ -83,15 +83,13 @@ Specifies response wait time in milliseconds.
.IP "\fB-T \fItimeout\fR"
Specifies connection timeout value in seconds (0 - disable timeout).
.IP "\fB-b\fR"
Instruct \fImbusd\fR to reply on a broadcast
Instructs \fImbusd\fR to reply on a broadcast.
.SH NOTES
In case of situation when \fImbusd\fR received response with invalid CRC and can't correct
error by re-request, it return MODBUS/TCP packet with exception code 04. In case of situation
when \fImbusd\fR can't receive response from MODBUS RTU device (e.g. addressed controller
is not present on the network), it return MODBUS/TCP packet with exception code 0x0B.
.SH BUGS
Broadcast messaging on MODBUS network isn't supported.
Please send bug reports to author.
.SH AUTHORS
Victor Antonovich <v.antonovich@gmail.com>

View File

@ -41,6 +41,7 @@
#define CFG_NAME_MATCH(n) strcmp(n, name) == 0
#define CFG_VALUE_MATCH(n) strcasecmp(n, value) == 0
#define CFG_VALUE_BOOL() (strcasecmp("y", value) == 0 || strcasecmp("yes", value) == 0)
/* Global configuration storage variable */
cfg_t cfg;
@ -175,7 +176,7 @@ cfg_handle_param(char *name, char *value)
}
else if (CFG_NAME_MATCH("replyonbroadcast"))
{
cfg.replyonbroadcast = 1;
cfg.replyonbroadcast = CFG_VALUE_BOOL();
}
else if (CFG_NAME_MATCH("timeout"))
{

View File

@ -146,7 +146,7 @@ usage(char *exename)
" (1-%d, default %lu)\n"
" -T timeout : set connection timeout value in seconds\n"
" (0-%d, default %d, 0 - no timeout)\n"
" -b : reply on broadcast (default %d)"
" -b : enable reply on broadcast"
"\n", PACKAGE, VERSION, exename,
#ifdef LOG
LOGPATH, LOGNAME, cfg.dbglvl,
@ -155,7 +155,7 @@ usage(char *exename)
cfg.serveraddr, cfg.serverport,
MAX_MAXCONN, cfg.maxconn, MAX_MAXTRY, cfg.maxtry,
MAX_RQSTPAUSE, cfg.rqstpause, MAX_RESPWAIT, cfg.respwait,
MAX_CONNTIMEOUT, cfg.conntimeout, cfg.replyonbroadcast);
MAX_CONNTIMEOUT, cfg.conntimeout);
exit(0);
}