SVGHMI: Fixed halting problem when there is no session opened.
--- a/svghmi/svghmi.c Tue Jul 13 16:19:07 2021 +0200
+++ b/svghmi/svghmi.c Thu Jul 15 11:48:02 2021 +0200
@@ -211,21 +211,21 @@
void SVGHMI_SuspendFromPythonThread(void);
void SVGHMI_WakeupFromRTThread(void);
-static int continue_collect;
+int svghmi_continue_collect;
int __init_svghmi()
{
bzero(rbuf,sizeof(rbuf));
bzero(wbuf,sizeof(wbuf));
- continue_collect = 1;
+ svghmi_continue_collect = 1;
return 0;
}
void __cleanup_svghmi()
{
- continue_collect = 0;
+ svghmi_continue_collect = 0;
SVGHMI_WakeupFromRTThread();
}
@@ -251,7 +251,7 @@
int svghmi_send_collect(uint32_t session_index, uint32_t *size, char **ptr){
- if(continue_collect) {
+ if(svghmi_continue_collect) {
int res;
sbufidx = HMI_HASH_SIZE;
send_session_index = session_index;
--- a/svghmi/svghmi_server.py Tue Jul 13 16:19:07 2021 +0200
+++ b/svghmi/svghmi_server.py Thu Jul 15 11:48:02 2021 +0200
@@ -31,6 +31,8 @@
svghmi_wait.restype = ctypes.c_int # error or 0
svghmi_wait.argtypes = []
+svghmi_continue_collect = ctypes.c_int.in_dll(PLCBinary, "svghmi_continue_collect")
+
svghmi_send_collect = PLCBinary.svghmi_send_collect
svghmi_send_collect.restype = ctypes.c_int # error or 0
svghmi_send_collect.argtypes = [
@@ -244,8 +246,7 @@
size = ctypes.c_uint32()
ptr = ctypes.c_void_p()
res = 0
- finished = False
- while not(finished):
+ while svghmi_continue_collect:
svghmi_wait()
for svghmi_session in svghmi_session_manager.iter_sessions():
res = svghmi_send_collect(
@@ -261,7 +262,6 @@
pass
else:
# this happens when finishing
- finished = True
break
def AddPathToSVGHMIServers(path, factory):