SICS-750 Restrict sensitive motor commands to debug+manager or initialization
This commit is contained in:
@@ -34,12 +34,15 @@
|
||||
#include <errno.h>
|
||||
#include "anstoutil.h"
|
||||
#include "action.h"
|
||||
#include "sicsglobal.h"
|
||||
|
||||
#define UNITSLEN 256
|
||||
#define TEXTPARLEN 1024
|
||||
#define CMDLEN 1024
|
||||
#define STATE_TRACE (200)
|
||||
|
||||
#define MAGIC_MAN (isDuringInitialization || (self->debug && SCMatchRights(pCon, usMugger)))
|
||||
|
||||
extern double DoubleTime(void);
|
||||
|
||||
/** \brief Used to ensure that the getDMCSetting function is called
|
||||
@@ -4810,77 +4813,77 @@ static int DMC2280SetPar(void *pData, SConnection *pCon,
|
||||
}
|
||||
if (strcasecmp("hardlowerlim", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->fLower = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("hardupperlim", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->fUpper = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("stepsPerX", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->stepsPerX = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (self->abs_encoder && strcasecmp("cntsPerX", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->cntsPerX = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (self->abs_encoder && strcasecmp("bias_bias", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->bias_bias = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (self->abs_encoder && strcasecmp("bias_bits", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->bias_bits = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (self->abs_encoder && strcasecmp("rotary_count", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->rotary_count = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (self->abs_encoder && strcasecmp("rotary_bits", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->rotary_bits = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("motorPollFast", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->motorPollFast = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("motorPollSlow", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->motorPollSlow = newValue;
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp("airPollTimer", name) == 0) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
self->airPollTimer = newValue;
|
||||
return 1;
|
||||
@@ -6081,27 +6084,29 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCWrite(pCon, line, eValue);
|
||||
return 1;
|
||||
}
|
||||
if (self->positions) {
|
||||
free(self->positions);
|
||||
self->positions = NULL;
|
||||
self->posit_count = 0;
|
||||
}
|
||||
if (self->posit_count > 0) {
|
||||
self->posit_count = 0;
|
||||
}
|
||||
if (argc > 2 && strcasecmp("erase", argv[2]) == 0) {
|
||||
char line[132];
|
||||
snprintf(line, 132, "%s.posit_count = %d", self->name, self->posit_count);
|
||||
SCWrite(pCon, line, eValue);
|
||||
if ((MAGIC_MAN)) {
|
||||
if (self->positions) {
|
||||
free(self->positions);
|
||||
self->positions = NULL;
|
||||
self->posit_count = 0;
|
||||
}
|
||||
if (self->posit_count > 0) {
|
||||
self->posit_count = 0;
|
||||
}
|
||||
if (argc > 2 && strcasecmp("erase", argv[2]) == 0) {
|
||||
char line[132];
|
||||
snprintf(line, 132, "%s.posit_count = %d", self->name, self->posit_count);
|
||||
SCWrite(pCon, line, eValue);
|
||||
return 1;
|
||||
}
|
||||
self->posit_count = argc - 2;
|
||||
self->positions = malloc(self->posit_count * sizeof(*self->positions));
|
||||
int i;
|
||||
for (i = 0; i < self->posit_count; ++i) {
|
||||
self->positions[i] = strtod(argv[i + 2], NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
self->posit_count = argc - 2;
|
||||
self->positions = malloc(self->posit_count * sizeof(*self->positions));
|
||||
int i;
|
||||
for (i = 0; i < self->posit_count; ++i) {
|
||||
self->positions[i] = strtod(argv[i + 2], NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if(strcasecmp("position_names", argv[1]) == 0) {
|
||||
if (argc == 2) {
|
||||
@@ -6115,37 +6120,39 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCWrite(pCon, line, eValue);
|
||||
return 1;
|
||||
}
|
||||
if (self->position_names) {
|
||||
if ((MAGIC_MAN)) {
|
||||
if (self->position_names) {
|
||||
int i;
|
||||
for (i = 0; i < self->posit_name_count; ++i) {
|
||||
free(self->position_names[i]);
|
||||
self->position_names[i] = NULL;
|
||||
}
|
||||
free(self->position_names);
|
||||
self->position_names = NULL;
|
||||
self->posit_name_count = 0;
|
||||
}
|
||||
if (self->posit_name_count > 0) {
|
||||
self->posit_name_count = 0;
|
||||
}
|
||||
if (argc > 2 && strcasecmp("erase", argv[2]) == 0) {
|
||||
char line[132];
|
||||
snprintf(line, 132, "%s.posit_name_count = %d", self->name, self->posit_name_count);
|
||||
SCWrite(pCon, line, eValue);
|
||||
return 1;
|
||||
}
|
||||
self->posit_name_count = argc - 2;
|
||||
self->position_names = malloc(self->posit_name_count * sizeof(*self->position_names));
|
||||
int i;
|
||||
for (i = 0; i < self->posit_name_count; ++i) {
|
||||
free(self->position_names[i]);
|
||||
self->position_names[i] = NULL;
|
||||
self->position_names[i] = strdup(argv[i + 2]);
|
||||
}
|
||||
free(self->position_names);
|
||||
self->position_names = NULL;
|
||||
self->posit_name_count = 0;
|
||||
}
|
||||
if (self->posit_name_count > 0) {
|
||||
self->posit_name_count = 0;
|
||||
}
|
||||
if (argc > 2 && strcasecmp("erase", argv[2]) == 0) {
|
||||
char line[132];
|
||||
snprintf(line, 132, "%s.posit_name_count = %d", self->name, self->posit_name_count);
|
||||
SCWrite(pCon, line, eValue);
|
||||
return 1;
|
||||
}
|
||||
self->posit_name_count = argc - 2;
|
||||
self->position_names = malloc(self->posit_name_count * sizeof(*self->position_names));
|
||||
int i;
|
||||
for (i = 0; i < self->posit_name_count; ++i) {
|
||||
self->position_names[i] = strdup(argv[i + 2]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (self->abs_encoder && strcasecmp("absEncHome", argv[1]) == 0) {
|
||||
if (argc > 2) {
|
||||
/* Debug Managers only */
|
||||
if (!(self->debug && SCMatchRights(pCon, usMugger)))
|
||||
if (!(MAGIC_MAN))
|
||||
return 0;
|
||||
long lValue = strtol(argv[2], NULL, 10);
|
||||
self->absEncHome = lValue;
|
||||
|
||||
Reference in New Issue
Block a user