ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

AddressCollection

Solved!
Go to solution

HI,

 

I want to use the FindListeners function to get a list of the devices that are attached to the gpib.

How do I use the AddressCollection object and an addresslist to find the primary and secondarry addresses of all the devices on the bus. 

 

Here's what I have so far.

public bool FindListeners()
        {

            try
            {

                m_board = new Board(m_boardnum);
                m_addresslist = new AddressCollection(); 
                
                m_addresslist = m_board.FindListeners();

                Trace.WriteLine("Number of Device found " + m_addresslist.Count);
                Trace.WriteLine("Devices " + m_addresslist.ToString());
                 
 
   
                return true;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                return false;
            }

        }

 

How do I read the primary and secondary address values?

 

Thanks

 

Curt

 

 

 

 

0 Kudos
Message 1 of 2
(3,396 Views)
Solution
Accepted by topic author Curt_C

Hi ,

 

I figured this one out myself.

 

if anyone is interested, here's how you do it.

Copy the contents of the AddressCollection to an Address array.

 

        public bool FindListeners()
        {

            try
            {

                m_board = new Board(m_boardnum);
                m_addresslist = new AddressCollection(); 
                
                m_addresslist = m_board.FindListeners();

                Address[] m_address = new Address[m_addresslist.Count ];
                
                Trace.WriteLine("Number of Device found " + m_addresslist.Count);
                Trace.WriteLine("Devices " + m_addresslist.ToString());

                 
                for (int i = 0; i < m_addresslist.Count; i++)
                {
                    m_addresslist.CopyTo(m_address, i);
                    Trace.WriteLine(i + m_address[i].PrimaryAddress.ToString());
                    Trace.WriteLine(i + m_address[i].SecondaryAddress.ToString());    
                }
   
                return true;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                return false;
            }

        }

 

Curt

 

0 Kudos
Message 2 of 2
(3,391 Views)