10-27-2010 07:08 AM
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
Solved! Go to Solution.
10-27-2010 08:48 AM
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