I am using the client verion of Snap7 from Delphi 2007.
I created a callback function and noticed that it get's called twice sometimes (?)
*procedure ClientCompletion(usrPtr : pointer; opCode, opResult : integer); stdcall;
begin
//Temporary store resultcodes (threadsafe by waiting until "scantasks" picks them up and using a mutex)
if WaitForSingleObject(Snap7ThreadMutex, INFINITE) <> WAITOBJECT0 then
RaiseLastOSError;
try
cTaskScheduler(usrPtr^).mCallbackOpCode :=opCode;
cTaskScheduler(usrPtr^).mCallbackOpResult:=opResult;
finally
ReleaseMutex(Snap7ThreadMutex)
end;
end;
*
Both cases with opResult=0 and opCode=1. What should I do with opCode? In the documenation of Snap7 I noticed that sometimes opResult gets checked for 0 and sometomes opCode (C# callback example).
At the moment I am using opResult as the "error code" (0=success >0=error) and I don't use opCode...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I solved the problem. It had something to do with cTaskScheduler(usrPtr^) pointing to the wrong position in memory.
However: The question about opCode remains. Anyone ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using the client verion of Snap7 from Delphi 2007.
I created a callback function and noticed that it get's called twice sometimes (?)
*procedure ClientCompletion(usrPtr : pointer; opCode, opResult : integer); stdcall;
begin
//Temporary store resultcodes (threadsafe by waiting until "scantasks" picks them up and using a mutex)
if WaitForSingleObject(Snap7ThreadMutex, INFINITE) <> WAITOBJECT0 then
RaiseLastOSError;
try
cTaskScheduler(usrPtr^).mCallbackOpCode :=opCode;
cTaskScheduler(usrPtr^).mCallbackOpResult:=opResult;
finally
ReleaseMutex(Snap7ThreadMutex)
end;
end;
*
Both cases with opResult=0 and opCode=1.
What should I do with opCode? In the documenation of Snap7 I noticed that sometimes opResult gets checked for 0 and sometomes opCode (C# callback example).
At the moment I am using opResult as the "error code" (0=success >0=error) and I don't use opCode...
I solved the problem. It had something to do with cTaskScheduler(usrPtr^) pointing to the wrong position in memory.
However: The question about opCode remains. Anyone ?