Skip to content

Commit

Permalink
bug corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
bsaxen committed Jan 4, 2012
1 parent cce8ad1 commit d85fbbd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 38 deletions.
4 changes: 2 additions & 2 deletions settings.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Simuino Setting Wed Jan 4 11:07:37 2012
PROJECT: test_uno.conf
# Simuino Setting Wed Jan 4 22:17:34 2012
PROJECT: work.conf
34 changes: 19 additions & 15 deletions simuino.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,13 @@ int goStep(int step)
{
char stemp[SIZE_ROW];

currentStep = step;
if(currentStep > g_steps || currentStep < 1)

if(step > g_steps || step < 1)
{
currentStep = checkRange(HEAL,"step",currentStep);
return(STOP);
step = checkRange(HEAL,"step",step);
//return(STOP);
}
currentStep = step;
currentLoop = stepLoop[currentStep];
winLog();
winSer();
Expand Down Expand Up @@ -392,7 +393,7 @@ void openCommand()
putMsg(2,"Wrong pin number or pin type!");
}
else
putMsg(2,"Syntax: del <a or d> <pin> <step>");
putMsg(2,"Syntax: rem <a or d> <pin> <step>");
}
else if(strstr(sstr,"add")) //
{
Expand Down Expand Up @@ -758,9 +759,13 @@ void runMode(int stop)
{
runNextRead();
}
else if (ch=='j')
{
runPrevRead();
}
else if (ch=='i')
{
step = currentStep + 1;
step = currentStep;
sprintf(temp,"(Step:%d) Enter: d/a pin value (q - cancel)",step);
putMsg(2,temp);
wgetstr(uno,temp);
Expand All @@ -770,30 +775,29 @@ void runMode(int stop)
{
g_pinNo = atoi(command[1]);
x = atoi(command[2]);

if(!strcmp(command[0],"a"))
printf("%s %d %d",command[0],g_pinNo,x);
if(strstr(command[0],"a"))
{
ok = ok + checkRange(S_OK,"anapin",g_pinNo);
ok = ok + checkRange(S_OK,"anaval",x);
g_pinType = ANA;
}
if(!strcmp(command[0],"d"))
if(strstr(command[0],"d"))
{
ok = ok + checkRange(S_OK,"digpin",g_pinNo);
ok = ok + checkRange(S_OK,"digval",x);
g_pinType = DIG;
}

if(ok == S_OK)
{
g_scenSource = 1;
// steps, source, pintype, pinno, pinvalue, pinstep
sprintf(syscom,"cd servuino;./servuino %d %d %d %d %d %d %d;",confSteps,g_scenSource,g_pinType,g_pinNo,x,currentStep+1,ADD);
sprintf(syscom,"cd servuino;./servuino %d %d %d %d %d %d %d;",confSteps,g_scenSource,g_pinType,g_pinNo,x,currentStep,ADD);
tmp=system(syscom);
initSim();
readSketchInfo();
readSimulation();
runStep(FORWARD);
goStep(currentStep);
readMsg(fileServScen);
}
}
Expand All @@ -802,7 +806,7 @@ void runMode(int stop)
}
else if (ch=='v')
{
step = currentStep + 1;
step = currentStep ;
sprintf(temp," Enter value to be read at step %d (q - cancel)",step);
putMsg(2,temp);
res = analyzeEvent(simulation[step]);
Expand All @@ -820,12 +824,12 @@ void runMode(int stop)
{
g_scenSource = 1;
// steps, source, pintype, pinno, pinvalue, pinstep
sprintf(syscom,"cd servuino;./servuino %d %d %d %d %d %d %d;",confSteps,g_scenSource,g_pinType,g_pinNo,x,currentStep+1,ADD);
sprintf(syscom,"cd servuino;./servuino %d %d %d %d %d %d %d;",confSteps,g_scenSource,g_pinType,g_pinNo,x,currentStep,ADD);
tmp=system(syscom);
initSim();
readSketchInfo();
readSimulation();
runStep(FORWARD);
goStep(currentStep);
readMsg(fileServScen);
}
}
Expand Down
2 changes: 1 addition & 1 deletion simuino.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ void noInterrupts();
int readStatus();
void readSerial();
void readTime();

int goStep(int step);
44 changes: 24 additions & 20 deletions simuino_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void unoInfo()
wmove(uno,ap+2,3);

if(g_existError == YES)
wprintw(uno," [Errors - err]");
wprintw(uno," [Errors - err] ");
else if(g_warning == YES)
wprintw(uno," [Possible Mismatch - load]");
else
Expand Down Expand Up @@ -567,17 +567,6 @@ void readConfig(char *cf)
}
fclose(in);
}
//====================================
int readEvent(char *ev, int step)
//====================================
{
if(step > 0 && step <= g_steps)
strcpy(ev,simulation[step]);
else
return(0);
return(step);
}


//====================================
void runLoop(int dir)
Expand Down Expand Up @@ -669,13 +658,28 @@ void endOfSimulation()
void runNextRead()
//====================================
{
char event[80];
int x;
char event[120];

while (!strstr(event,"digitalRead") && !strstr(event,"analogRead") && currentStep < g_steps)
{
runStep(FORWARD);
x = readEvent(event, currentStep+1);
currentStep++;
goStep(currentStep);
strcpy(event,simulation[currentStep]);
}
return;
}

//====================================
void runPrevRead()
//====================================
{
char event[80];

while (!strstr(event,"digitalRead") && !strstr(event,"analogRead") && currentStep > 0)
{
currentStep--;
goStep(currentStep);
strcpy(event,simulation[currentStep]);
}
return;
}
Expand Down Expand Up @@ -1316,7 +1320,7 @@ int readStatus()
//====================================
{
FILE *in;
char row[SIZE_ROW];
char row[SIZE_ROW],*p;
int step=0,res=0;

in = fopen(fileServStatus,"r");
Expand All @@ -1327,7 +1331,7 @@ int readStatus()
}
else
{
fgets(row,SIZE_ROW,in);// read first header line in file
p = fgets(row,SIZE_ROW,in);// read first header line in file
while (fgets(row,SIZE_ROW,in)!=NULL)
{
sscanf(row,"%d",&step);
Expand All @@ -1346,7 +1350,7 @@ void readSerial()
//====================================
{
FILE *in;
char *left,*right; char row[SIZE_ROW],line[SIZE_ROW],value[SIZE_ROW];
char *left,*right; char row[SIZE_ROW],line[SIZE_ROW],value[SIZE_ROW],*p;
int step=0,res=0;

in = fopen(fileServSerial,"r");
Expand All @@ -1357,7 +1361,7 @@ void readSerial()
}
else
{
fgets(row,SIZE_ROW,in);// read first header line in file
p = fgets(row,SIZE_ROW,in);// read first header line in file
while (fgets(row,SIZE_ROW,in)!=NULL)
{
//strcpy(serial[step],row);
Expand Down

0 comments on commit d85fbbd

Please sign in to comment.