- remob.c: forward errors to sics correctly
- minor, more cosmetic fixes
This commit is contained in:
32
remob.c
32
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user