diff --git a/ascon.c b/ascon.c index 98039cc8..6943f813 100644 --- a/ascon.c +++ b/ascon.c @@ -392,6 +392,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;