I’m running an XEM3001 board. It appears fine in the FrontPanel application (both v4.0.4 and v.3.1.5). But when I write my own code in Visual Studio 2008 and compile it against either of the two libraries, GetDeviceCount() returns 0 and OpenBySerial() fails.
Here’s the code
#include
#include
#include "okFrontPanelDLL.h"
#define CONFIG_FILE "ok.bit"
okCFrontPanel* initializeFPGA();
// ----------------------------------------------
// main
// ----------------------------------------------
int main (void)
{
okCFrontPanel *xem;
xem = initializeFPGA();
if (NULL == xem)
{
printf("FPGA could not be initialized.\n");
return -1;
}
return 0;
}
// ----------------------------------------------
// initializeFPGA
// Taken from the Front Panel destester sample
// ----------------------------------------------
okCFrontPanel* initializeFPGA()
{
okCFrontPanel *dev;
// Open the first XEM - try all board types.
dev = new okCFrontPanel;
int num = dev->GetDeviceCount();
printf("Number of devices connected: %d\n", num);
if (okCFrontPanel::NoError != dev->OpenBySerial())
{
delete dev;
printf("Device could not be opened. Is one connected?\n");
return(NULL);
}
printf("Found a device: %s\n", dev->GetBoardModelString(dev->GetBoardModel()).c_str());
dev->LoadDefaultPLLConfiguration();
// Get some general information about the XEM.
std::string str;
printf("Device firmware version: %d.%d\n", dev->GetDeviceMajorVersion(), dev->GetDeviceMinorVersion());
str = dev->GetSerialNumber();
printf("Device serial number: %s\n", str.c_str());
str = dev->GetDeviceID();
printf("Device device ID: %s\n", str.c_str());
// Download the configuration file.
if (okCFrontPanel::NoError != dev->ConfigureFPGA(CONFIG_FILE))
{
printf("FPGA configuration failed.\n");
delete dev;
return(NULL);
}
// Check for FrontPanel support in the FPGA configuration.
if (dev->IsFrontPanelEnabled())
printf("FrontPanel support is enabled.\n");
else
printf("FrontPanel support is not enabled.\n");
return(dev);
}
and here’s the output
Number of devices connected: 0
Device could not be opened. Is one connected?
FPGA could not be initialized.