Skip to content

Commit

Permalink
instrument support
Browse files Browse the repository at this point in the history
  • Loading branch information
bsaxen committed Feb 10, 2012
1 parent 67fd77b commit 990679a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
2 changes: 1 addition & 1 deletion settings.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Simuino Setting Fri Feb 10 07:51:34 2012
# Simuino Setting Fri Feb 10 09:56:16 2012
PROJECT: work.conf
3 changes: 3 additions & 0 deletions simuino.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ char fileServTime[80] = "servuino/serv.time";
int g_nScenDigital = 0;
int g_nScenAnalog = 0;

int g_row_setup = 0;
int g_row_loop = 0;

int uno_h=0, uno_w=0, uno_x=0, uno_y=0;
int msg_h=0, msg_w=0, msg_x=0, msg_y=0;
int log_h=0, log_w=0, log_x=0, log_y=0;
Expand Down
63 changes: 61 additions & 2 deletions simuino_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,17 +1216,28 @@ int countRowsInFile(char *fileName)
char *replace_str(char *str, char orig[], char rep[])
{
static char buffer[4096];
static char work[4096];
char *p;

if(!(p = strstr(str, orig))) // Is 'orig' even in 'str'?
return str;



strncpy(buffer, str, p-str); // Copy characters from 'str' start to 'orig' st$
buffer[p-str] = '\0';

sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig));
strcpy(work,buffer);

while(p=strstr(work, orig))
{
strncpy(buffer, work, p-work); // Copy characters from 'str' start to 'orig' st$
buffer[p-work] = '\0';
sprintf(buffer+(p-work), "%s%s", rep, p+strlen(orig));
strcpy(work,buffer);
}

return buffer;
return work;
}
//====================================
void instrument(char *fileFrom, char *fileTo)
Expand Down Expand Up @@ -1255,6 +1266,10 @@ void instrument(char *fileFrom, char *fileTo)
while (fgets(row,SIZE_ROW,in)!=NULL)
{
count++;

if(strstr(row,"setup(") != NULL)g_row_setup = count;
if(strstr(row,"loop(") != NULL)g_row_loop = count;

strcpy(sIn,"pinMode(");
sprintf(sTemp,"pinModeX(%d,",count);
p = replace_str(row,sIn,sTemp);
Expand Down Expand Up @@ -1283,6 +1298,50 @@ void instrument(char *fileFrom, char *fileTo)
sprintf(sTemp,"delayMicrosecondsX(%d,",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"attachInterrupt(");
sprintf(sTemp,"attachInterruptX(%d,",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"detachInterrupt(");
sprintf(sTemp,"detachInterruptX(%d,",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.begin(");
sprintf(sTemp,"Serial.beginX(%d,",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.end(");
sprintf(sTemp,"Serial.endX(%d",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.print(");
sprintf(sTemp,"Serial.printX(%d,",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.println(");
sprintf(sTemp,"Serial.printlnX(%d,",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.available(");
sprintf(sTemp,"Serial.availableX(%d",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.write(");
sprintf(sTemp,"Serial.writeX(%d,",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.read(");
sprintf(sTemp,"Serial.readX(%d",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.peek(");
sprintf(sTemp,"Serial.peekX(%d",count);
p = replace_str(p,sIn,sTemp);

strcpy(sIn,"Serial.flush(");
sprintf(sTemp,"Serial.flushX(%d",count);
p = replace_str(p,sIn,sTemp);

fprintf(out,"%s",p);

}
Expand Down

0 comments on commit 990679a

Please sign in to comment.