LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting VISA resource to instrument handle..

Hello,

I am trying to make a DLL in LabWindowsCVI for use in LabVIEW. This particular DLL will communicate with a serial device. I used the "Create IVI Instrument Driver" to generate the base code. But the "Init" function has no way of configuring the serial port before use !!

So how do I go about doing this? I thought I could use the "VISA Configure Serial Port" vi from labviews, then pass the resource name from that into the instrument handle of the CVI function..but those data types aren't compatible.
Configuring the port from either CVI or Labview is fine..I'm just a bit flumoxed that the code generator didn't take this detail into account. Help !!

Kindest regards,
Warren Crossfield
0 Kudos
Message 1 of 5
(4,868 Views)
The idea of these instrument drivers is to abstract out the low level configuration and port communication and create a simple function and attribute list for a common instrument type. The IVI wizard lets you configure the default serial port settings for the session if you picked Serial as the instrument bus.

If you need to change these programmatically from the specification of the driver, you would get the VISA session from the instrument driver with:

prefix_GetAttributeViSession (instHandle, "",
TEST_ATTR_IO_SESSION, &visaSession);

where prefix is the prefix of your instrument driver.

Then with that visaSession, you can use the viSetAttribute in CVI to change the serial settings.

Again, the reason this is not in
the init function is that it is very uncommon to need to change the serial settings from the defaults defined in the instrument driver for the same instrument.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 5
(4,868 Views)
I think the recommended solution would be to setup the serial port with MAX. You then use an IVI Logical Name to open a handle to your instrument. The IVI Logical Name refers to a Virtual Instrument, which refers to an IVI Device, which refers to your serial port. All this configuration is done with MAX. The problem is that configuring MAX is a manual operation that must be done anytime you install your application on a new machine. Would be really nice if there was an API to MAX so these settings could be made programmatically.
0 Kudos
Message 3 of 5
(4,868 Views)
Hi Mark,

Yes, and what bugs me is that the IVI expects that each serial device we communicate with to remain at certain settings during it's operation. Those settings should be considered nothing less than a configurable item on that device. Oh well..maybe they will come around someday? 😉
0 Kudos
Message 5 of 5
(4,868 Views)
Warren:

Make sure you pass false(0) to both the IDquery and the Reset parameters to the Init function. This will usually ensure that no I/O is done to the device at this time. Then you can use the output handle and do what Chris suggested, to use VISA directly to modify the communications parameters.

Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments
0 Kudos
Message 4 of 5
(4,868 Views)