Modbus plugin web interface: show the keyword "#ANY#" on TCP servers
authorMario de Sousa <msousa@fe.up.pt>
Sun, 07 Jun 2020 22:32:24 +0100
changeset 2665 978cf239c689
parent 2664 a26a8e182190
child 2666 5f48d5e60a81
Modbus plugin web interface: show the keyword "#ANY#" on TCP servers
modbus/mb_runtime.c
runtime/Modbus_config.py
--- a/modbus/mb_runtime.c	Sun Jun 07 19:33:32 2020 +0100
+++ b/modbus/mb_runtime.c	Sun Jun 07 22:32:24 2020 +0100
@@ -929,7 +929,7 @@
 const char *       __modbus_get_ClientNode_addr_type  (int nodeid)  {return addr_type_str[client_nodes[nodeid].node_address.naf];}
                                                                                                                         
 const char *       __modbus_get_ServerNode_config_name(int nodeid)  {return server_nodes[nodeid].config_name;                    }
-const char *       __modbus_get_ServerNode_host       (int nodeid)  {return server_nodes[nodeid].str1;                           }
+const char *       __modbus_get_ServerNode_host       (int nodeid)  {char*x=server_nodes[nodeid].str1; return (x[0]=='\0'?"#ANY#":x); }
 const char *       __modbus_get_ServerNode_port       (int nodeid)  {return server_nodes[nodeid].str2;                           }
 const char *       __modbus_get_ServerNode_device     (int nodeid)  {return server_nodes[nodeid].str1;                           }
 int                __modbus_get_ServerNode_baud       (int nodeid)  {return server_nodes[nodeid].node_address.addr.rtu.baud;     }
@@ -948,7 +948,8 @@
 void __modbus_set_ClientNode_comm_period(int nodeid, u64          value)  {client_nodes[nodeid].comm_period                     = value;}
                                                                                                                         
 
-void __modbus_set_ServerNode_host       (int nodeid, const char * value)  {__safe_strcnpy(server_nodes[nodeid].str1, value, MODBUS_PARAM_STRING_SIZE);}
+void __modbus_set_ServerNode_host       (int nodeid, const char * value)  {if (strcmp(value,"#ANY#")==0) value = "";
+                                                                           __safe_strcnpy(server_nodes[nodeid].str1, value, MODBUS_PARAM_STRING_SIZE);}
 void __modbus_set_ServerNode_port       (int nodeid, const char * value)  {__safe_strcnpy(server_nodes[nodeid].str2, value, MODBUS_PARAM_STRING_SIZE);}
 void __modbus_set_ServerNode_device     (int nodeid, const char * value)  {__safe_strcnpy(server_nodes[nodeid].str1, value, MODBUS_PARAM_STRING_SIZE);}
 void __modbus_set_ServerNode_baud       (int nodeid, int          value)  {server_nodes[nodeid].node_address.addr.rtu.baud      = value;}
--- a/runtime/Modbus_config.py	Sun Jun 07 19:33:32 2020 +0100
+++ b/runtime/Modbus_config.py	Sun Jun 07 22:32:24 2020 +0100
@@ -383,8 +383,6 @@
         if value is not None:
             newConfig[par_name] = value
 
-    _WebNodeList[WebNode_id]["WebviewConfiguration"] = newConfig
-    
     # First check if configuration is OK.
     # Note that this is not currently required, as we use drop down choice menus
     # for baud, parity and sop bits, so the values should always be correct!
@@ -399,6 +397,11 @@
     # Configure PLC with the current Modbus parameters
     _SetPLCConfiguration(WebNode_id, newConfig)
 
+    # Update the viewable configuration
+    # The PLC may have coerced the values on calling _SetPLCConfiguration()
+    # so we do not set it directly to newConfig
+    _WebNodeList[WebNode_id]["WebviewConfiguration"] = _GetPLCConfiguration(WebNode_id)
+
     # File has just been created => Delete button must be shown on web interface!
     _updateWebInterface(WebNode_id)