# HG changeset patch # User Daniele Nicolodi # Date 1363974373 -3600 # Node ID b7ae2d9476174d1255f16cac6d16ddf9f44ff7c8 # Parent 72c46cdfb80803ef7c7017f15d255734c94c4c69 Change default KK port to COM4. Make port configurable via .ini file diff -r 72c46cdfb808 -r b7ae2d947617 kk-data-provider.c --- 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 #include #include +#include #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");