From f53ad5caf76359fd92fc7b7d0694138ca8a37146 Mon Sep 17 00:00:00 2001 From: Andy Sittig Date: Fri, 28 Oct 2016 16:49:05 +0200 Subject: [PATCH 1/4] Add default path (variable) for IVI Visa headers and libs (fixes visa.h not found error). Also add path to library headers (fixes vxi11_user.h not found error in utils). --- CMakeLists.txt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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) From de05fd9b1bc9a56a5529061f0fa27b6d6831f60e Mon Sep 17 00:00:00 2001 From: Andy Sittig Date: Fri, 28 Oct 2016 16:49:31 +0200 Subject: [PATCH 2/4] Fix access errors in vxi11_user.c --- library/vxi11_user.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/vxi11_user.c b/library/vxi11_user.c index de216ed..8d064e1 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; From f5a323c8346ae575b881c166ae24059abad18718 Mon Sep 17 00:00:00 2001 From: Andy Sittig Date: Fri, 28 Oct 2016 16:49:48 +0200 Subject: [PATCH 3/4] Fix incompatible pointer type errors in vxi11_user.c --- library/vxi11_user.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/vxi11_user.c b/library/vxi11_user.c index 8d064e1..2e92d16 100644 --- a/library/vxi11_user.c +++ b/library/vxi11_user.c @@ -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; From 8f9c9f6b69473287b7f7aa5e2c98b1afa1e9ccce Mon Sep 17 00:00:00 2001 From: Andy Sittig Date: Fri, 28 Oct 2016 16:50:07 +0200 Subject: [PATCH 4/4] Remove strncasecmp macro from utils (should be defined in string.h). --- utils/vxi11_cmd.c | 5 ----- utils/vxi11_send.c | 4 ---- 2 files changed, 9 deletions(-) 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[]) {