Example Code

Change DAQmx Device Alias Programmatically

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Download All

Overview

This example demonstrates how to programmatically change the alias of any device using LabVIEW.

  

Description

Device aliases show up as Dev1, Dev2, Dev3... by default, but often you will change those to more meaningful names. Programmatically changing the device name may come in handy when distributing applications to multiple systems. This example could be used to change your NI PCIe-6321 to X-Series in an initialization sequence, and then reference it as such in the rest of your application.

 

Requirements

Software

  • LabVIEW 2012 or compatible

 

Steps to Implement or Execute Code

  1. Retrieve list of all DAQmx devices.
  2. Iterate through list of devices to find desired device.
  3. Change alias.
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
zlavick
Member
Member
on

Hi!, I've got this error:

     Error -2147467259 occurred at nisyscfg.lvlib:Rename Alias.vi

     Possible reason(s):

          LabVIEW:  (Hex 0x80004005) Unspecified error.

          =========================

          NI System Configuration:  (Hex 0x80004005) Miscellaneous operation failure.

Example on Windows host works without any problem, but on RT Target it generates this error (outputs for products and device aliases are correct).

Problem with drivers? Can it be solved?

D_Biel
Active Participant
Active Participant
on

Zlavick,

I did not have RT in mind when I originally wrote this example, but it should work. I was able to run it on my RT target without errors. How are you viewing your errors? Have you made any modification to the original code I posted?

National Instruments
zlavick
Member
Member
on

I'm using your code without any modification, just setting Device=NI PCI-6221 and New Alias=Dev4 (now it is Dev2).

ProdName's array getting correctly:  NI PCI-6229, NI PCI-6221. And aliases too: Dev1,Dev2. So, "system session" refnum is alive.

Before "Rename Alias.vi" have no errors.

I've tried to set "session in" to localhost  (and run it @ RT Target) and tried Remote Target (and run it @ my win host), but the result is the same - error.

May be trouble with my RT's software?

>Error -2147467263 occurred at nisyscfg.lvlib:Rename Alias.vi

That error code is "Not implemented".  What it means is that the version of DAQmx you are using does not implement the Rename functionality.  It was introduced in DAQmx 9.2 if I recall correctly, so try updating to that version and it should work. Source.

But my DAQmx version is 9.2.1... What is DAQmx version at your RT target?

D_Biel
Active Participant
Active Participant
on

I am using DAQmx 9.4 and System Configuration API 5.0. I could not find any bug fixes that would affect this, but that can be hard to tell sometimes.

If you run a project with just the ChangeAlias.vi in it, do you still receive the error? You could try debugging it from LV and see specifically which function is causing the error.

National Instruments
zlavick
Member
Member
on

1. To run "ChangeAlias.vi" i need "resource in" input, and i can't get it without other "sys.conf" vi's. If i running only in "ChangeAlias.vi" in empty VI, i'm getting expected error:

 

     Error -2147467261 occurred at an unidentified location

     Possible reason(s):

           LabVIEW:  (Hex 0x80004003) Invalid pointer.

     =========================

     NI System Configuration:  (Hex 0x80004003) A required pointer parameter was NULL.

2. Now i'm using DAQmx 9.4 & Sys. Confg. API 5.0 too, but error still with me.

3. "ChangeAlias.vi" is password protected, how can i debug it?

zlavick
Member
Member
on

SOLVED!

The problem was too strange.