#define _CRT_SECURE_NO_WARNINGS #include #include #include "pipeproto.h" /* Type definitions for STP data */ #define DECSTP_TYPE_OVF 2 #define DECSTP_TYPE_D8 4 #define DECSTP_TYPE_D16 5 #define DECSTP_TYPE_D32 6 #define DECSTP_TYPE_D64 7 #define DECSTP_TYPE_WITHTS 0x10 #define DECSTP_TYPE_ERROR 0xFF #define OST_FRAME_BUF_SIZE 1000 #define OST_FRAME_ARRAY_SIZE 10 #define TS_SIZE 8 typedef struct localData { unsigned int fctn, var; } localDataT,*localDataP; /*********************/ /* Private functions */ /*********************/ void init_localDataT_struct(localDataP data) { data->fctn = 0; data->var = 0; } /* Processing function * * The following function will be called, each time a STP message is decoded * * Parameters * info : Structure for calling functions inside T32 software. * data : Pointer to structure which holds local data for this DLL. * buffer : Pointer to byte buffer which holds STP message. * [7:0] = timestamp from CombiProbe * [8] = STP packet type * [9] = channel * [10] = master * [11:19] = data * len : Length of byte buffer which holds STP message. */ static void process(SPipeProtoInfo *info,localDataP data,unsigned char *buffer,int len) { unsigned short channel; unsigned int value; SPipeProtoCycleInfo cycle; if (!buffer) return; channel = buffer[9]; value = buffer[11] | (buffer[12]<<8) | (buffer[13] << 16) | (buffer[14] << 24); switch (channel) { case 0: /* function address */ cycle.type = PIPE_LOG_TYPE_PROGRAM; cycle.address = value; data->fctn = value; break; case 1: /* variable's address */ data->var = value; return; case 2: /* variable's value */ cycle.type = PIPE_LOG_TYPE_READ | PIPE_LOG_TYPE_WITHADDRESS | PIPE_LOG_TYPE_WITHDATA; cycle.address = data->var; cycle.datasize = 4; cycle.data[0] = buffer[11]; cycle.data[1] = buffer[12]; cycle.data[2] = buffer[13]; cycle.data[3] = buffer[14]; /* Display output via 'AREA.view CT_Demo' */ PIPE_PrintfArea(info, "CT_Demo", "function=%d, variable=%d, value=%d", data->fctn, data->var, value ); break; } /* Display output via 'CAnalyzer.CUSTOMTRACE.CT_DEMO.List' */ PIPE_LogCycle(info, buffer, &cycle); } /* called when DLL is unloaded * Parameters * info : Structure for calling functions inside T32 * data : Pointer to structure which holds local data for this DLL. */ static void exitDll(SPipeProtoInfo *info,localDataP localdata) { /* Free data, which was allocated in "PIPE_Init" */ free(localdata); } /* called when DLL is loaded * * Parameters * info : Structure for calling functions inside T32 * argc : numbers of parameters stored in "argv" * argv : array of pointers to "NULL" terminated command line parameters * * Return Value: * == 0 indicates success. * != 0 indicates error. DLL will be unloaded. * * This function should allocate space to store local configuration data * for one DLL load. * It additionally should do all initialization which is necessary. */ int PIPE_Init(SPipeProtoInfo *info,int argc, char **argv) { localDataP localdata = (localDataP)malloc(sizeof(localDataT)); init_localDataT_struct(localdata); /* * Parameters for PIPE_RegisterCallback: * info : Pointer to "SPipeProtoInfo" structure * type : Type of function to register * callback : Pointer to function which will be called. * flags : optional flags (currently always 0). */ PIPE_RegisterCallback(info, PIPE_PROCESS_CALLBACK, process, localdata, 0); PIPE_RegisterCallback(info, PIPE_EXIT_CALLBACK , exitDll, localdata, 0); return 0; }