/* You must run PVSstart() in your vxWorks startup script before these functions can be used. Just ld() the object file for this code in your vxWorks startup script. Services added in this file: PVS_MemStats - Send the bytes free and allocated to the requestor. PVS_ClientStats - Send a CA client statistics summary report to the requestor. Includes host name, user id, number of channels in use. PVS_TaskList - Send a report of all the tasks in the IOC, along with there state and priority. */ #include #include #include #include #include #include #include #include /* sucks, don't it */ /* required for client stat section */ #include #include #include #include #include "PVS.h" #define MAX_TASK 100 extern struct dbBase *pdbbase; static int* task_list=NULL; void PVS_MemStats(BS* bs) { int len; unsigned long b_free, b_alloc; char line[100]; b_free=2*(memSysPartId->totalWords-memSysPartId->curWordsAllocated); b_alloc=2*memSysPartId->curWordsAllocated; /* report columns: bytes_free bytes allocated */ sprintf(line,"%lu %lu\n",b_free,b_alloc); len=strlen(line)+1; if(BSsendHeader(bs,PVS_Data,len)<0) printf("PVSserver: data cmd failed\n"); else { if(BSsendData(bs,line,len)<0) printf("PVSserver: data send failed\n"); } BSsendHeader(bs,BS_Done,0); } void PVS_TaskList(BS* bs) { int len,i,tot,pri; char line[100]; char state[30]; char* name; if(task_list==NULL) task_list=(int*)malloc(sizeof(int)*MAX_TASK); if((tot=taskIdListGet(task_list,MAX_TASK))==0) { BSsendHeader(bs,BS_Done,0); return; } /* report columns: name_of_task state_of_task priority of task */ for(i=0;i, value=<%s>\n",name,value); } } break; default: fprintf(stderr,"PVS_FieldList(): Unknown packet received\n"); break; default: } } BSsendHeader(bs,BS_Done,0); } #endif