07-25-2022 06:11 PM
Hi everyone,
I recently tried making an IVI Specific Instrument Driver for a switch controlled via ethernet (TCP/IP). I followed the instructions...
- select "IVI Specific Instrument Driver" under the New menu of the welcome page
- click next and select "Create New Driver", "Ethernet", and "Switch"
- click next and enter instrument name, prefix, company name, and select a target directory
- proceed through the rest of the of the menus (specifying ID query format, etc...)
- select "Run Tests..." in the Test menu, it appears to complete tests without error
- click "Generate"
This is where I run into my first problem. Immediately after generation, without touching any of the code, the project does not build. There are 5 errors caused by the following functions and attributes that appear to not be defined in ivi.h ...
- Ivi_viWrite()
- Ivi_viRead()
- IVI_ATTR_SYSTEM_IO_SESSION
In an effort to quickly check if there were any other issues, I commented out <prefix>_viWrite() and <prefix>_viRead() which call Ivi_viWrite() and Ivi_viRead() respectively as well as the 3 lines that included IVI_ATTR_SYSTEM_IO_SESSION. After doing so, the project builds successfully.
This leads me to the next roadblock that I am stuck on. I made a very simple c file, main.c which includes the following...
#include <string.h>
#include <stdio.h>
#include <formatio.h>
#include <utility.h>
#include <ctype.h>
#include "<prefix>.h"
void main(void) {
ViSession inst_hand;
ViStatus status;
status = <prefix>_init (<addr>, VI_FALSE, VI_FALSE, &inst_hand);
status = <prefix>_reset (inst_hand);
status = <prefix>_close (inst_hand);
return;
}
This compiles and runs, but after the <prefix>_init() call, inst_hand is 1 according to the debugger and when the following line
ViSession io = Ivi_IOSession(vi);
is executed in <prefix>_reset(), the value of io is 0 which of course throws a VI_ERROR_INV_OBJECT error.
I am using NI LabWindows CVI 2017 and I also see that I have IVI Shared Components 2.5 installed. I'm not certain what other bits of software are pertinent in this situation.
With all of that said, does anyone have any input regarding why I have these build errors out of the box and why I am seemingly unable to get a valid instrument handle? Is there any software I may need to upgrade/downgrade? Am I doing something wrong when I try to call these driver functions? I am obviously in way over my head here so any and all feedback is appreciated.
Thank you for taking the time to read through this and for any advice you may have.
Sincerely,
Elliott