From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the serial # of the PXI-8430/8 and PXI-8431/8 card programmatically using C#, NI assemblies and VISA?

I am trying to support multiple cards in multiple chassis. I need to map the COM ports I find with VISA to cards in the chassis/slots I find with VISA.

 

NIMAX does this nicely, putting the COM ports under the 8430 and 8431 cards with which they are associated. If you look at the Settings Tab in NIMAX the Serial Number is right there as part of the Settings. I would sure like to know how to get it, seems easy enough.

 

I am using the NationalInstruments.VisaNS and C#. The com ports are very nice and give me all the info I need including Serial Number in the session's HardwareInterfaceName attribute. see code snippet below:

 

HardwareInterfaceType thwt, hwtype;

short sintNum;

string resClass = string.Empty;

string expName = string.Empty;

string alias = string.Empty;

string COM15VisaID = "visa://<ip>/ASRL15::INSTR";

 

Session session = ResourceManager.GetLocalManager().Open(COM15VisaID);

ResourceManager.GetLocalManager().ParseResource(COM15VisaID, out hwtype, out sintNum, out resClass, out expName, out alias);              

 

session.HardwareInterfaceName string value is:  "ASRL15  (COM15 - NI PXI-8430/8 (RS-232) SN:17E536C, Communications Port 1)"

 

---------------------------------------------------------------------------------

Then when I get the 8430 card info i don't get the serial number and I have searched for it in all the data and cannot find it anywhere.  If it was a DIO or AIO card it is as easy as:

 

Device dev = DaqSystem.Local.LoadDevice(dev_str);

long sn = dev.SerialNumber;

 

So I have found a workaround that is not very elegant. I put the serial number into the VISA alias. I really don't want to, but I am at the point of diminishing returns on this. If you add another card to the system, then you MUST change the VISA alias in order for this to work. I would really rather get the serial number from somewhere than adding it by hand. Here is what i get when I get the values for the card after changing the VISA alias:

 

CardVisaID8430 = "visa://<ip>/PXI2::14::INSTR";

Session session = ResourceManager.GetLocalManager().Open(CardVisaID8430);

ResourceManager.GetLocalManager().ParseResource(CardVisaID8430, out hwtype, out sintNum, out resClass, out expName, out alias);              

 

session.HardwareInterfaceName string value is: "PXI2 (PCI Extensions for Instrumentation)"

alias string value is: "visa://<ip>/PXI-8430_Rack1_Slot3_SN017E536C"

 

So now I can associate the com port to the correct cards. Does anyone know how to get the serial number for these cards?

 

Thanks,

Jason

 

 

0 Kudos
Message 1 of 3
(5,144 Views)

Hi Jason,

 

I wasn't able to find a C# function that would obtain the serial number for a PXI card. However, I believe you could use the VI_ATTR_MODEL_NAME function to get the model name of the device. Therefore, you would know whether it was the PXI-8430 or the PXI-8431. If this does not work, your workaround will work like you said. I know that this is not your desired way of achieving this, however, it will work. I can continue looking though and see if I can find a function that will return the serial number. 

 

Thanks,

Kevin S
Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(5,100 Views)

solution in LabVIEW

https://decibel.ni.com/content/docs/DOC-48473

אור הירשפלד
Or Hirshfeld
Application Engineer
Certified LabVIEW Developer
SK- Electronika
+972-545844555
Or.Hirshfeld@SK-Advanced.com
il.linkedin.com/in/orhirshfeld
0 Kudos
Message 3 of 3
(3,591 Views)