Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Accessing Sys.Idata[xxx] form bgcplc
#1
I have created the following background cplc for test. Upon enabling with UserAlgo.BgCplc[0]=1 I monitor the p variable testpvar and Sys.Idata[50000] in a watch window. The p variable increments correctly and continiously, but the variable accessed by pushm does not. Any ideas as to what I am missing here?

// CPLCs/bgplc00/bgcplc.c
#include <gplib.h>
#define _PPScriptMode_
#include "../../Include/pp_proj.h"

void user_plcc()
{
int *sos_tmp;
sos_tmp = (int *)pushm + 50000; // pointer to Sys.Idata[50000]
*sos_tmp++; // increment for test
testpvar++; // testpvar is declared as global testpvar in blobal definitions.pmh
}
Reply
#2
(01-28-2019, 11:42 AM)JeffLowe Wrote: I have created the following background cplc for test. Upon enabling with UserAlgo.BgCplc[0]=1 I monitor the p variable testpvar and Sys.Idata[50000] in a watch window. The p variable increments correctly and continiously, but the variable accessed by pushm does not. Any ideas as to what I am missing here?

// CPLCs/bgplc00/bgcplc.c
#include <gplib.h>
#define _PPScriptMode_
#include "../../Include/pp_proj.h"

void user_plcc()
{
int *sos_tmp;
sos_tmp = (int *)pushm + 50000; // pointer to Sys.Idata[50000]
*sos_tmp++; // increment for test
testpvar++; // testpvar is declared as global testpvar in blobal definitions.pmh
}

Replace "*sos_tmp++;" with "(*sos_tmp)++;". In your code, just the target address was shifted, not the value ++.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)