Jump to content
OMRON Forums

GetPmacStatus in usrcode.c


kmonroe023
 Share

Recommended Posts

I'm trying to use GetPmacStatus in usrcode.c to get the program running status of a coordinate system. However I can't get usrcode.c to compile if I call GetPmacStatus. If I comment out the line that GetPmacStatus is on, usrcode.c compiles and runs as expected.

 

// code

char strCoord[]="Coord[1].ProgRunning";

char *strPntr = strCoord;

double CoordProgRun = 0;

.

.

CoordProgRun = (double)GetPmacStatus(strPntr);

// end of code

 

Here is output from err.log (I snipped out some of the path text):

/cygdrive/c/Users/..../usrcode.c: In function 'CfromScript':

/cygdrive/c/Users/..../usrcode.c:96: error: implicit declaration of function 'GetPmacStatus'

make[2]: *** [/cygdrive/c/Users/..../usrcode.o] Error 1

make[1]: *** [_module_/cygdrive/c/Users/....] Error 2

make: *** [all] Error 2

 

Any idea what I'm doing wrong? I'm still in the process of learning C so please let me know if I'm making a mistake in how I use the API call.

 

Thanks,

kmonroe

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You have to include gplib.h at the top of your C program like this:

 

#include

 

If it is a background C program, you have to initialize the library, place your code, and then close the library.

 

Example program that builds fine:

 

#include // Global Gp Shared memory pointer

#include "../../Include/pp_proj.h"

 

int main(void)

{

int Status = 0;

InitLibrary();

Status = GetPmacStatus("Coord[2].ProgRunning");

CloseLibrary();

return 0;

}

 

If it is in kernel space (e.g. in usrcode.c), certain functions, such as this one, are not available, but you can access the vast majority of Power PMAC structures directly through the pshm pointer. For the structures that are computed, and not directly accessible, such as ProgRunning, you can compute them. Here is the logic for three Coord bits you have to compute:

 

if ((pshm->Coord[n].Ldata.Status & 0x2e) == 0x20) then Coord[n].ProgRunning returns 1 else 0.

if ((pshm->Coord[n].Ldata.Status & 0x20) == 0x20) then Coord[n].ProgActive returns 1 else 0.

if (((pshm->Coord[n].Ldata.Status & 0x2e) == 0x20) && (pshm->Coord[n].FeedHold != 1)) then Coord[n].ProgProceeding returns 1 else 0.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...