#include #include #include #include #include "vxi11.h" #define WAITLOCK_FLAG 1 #define WRITE_END_CHAR 8 #define READ_END_CHAR 0x80 #define VXI_ENDW (WAITLOCK_FLAG | WRITE_END_CHAR) CLIENT *rpcClient; Create_LinkParms crlp; Create_LinkResp *crlr; Device_WriteParms dwrp; Device_WriteResp *dwrr; Device_ReadParms drdp; Device_ReadResp *drdr; Device_Error *derr; UnsignedWide microTickCount1,microTickCount2; // this example uses a ICS 8063's default IP address // The printf calls are commneted out to have pure execution tome measurments // For the different mesurments the two calls to "Microseconds()" were moved to the appropriate places // here are the results obtained on on an Intel core-duo mac. // // The create_link_1 takes about 265msec // the rest: write-read-close about 65msec // close link destroy client 20msec static char *svName = "192.168.0.254"; int main(){ char sendMessage[1024]; //char responseMessage[2048]; rpcClient = clnt_create(svName, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp"); if (rpcClient == NULL){ printf("Error creating client\n"); clnt_pcreateerror(svName); return 1; } // printf("Hello %s\n", svName); crlp.clientId = (long) rpcClient; crlp.lockDevice = 0; crlp.lock_timeout = 10000; crlp.device = "inst0"; crlr = create_link_1(&crlp, rpcClient); if (crlr == NULL){ clnt_perror(rpcClient, svName); return 1; } // printf("Link created to %s\n", crlp.device); Microseconds ( µTickCount1); dwrp.lid = crlr->lid; dwrp.io_timeout = 1000; dwrp.lock_timeout = 10000; dwrp.flags = VXI_ENDW; sprintf(sendMessage, "*IDN?\n"); dwrp.data.data_len = strlen(sendMessage); dwrp.data.data_val = sendMessage; dwrr = device_write_1(&dwrp, rpcClient); if (dwrr == NULL){ clnt_perror(rpcClient, svName); printf ("device_write returned dwrr == NULL \n"); return 1; } drdp.lid = crlr->lid; drdp.io_timeout = 1000; drdp.lock_timeout = 10000; drdp.flags = VXI_ENDW; drdp.termChar = '\n'; drdp.requestSize = 1024; drdr = device_read_1(&drdp, rpcClient); if (drdr == NULL){ clnt_perror(rpcClient, svName); printf("device read returned drdr == NULL\n"); return 1; } // printf("response = %s\n", drdr->data.data_val); Microseconds ( µTickCount2); derr = destroy_link_1(&(crlr->lid), rpcClient); clnt_destroy(rpcClient); printf("Ellapsed time in microsec %ld \n", microTickCount2.lo-microTickCount1.lo); return 0; }