diff --git a/CMakeLists.txt b/CMakeLists.txt index e836c9f..83530b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,12 +22,22 @@ endif (NOT WIN32) # ================================================== set(vxi11_SRCS library/vxi11_user.c library/vxi11_user.h) + if (WIN32) - include_directories(C:\\VXIpnp\\WINNT\\include) - link_directories(C:\\VXIpnp\\WINNT\\lib\\msc) + # Default path for IVI Visa under Windows should be + # C:\Program Files (x86)\IVI Foundation\VISA + set(ivi_path "C:\\Program Files (x86)\\IVI Foundation\\VISA") + include_directories("${ivi_path}\\WinNT\\include") + link_directories("${ivi_path}\\WinNT\\lib\\msc") + + # Path for library headers needed by utils + include_directories("${vxi11_SOURCE_DIR}\\library") else (WIN32) - set(vxi11_SRCS ${vxi11_SRCS} library/vxi11.h library/vxi11_clnt.c - library/vxi11_xdr.c library/vxi11.x) + set(vxi11_SRCS ${vxi11_SRCS} + library/vxi11.h + library/vxi11_clnt.c + library/vxi11_xdr.c + library/vxi11.x) endif (WIN32) diff --git a/library/vxi11_user.c b/library/vxi11_user.c index de216ed..2e92d16 100644 --- a/library/vxi11_user.c +++ b/library/vxi11_user.c @@ -122,17 +122,17 @@ int vxi11_open_device(VXI11_CLINK **clink, const char *address, char *device) } #ifdef WIN32 - status = viOpenDefaultRM(&clink->rm); + status = viOpenDefaultRM(&(*clink)->rm); if (status != VI_SUCCESS) { - viStatusDesc(NULL, status, buf); + viStatusDesc(0, status, buf); printf("%s\n", buf); free(*clink); *clink = NULL; return 1; } - viOpen(clink->rm, (char *)address, VI_NULL, VI_NULL, &clink->session); + viOpen((*clink)->rm, (char *)address, VI_NULL, VI_NULL, &(*clink)->session); if (status != VI_SUCCESS) { - viStatusDesc(clink->rm, status, buf); + viStatusDesc((*clink)->rm, status, buf); printf("%s\n", buf); free(*clink); *clink = NULL; @@ -294,9 +294,10 @@ int vxi11_send(VXI11_CLINK * clink, const char *cmd, size_t len) char *send_cmd; #endif size_t bytes_left = len; - ssize_t write_count; #ifdef WIN32 + ViUInt32 write_count = 0; + send_cmd = (unsigned char *)malloc(len); if (!send_cmd) { return 1; @@ -390,10 +391,11 @@ ssize_t vxi11_receive(VXI11_CLINK * clink, char *buffer, size_t len) ssize_t vxi11_receive_timeout(VXI11_CLINK * clink, char *buffer, size_t len, unsigned long timeout) { - size_t curr_pos = 0; #ifdef WIN32 + ViUInt32 curr_pos = 0; viRead(clink->session, (unsigned char *)buffer, len, &curr_pos); #else + size_t curr_pos = 0; Device_ReadParms read_parms; Device_ReadResp read_resp; diff --git a/utils/vxi11_cmd.c b/utils/vxi11_cmd.c index 74df81c..b01c118 100644 --- a/utils/vxi11_cmd.c +++ b/utils/vxi11_cmd.c @@ -29,13 +29,8 @@ #include "vxi11_user.h" #define BUF_LEN 100000 -#ifdef WIN32 -#define strncasecmp(a, b, c) stricmp(a, b) -#endif - int main(int argc, char *argv[]) { - char *device_ip; char *device_name = NULL; char cmd[256]; diff --git a/utils/vxi11_send.c b/utils/vxi11_send.c index afeef87..65fe533 100644 --- a/utils/vxi11_send.c +++ b/utils/vxi11_send.c @@ -28,10 +28,6 @@ #include "vxi11_user.h" -#ifdef WIN32 -#define strncasecmp(a, b, c) stricmp(a, b) -#endif - int main(int argc, char *argv[]) {