Enumerating Devices

Prior to opening a device, you can use an instance of okCFrontPanel to list available devices. It’s important to note that a device is only available in one thread or process at a time and therefore will not be visible in this list if another thread or process has already opened it.
We’ll use GetDeviceCount() to query available devices, then use GetDeviceListModel() and GetDeviceListSerial() to list the model numbers and serial numbers for each attached device, respectively.


okCFrontPanel dev; int devCount = dev.GetDeviceCount(); for (i=0; i < devCount; i++) { std::cout << "Device[" << i << "] Model : " << dev.GetDeviceListModel(i) << "\n"; std::cout << "Device[" << i << "] Serial : " << dev.GetDeviceListSerial(i) << "\n"; }
Code language: PHP (php)


okCFrontPanel device = new okCFrontPanel(); int count = device.GetDeviceCount(); int i; for (i = 0; i < count; i++) { Console.WriteLine("Device[{0}] Model: {1}", i, device.GetDeviceListModel(i)); Console.WriteLine("Device[{0}] Serial: {1}", i, device.GetDeviceListSerial(i)); }
Code language: JavaScript (javascript)


device = ok.okCFrontPanel() deviceCount = device.GetDeviceCount() for i in range(deviceCount): print 'Device[{0}] Model: {1}'.format(i, device.GetDeviceListModel(i)) print 'Device[{0}] Serial: {1}'.format(i, device.GetDeviceListSerial(i))
Code language: PHP (php)


public class EnumDevice{ okCFrontPanel device; int devCount; int previousCount; int i; public void Initialize(){ device = new okCFrontPanel(); previousCount = device.GetDeviceCount(); } public void Enumerate(){ devCount = device.GetDeviceCount(); if(devCount != previousCount){ for(i = 0; i < devCount; i++){ System.out.println("Device["+i+"] Model: " + device.GetDeviceListModel(i)); System.out.println("Device["+i+"] Serial: " + device.GetDeviceListSerial(i)); } } } }
Code language: PHP (php)