Mercurial > hg > fxanalyse
changeset 94:b7ae2d947617
Change default KK port to COM4. Make port configurable via .ini file
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Fri, 22 Mar 2013 18:46:13 +0100 |
parents | 72c46cdfb808 |
children | e437666ab710 |
files | kk-data-provider.c |
diffstat | 1 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kk-data-provider.c Fri Mar 22 17:02:47 2013 +0100 +++ b/kk-data-provider.c Fri Mar 22 18:46:13 2013 +0100 @@ -4,25 +4,46 @@ #include <userint.h> #include <formatio.h> #include <utility.h> +#include <inifile.h> #include "data-provider.h" #include "KKFX80E.h" -#define SERIAL "COM1:115200" +#define CONFIGFILE "FXAnalise.ini" +#define DEFAULTPORT "COM4:115200" int CVICALLBACK KKDataProvider (void *functionData) { int mainThreadId; char *resp; struct event event; + char port[256]; /* get main thread id to post messages to it */ mainThreadId = CmtGetMainThreadID(); + /* path for the configuration file */ + 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 serial port name configuration */ + int rv = Ini_GetStringIntoBuffer(configuration, "KK", "port", port, sizeof(port)); + if (rv == 0) + strncpy(port, DEFAULTPORT, sizeof(port)); + + /* free */ + Ini_Dispose(configuration); + /* initialize library */ FX_Init(); /* connect to KK FX80E counter */ - FX_Open(SERIAL); + FX_Open(port); /* clear transmit buffer */ FX_Send("\x80");