check all targets for valid numbers before driving any
This commit is contained in:
29
drive.c
29
drive.c
@ -1,7 +1,7 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
Implementation file for the drive command
|
||||
|
||||
|
||||
This version as Test for Device Executor.
|
||||
|
||||
Mark Koennecke, December 1996
|
||||
@ -66,7 +66,7 @@ int Drive(SConnection * pCon, SicsInterp * pInter, char *name, float fNew)
|
||||
|
||||
/* check if user is allowed to drive */
|
||||
if (!SCMatchRights(pCon, usUser)) {
|
||||
snprintf(pBueffel, 511, "Insuficient Privilege to drive %s", name);
|
||||
snprintf(pBueffel, 511, "Insufficient Privilege to drive %s", name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -160,7 +160,7 @@ int Start2Run(SConnection * pCon, SicsInterp * pInter, char *name,
|
||||
|
||||
/* check if user is allowed to drive */
|
||||
if (!SCMatchRights(pCon, usUser)) {
|
||||
snprintf(pBueffel,511, "Insuficient Privilege to drive %s", name);
|
||||
snprintf(pBueffel,511, "Insufficient Privilege to drive %s", name);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
return 0;
|
||||
}
|
||||
@ -301,7 +301,7 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* interprete arguments as pairs name value and try to start */
|
||||
/* interpret arguments as pairs (name, value) and check */
|
||||
SetStatus(eDriving);
|
||||
for (i = 1; i < argc; i += 2) {
|
||||
if (argv[i + 1] == NULL) {
|
||||
@ -313,7 +313,22 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
iRet = Tcl_GetDouble(tcl_interp, argv[i + 1], &dTarget);
|
||||
if (iRet == TCL_ERROR) {
|
||||
SCWrite(pCon, Tcl_GetStringResult(tcl_interp), eError);
|
||||
StopExe(GetExecutor(), "ALL");
|
||||
SetStatus(eOld);
|
||||
return 0;
|
||||
} else if (!isfinite(dTarget)) {
|
||||
snprintf(pBueffel, 511,
|
||||
"ERROR: target %s value for %s is not a finite number",
|
||||
argv[i + 1], argv[i]);
|
||||
SCWrite(pCon, pBueffel, eError);
|
||||
SetStatus(eOld);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* interpret arguments as pairs (name, value) and try to start */
|
||||
for (i = 1; i < argc; i += 2) {
|
||||
iRet = Tcl_GetDouble(tcl_interp, argv[i + 1], &dTarget);
|
||||
if (iRet == TCL_ERROR) {
|
||||
SCWrite(pCon, Tcl_GetStringResult(tcl_interp), eError);
|
||||
SetStatus(eOld);
|
||||
return 0;
|
||||
}
|
||||
@ -360,7 +375,7 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SetStatus(eOld);
|
||||
return 0;
|
||||
}
|
||||
SCWrite(pCon, "Driving finished sucessfully", eValue);
|
||||
SCWrite(pCon, "Driving finished successfully", eValue);
|
||||
SetStatus(eOld);
|
||||
return 1;
|
||||
}
|
||||
@ -398,7 +413,7 @@ int RunWrapper(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* interprete arguments as pairs name value and try to start */
|
||||
/* interpret arguments as pairs name value and try to start */
|
||||
SetStatus(eDriving);
|
||||
for (i = 1; i < argc; i += 2) {
|
||||
if (argv[i + 1] == NULL) {
|
||||
|
Reference in New Issue
Block a user