plugins/python/plc_python.c
changeset 613 be0ceea3b6dd
parent 483 bc26c42d2eec
child 638 865c7c60a1f3
equal deleted inserted replaced
612:f44651506a88 613:be0ceea3b6dd
   125 		if(__GET_VAR(data__->TRIGGED) == 1 &&
   125 		if(__GET_VAR(data__->TRIGGED) == 1 &&
   126 		   /* and not already being processed */
   126 		   /* and not already being processed */
   127 		   __GET_VAR(data__->STATE) == PYTHON_FB_FREE)
   127 		   __GET_VAR(data__->STATE) == PYTHON_FB_FREE)
   128 		{
   128 		{
   129 			/* Enter the block in the fifo
   129 			/* Enter the block in the fifo
   130 			/* Don't have to check if fifo cell is free
   130 			 * Don't have to check if fifo cell is free
   131 			 * as fifo size == FB count, and a FB cannot
   131 			 * as fifo size == FB count, and a FB cannot
   132 			 * be requested twice */
   132 			 * be requested twice */
   133 			EvalFBs[Current_PLC_EvalFB] = data__;
   133 			EvalFBs[Current_PLC_EvalFB] = data__;
   134 			/* copy into BUFFER local*/
   134 			/* copy into BUFFER local*/
   135 			__SET_VAR(data__->BUFFER, __GET_VAR(data__->PREBUFFER));
   135 			__SET_VAR(data__->BUFFER, __GET_VAR(data__->PREBUFFER));
   174 			{
   174 			{
   175 			    __SET_VAR(data__->BUFFER, STR_MAX_LEN, .len );
   175 			    __SET_VAR(data__->BUFFER, STR_MAX_LEN, .len );
   176 				/* TODO : signal error */
   176 				/* TODO : signal error */
   177 			}
   177 			}
   178 			/* Copy results to buffer */
   178 			/* Copy results to buffer */
   179 			strncpy(__GET_VAR(data__->BUFFER, .body), result, __GET_VAR(data__->BUFFER,.len));
   179 			strncpy((char*)__GET_VAR(data__->BUFFER, .body), result, __GET_VAR(data__->BUFFER,.len));
   180 	   	}else{
   180 	   	}else{
   181 	   	    __SET_VAR(data__->BUFFER, 0, .len);
   181 	   	    __SET_VAR(data__->BUFFER, 0, .len);
   182 	   	}
   182 	   	}
   183 		/* remove block from fifo*/
   183 		/* remove block from fifo*/
   184 		EvalFBs[Current_Python_EvalFB] = NULL;
   184 		EvalFBs[Current_Python_EvalFB] = NULL;
   205 	__SET_VAR(data__->STATE, PYTHON_FB_PROCESSING);
   205 	__SET_VAR(data__->STATE, PYTHON_FB_PROCESSING);
   206 	//printf("PythonIterator\n");
   206 	//printf("PythonIterator\n");
   207 	/* make BUFFER a null terminated string */
   207 	/* make BUFFER a null terminated string */
   208 	__SET_VAR(data__->BUFFER, 0, .body[__GET_VAR(data__->BUFFER, .len)]);
   208 	__SET_VAR(data__->BUFFER, 0, .body[__GET_VAR(data__->BUFFER, .len)]);
   209 	/* next command is BUFFER */
   209 	/* next command is BUFFER */
   210 	next_command = __GET_VAR(data__->BUFFER, .body);
   210 	next_command = (char*)__GET_VAR(data__->BUFFER, .body);
   211 	/* free python mutex */
   211 	/* free python mutex */
   212 	UnLockPython();
   212 	UnLockPython();
   213 	/* return the next command to eval */
   213 	/* return the next command to eval */
   214 	return next_command;
   214 	return next_command;
   215 }
   215 }