From fb7741178d065f3e10f28f8573f77192623f1f52 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Tue, 28 Apr 2015 16:17:32 +0200 Subject: [PATCH 1/3] - remob.c: forward errors to sics correctly - minor, more cosmetic fixes --- ascon.c | 6 ++++++ dynstring.c | 1 + logreader.c | 29 ++++++++++------------------- remob.c | 32 ++++++++++++++++++++++++++++---- sicsutil.c | 3 ++- 5 files changed, 47 insertions(+), 24 deletions(-) diff --git a/ascon.c b/ascon.c index be3e0a1d..66e51362 100644 --- a/ascon.c +++ b/ascon.c @@ -388,6 +388,12 @@ int AsconBaseHandler(Ascon * a) } void AsconInsertProtocol(AsconProtocol *protocol) { + AsconProtocol *p; + + for (p = protocols; p != NULL; p = p->next) { + if (p == protocol) + return; + } protocol->next = protocols; protocols = protocol; } diff --git a/dynstring.c b/dynstring.c index c45a6afd..1c5987a5 100644 --- a/dynstring.c +++ b/dynstring.c @@ -101,6 +101,7 @@ void DeleteDynString(pDynString self) if (self->pBuffer) free(self->pBuffer); + self->iMAGIC = 0; free(self); } diff --git a/logreader.c b/logreader.c index f5cd6f03..f3258fae 100644 --- a/logreader.c +++ b/logreader.c @@ -218,9 +218,7 @@ static int LogReader(SConnection * pCon, SicsInterp * pSics, void *pData, int argc, char *argv[]) { /* Usage: - graph [ none ] np [ ...] - graph text - graph [ ...] + graph [ none | text | np ] [ ...] and are seconds since epoch (unix time) or, if the value is below one day, a time relative to the actual time @@ -230,15 +228,13 @@ static int LogReader(SConnection * pCon, SicsInterp * pSics, void *pData, is the maximal number of points to be returned. If more values are present and the values are numeric, the data is reduced. If the data is not numeric, the last values may be skipped in order to avoid overflow. + If np is not given, it is assumed to be very high. is the name of a variable (several vaiables may be given). Note that slashes are converted to dots, and that the first slash is ignored. - The seconds variant is for text values, which can not be reduced. In any case, all values - are returned. - - The third variant is old style and can be replaced by the first variant, where - = ( - ) / + 2 + "text" means that the values are not numeric, in this case np is not needed + and by default infinitely high Output format: @@ -308,15 +304,16 @@ Statistics *old; to += now; } iarg = 3; + type0 = NUMERIC; while (1) { if (iarg >= argc) goto illarg; if (strcasecmp(argv[iarg], "text") == 0) { /* non-numeric values */ iarg++; step = 1; - type0 = TEXT; np = to - from + 2; - break; + type0 = TEXT; + /* break; */ } else if (strcasecmp(argv[iarg], "none") == 0) { /* none */ iarg++; if (iarg >= argc) @@ -327,7 +324,6 @@ Statistics *old; iarg++; if (iarg >= argc) goto illarg; - type0 = NUMERIC; np = strtol(argv[iarg], &p, 0); if (p == argv[iarg]) goto illarg; @@ -341,14 +337,9 @@ Statistics *old; } break; } else { - step = strtol(argv[iarg], &p, 0); - if (p == argv[iarg]) - goto illarg; - iarg++; - if (step <= 0) - step = 1; - type0 = NUMERIC; - np = (from - to) / step + 2; + np = to - from + 2; + step = 1; + break; } } if (step <= 0) diff --git a/remob.c b/remob.c index 3aa384ea..87c21cf4 100644 --- a/remob.c +++ b/remob.c @@ -313,7 +313,8 @@ static int RemTransact(RemServer * remserver, int nChan, int try; int argMask; RemChannel *rc = &remserver->rc[nChan]; - + pDynString errorResult; + try = 3; if (rc->timeout) { /* eat old responses */ while (RemRead(rc, 0) > 0) { @@ -339,6 +340,20 @@ tryagain: if (iRet <= 0) goto close; while (!StartsWith(rc->line, "TRANSACTIONFINISHED")) { + if (StartsWith(rc->line, "ERROR:")) { + errorResult = CreateDynString(60, 64); + do { + RemHandle(remserver); + DynStringConcat(errorResult, rc->line); + DynStringConcat(errorResult, "\n"); + iRet = RemRead(rc, 2000); + } while (!StartsWith(rc->line, "TRANSACTIONFINISHED")); + if (pCon != NULL) { + SCPrintf(pCon, eError, "ERROR: in %s:\n%s", remserver->name, GetCharArray(errorResult)); + } + DeleteDynString(errorResult); + return -2; + } RemHandle(remserver); va_start(ap, cmd); arg = va_arg(ap, char *); @@ -448,15 +463,17 @@ static float RemobGetValue(void *pData, SConnection * pCon) SCDeleteConnection(remserver->conn); } remserver->conn = SCCopyConnection(pCon); - none = -1.25e6; + none = -1.234e32; value = none; snprintf(buf, sizeof(buf), "<%s", remob->name); /* get value needs only spy priviledge */ iRet = RemTransact(remserver, 0, pCon, remob->name, buf, &value, ">", NULL); + /* if (iRet <= 0) { return 0.0; } + */ if (value != none) { return value; } @@ -654,7 +671,13 @@ int RemobAction(SConnection * pCon, SicsInterp * pSics, void *pData, remserver->conn = SCCopyConnection(pCon); } if (argc == 1) { - iRet = RemTransact(remserver, nChan, pCon, remob->name, ">", NULL); + /* filter out time stamps !=== */ + iRet = RemTransact(remserver, nChan, pCon, remob->name, "!===", ">", NULL); + if (iRet < 0) { + iRet = 0; + } else { + iRet = 1; + } } else if (strcasecmp(argv[1], "interest") == 0) { /* ignore interest commands, as they would not work properly */ iRet = 1; @@ -666,7 +689,8 @@ int RemobAction(SConnection * pCon, SicsInterp * pSics, void *pData, cmd = Arg2Tcl0(argc - 1, argv + 1, buf, sizeof buf, remob->name); if (cmd) { - RemTransact(remserver, nChan, pCon, cmd, ">", NULL); + /* filter out time stamps !=== */ + RemTransact(remserver, nChan, pCon, cmd, "!===", ">", NULL); if (cmd != buf) free(cmd); } diff --git a/sicsutil.c b/sicsutil.c index 53f89034..c18f6686 100644 --- a/sicsutil.c +++ b/sicsutil.c @@ -51,7 +51,8 @@ double DoubleTime(void) { struct timeval now; /* the resolution of this function is usec, if the machine supports this - and the mantissa of a double is 51 bits or more (31 for sec and 20 for mic$ + and the mantissa of a double is 51 bits or more (31 bits for seconds + and 20 for microseconds) */ gettimeofday(&now, NULL); return now.tv_sec + now.tv_usec / 1e6; From 7d535abd731bb5dc5dde3169bfe5866d6d1919a7 Mon Sep 17 00:00:00 2001 From: Koennecke Mark Date: Mon, 4 May 2015 08:04:54 +0200 Subject: [PATCH 2/3] Fixed a core dump in monitor mode in countersec.c --- countersec.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/countersec.c b/countersec.c index e393786b..2ec4f3e8 100644 --- a/countersec.c +++ b/countersec.c @@ -184,13 +184,17 @@ static int SecCtrCheckStatus(void *pData, SConnection *pCon) fControl = v.v.doubleValue; } else { node = GetHipadabaNode(self->pDes->parNode,"values"); - assert(node != NULL); - /* - The 1 below is only correct for PSI where only the first - monitor can be the control monitor. Elsewhere this must be the - control monitor channel - */ - fControl = v.v.intArray[1]; + if(node != NULL) { + /* + This can be NULL if the counter is a HM. The values does not + exist and fControl is useless + + The 1 below is only correct for PSI where only the first + monitor can be the control monitor. Elsewhere this must be the + control monitor channel + */ + fControl = v.v.intArray[1]; + } } From 0bcd3b06f6e12c5fc519ca92f5f70915bd7af029 Mon Sep 17 00:00:00 2001 From: Koennecke Mark Date: Fri, 8 May 2015 13:43:49 +0200 Subject: [PATCH 3/3] Fixed a critical bug which prevented gumtree SE from working. No ACt was sent after removing the sycamore protocol --- conman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conman.c b/conman.c index a1d62e34..c8bad638 100644 --- a/conman.c +++ b/conman.c @@ -1323,7 +1323,7 @@ int SCWriteZipped(SConnection * self, char *pName, void *pData, memset(outBuf, 0, 65536); protocolID = GetProtocolID(self); - if (protocolID == 5) { + if (protocolID == 4) { cc = SCGetContext(self); sprintf(outBuf, "SICSBIN ZIP %s %d %d\r\n", pName, compressedLength, cc.transID); @@ -1398,7 +1398,7 @@ int SCWriteBinary(SConnection * self, char *pName, void *pData, memset(outBuf, 0, 65536); protocolID = GetProtocolID(self); - if (protocolID == 5) { + if (protocolID == 4) { cc = SCGetContext(self); sprintf(outBuf, "SICSBIN BIN %s %d %d\r\n", pName, iDataLen, cc.transID); @@ -1504,7 +1504,7 @@ int SCWriteZippedOld(SConnection * self, char *pName, void *pData, memset(outBuf, 0, 65536); protocolID = GetProtocolID(self); - if (protocolID == 5) { + if (protocolID == 4) { cc = SCGetContext(self); sprintf(outBuf, "SICSBIN ZIP %s %d %d\r\n", pName, compressedLength, cc.transID);