# HG changeset patch # User Daniele Nicolodi # Date 1392041974 -3600 # Node ID 211ea3950310defe5a86b08273b575e3c9d01868 # Parent 4ff3e468ab5fcc4895525873d7dfd6a027a7b188 Read AD9956 configuration from configuration file diff -r 4ff3e468ab5f -r 211ea3950310 FXAnalyse.c --- a/FXAnalyse.c Mon Feb 10 15:19:29 2014 +0100 +++ b/FXAnalyse.c Mon Feb 10 15:19:34 2014 +0100 @@ -17,6 +17,7 @@ #include "stat.h" #include "data-provider.h" +#define CONFIGFILE "FXAnalyse.ini" #define SR_LOGGER_IP "145.238.204.91" #define DATAFOLDER "Z:\\Measures-2014" @@ -422,12 +423,15 @@ } + + void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int event, int value, void *callbackData); int main (int argc, char *argv[]) { + int rv; double frequency; char expr[1024]; @@ -442,6 +446,36 @@ return -1; if ((LoggingPanel = LoadPanel (0, "FXAnalyse.uir", LOGGING)) < 0) return -1; + + // construct configuration file path + char pathname[MAX_PATHNAME_LEN]; + char project[MAX_PATHNAME_LEN]; + GetProjectDir(project); + MakePathname(project, CONFIGFILE, pathname); + + // load configuration file */ + IniText configuration = Ini_New(TRUE); + Ini_ReadFromFile(configuration, pathname); + + // get AD9956 configuration parameters + char host[256]; + int port; + double clock; + rv = Ini_StringIntoBuffer(configuration, "AD9956", "host", host, sizeof(host)); + if (! rv) + return -1; + rv = Ini_GetInt(configuration, "AD9956", "port", &port); + if (! rv) + return -1; + rv = Ini_GetDouble(configuration, "AD9956", "clock", &clock); + if (! rv) + return -1; + + // initialyze 1x AD9956 DDS box + DDSFox_Initialize(&DDS1xAD9956, host, port, dedrift.freq0); + + // free + Ini_Dispose(configuration); // initialize 4x AD9959 DDS box DDS4xAD9912_Reset(&DDS4xAD9912); @@ -454,9 +488,6 @@ GetCtrlVal(MainPanel, PANEL_DDS4, &frequency); DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); - // initialyze 1x AD9956 DDS box - DDSFox_Initialize(&DDS1xAD9956, "145.238.205.58", 6665, dedrift.freq0); - GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1); GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2); GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3); diff -r 4ff3e468ab5f -r 211ea3950310 FXAnalyse.ini --- a/FXAnalyse.ini Mon Feb 10 15:19:29 2014 +0100 +++ b/FXAnalyse.ini Mon Feb 10 15:19:34 2014 +0100 @@ -1,2 +1,14 @@ +[AD9956] +host = 145.238.205.58 +port = 6665 +clock = 200e6 + +[AD9912] +host = 145.238.205.55 +port0 = 6665 +port1 = 6666 +port2 = 6667 +port3 = 6668 + [KK] port = COM1:115200