Change behaviour of python_eval function block : if TRIG is false, then ACK is also false except a pulse precisely when receiving answer from interpreter
authorEdouard Tisserant
Tue, 11 Sep 2018 16:08:21 +0200
changeset 2272 28b0a783975e
parent 2271 985973ed701b
child 2273 a0efe3d9c853
Change behaviour of python_eval function block : if TRIG is false, then ACK is also false except a pulse precisely when receiving answer from interpreter
py_ext/plc_python.c
--- a/py_ext/plc_python.c	Wed Sep 05 12:58:41 2018 +0200
+++ b/py_ext/plc_python.c	Tue Sep 11 16:08:21 2018 +0200
@@ -89,6 +89,10 @@
  */
 void __PythonEvalFB(int poll, PYTHON_EVAL* data__)
 {
+    if(!__GET_VAR(data__->TRIG)){
+        /* ACK is False when TRIG is false, except a pulse when receiving result */
+        __SET_VAR(data__->, ACK,, 0);
+    }
 	/* detect rising edge on TRIG to trigger evaluation */
 	if(((__GET_VAR(data__->TRIG) && !__GET_VAR(data__->TRIGM1)) ||
 	   /* polling is equivalent to trig on value rather than on rising edge*/
@@ -109,7 +113,7 @@
 		if(__GET_VAR(data__->STATE) == PYTHON_FB_ANSWERED){
 			/* Copy buffer content into result*/
 			__SET_VAR(data__->, RESULT,, __GET_VAR(data__->BUFFER));
-			/* signal result presece to PLC*/
+			/* signal result presence to PLC*/
 			__SET_VAR(data__->, ACK,, 1);
 			/* Mark as free */
 			__SET_VAR(data__->, STATE,, PYTHON_FB_FREE);