# HG changeset patch # User Daniele Nicolodi # Date 1393244212 -3600 # Node ID bc980095a24d29812170b98595c08fb37c325b43 # Parent 12df3a2b18dee2c03af926f67c42a2ececeed3cb Add scrambler option to KK data provider. Report KK counter version. diff -r 12df3a2b18de -r bc980095a24d kk-data-provider.c --- a/kk-data-provider.c Fri Feb 21 18:42:30 2014 +0100 +++ b/kk-data-provider.c Mon Feb 24 13:16:52 2014 +0100 @@ -20,9 +20,10 @@ { int mainThreadId; int rv; - char *resp; + char *cmd, *resp; struct event event; int nchan; + int scrambler; char port[256]; /* get main thread id to post messages to it */ @@ -46,6 +47,11 @@ if (! rv) nchan = DEFAULT_NCHAN; + /* enable scrambler */ + rv = Ini_GetInt(configuration, "KK", "scrambler", &scrambler); + if (! rv) + scrambler = FALSE; + /* free */ Ini_Dispose(configuration); @@ -71,6 +77,28 @@ goto error; } + /* get counter hardware version string */ + rv = FX_Send("\x81"); + if (! rv) { + SendMessage(mainThreadId, FX_Error()); + goto error; + } + rv = FX_Recv(&resp, TIMEOUT); + if (! rv) { + SendMessage(mainThreadId, FX_Error()); + goto error; + } + /* wait for response */ + while (strneq(resp, "7000", 4)) { + rv = FX_Recv(&resp, TIMEOUT); + if (! rv) { + SendMessage(mainThreadId, FX_Error()); + goto error; + } + } + if (strneq(resp, "7001", 4)) + SendMessage(mainThreadId, "KK Counter version: %s", resp + 4); + /* set report interval 1sec */ rv = FX_Send("\x29"); if (! rv) { @@ -84,7 +112,7 @@ } /* read nchan channels */ - char *cmd = "\x30"; + cmd = "\x30"; cmd[0] += nchan; rv = FX_Send(cmd); if (! rv) { @@ -109,7 +137,9 @@ goto error; } - /* switch scrambler off */ + /* scrambler */ + cmd = "\x50"; + cmd[0] += scrambler; rv = FX_Send("\x50"); if (! rv) { SendMessage(mainThreadId, FX_Error());