Example #1
0
void Task_LCD(void)
{
   /* task setup */
   INT16U uiValorAD = 0;
   init_lcd();

   //strcpypgm2ram (BufferLCD, (const rom char far *)"ugenios + BRTOS");
   BufferLCD[0] = 0xE4;

   write_lcd(BufferLCD);
   
   posiciona(2, 1);
   //strcpypgm2ram (BufferLCD, (const rom char far *)"Temp: ");
   write_lcd(BufferLCD);


   TRISA = 0xFF;   

   InicializaAD();

   // Liga resistencia de aquecimento
   LATCbits.LATC5 = 1;
   TRISCbits.TRISC5 = 0;

   // Liga ventilador
   LATCbits.LATC2 = 0;
   TRISCbits.TRISC2 = 0;

   uiValorAD = LeValorAD();

    // task main loop
    for (;;) 
    {
    
      
      uiValorAD = LeValorAD();

      if (uiValorAD >= 30)
      {
         // Liga ventilador
         LATCbits.LATC2 = 1;    
         // Desliga resist�ncia
         LATCbits.LATC5 = 0;
      }else
      {
         // Desliga ventilador
         LATCbits.LATC2 = 0;    
         // Liga resist�ncia
         LATCbits.LATC5 = 1;
      }

      posiciona(2, 7);
      write_numero(uiValorAD);

      BufferLCD[0]=0xDF;
      BufferLCD[1]='C';
      BufferLCD[2]=0;
      write_lcd(BufferLCD);
 
      DelayTask(1000);
    }
}
Example #2
0
/**
 * Import test cases from POKE-TOOL.
 */
ImportPoke(int argc, char *argv[])
{
	FILE	*testCaseFile, *parametersFile;
	int	i, j, k, cont, TemPar;
	char 	*c;
	char XLabel[NOME_LENGTH+1];
	char parameters[PARAMSIZE] = "";

	if (carrega_arquivo_tcase(&testSet, workingDir, testSessionName) == ERRO) {
		return ERRO;
	}

	for (i = firstTestCase, cont = 0; i <= lastTestCase; i++) {
		// Try to import command line parameters for test case number i
		printf(testCaseInputDataImportFilename, "input%d.tes", i);
		strcpy(parameters, "");
		TemPar = FALSE;
		if (tem_arq(testCaseImportDir, testCaseInputDataImportFilename, "")) {
			parametersFile = abrearq(testCaseImportDir, testCaseInputDataImportFilename, "", 0);
			if (parametersFile != NULL) {
				posifim(parametersFile);
				k = ftell(parametersFile);
				if (k >= sizeof(parameters)) {
					msg("Invalid POKE-TOOL parameter file");
					fecharq(parametersFile);
				} else {
					posiciona(parametersFile, 0);
					fgets(parameters, (int) k, parametersFile);
				        k = strlen(parameters);
				        if (k > 0 && parameters[k-1] == '\n') {
						parameters[k-1] = '\0';
					}
					fecharq(parametersFile);
					TemPar = TRUE;
				}
			}
		}

		// Try to import test case number i
		sprintf(testCaseInputDataImportFilename, "tec%d.tes", i);
		if (tem_arq(testCaseImportDir, testCaseInputDataImportFilename, "")) {
			testCaseFile = abrearq(testCaseImportDir, testCaseInputDataImportFilename, "", 0);
			if (testCaseFile == NULL) {
				msg("Invalid POKE-TOOL test case");
				break;
			}
			fecharq(testCaseFile);
		}

		if (exec_from_ascii(executableDir, executableFilename, instrumentedExecutableFilename, parameters, workingDir, testSessionName, &(TREG(&testSet)), 120,  enableTrace, SHELL, isInteractive) == ERRO) {
			break;
		}
		TREG(&testSet).interativo = isInteractive;
		inic_to_buf(TREG(&testSet).param, sizeof(TREG(&testSet).param));
		inic_from_buf(parameters);
	   	for (c = from_buf(); c != NULL; c = from_buf()) {
			if (to_buf(c) == ERRO) {
				break;
			}
		}
		if (! isempty(Label)) {
			sprintf(XLabel, "%s%d", Label, i);
		} else {
			testCaseInputDataImportFilename[0] = '\0';
		}

		if (strlen(XLabel) <= LABELSIZE) {
			strcpy(TREG(&testSet).label, XLabel);
		} else {
			msg("Invalid label");
			TREG(&testSet).label[0] = '\0';
		}

		if (insere_tcase(&testSet,  enableTrace) == ERRO) {
                	break;
		}

		cont++;
		if (verbosityChar != '\0' && ! isspace(verbosityChar)) {
			fprintf(stdout, "%c", verbosityChar);
			fflush(stdout);
		}
	}

	printf("\n%d test cases imported from POKE-TOOL files\n", cont);

	descarrega_arquivo_tcase(&testSet);
	return OK;
}
Example #3
0
/**
 * Import test cases from plain text files.
 */
int
ImportAscii(int argc, char *argv[])
{
	FILE *testCaseFile, *parametersFile;
	int i, j, k, cont;
	char testCaseFilename[NOME_LENGTH+10];
	char parametersFilename[NOME_LENGTH+10];
	long t;
	char *c;
	char parameters[PARAMSIZE] = "";
	char XLabel[NOME_LENGTH+1];

	if (carrega_arquivo_tcase(&testSet, workingDir, testSessionName) == ERRO) {
		msg("Could not load test set");
		return ERRO;
	}

	if (strlen(testCaseInputDataImportFilename) > 0 || strlen(testCaseParametersImportFilename)) {
		msg("Invalid import filename");
	}

	for (i = firstTestCase, cont = 0; i <= lastTestCase; i++) {
		sprintf(parametersFilename, "%s%d", testCaseInputDataImportFilename, i);
		fprintf(stdout, "\nReading command line parameters from file %s", parametersFilename);
		strcpy(parameters, "");
		if (tem_arq(testCaseImportDir, parametersFilename, "")) {
		 	parametersFile = abrearq(testCaseImportDir, parametersFilename, "", 0);
			if (parametersFile == NULL) {
				fprintf(stdout, "\nError reading command line parameters");
			} else {
				posifim(parametersFile);
				t = ftell(parametersFile);
				posiciona(parametersFile, 0);
				if (t > sizeof(parameters)) {
					msg("Parameter too big");
				   	fclose(parametersFile);
				} else {
					fgets(parameters, (int) t, parametersFile);
					fclose(parametersFile);
					k = strlen(parameters);
					if (k > 0 && parameters[k-1] == '\n') {
						parameters[k-1] = '\0';
					}
				}
			}
		}

		sprintf(testCaseFilename, "%s%d", testCaseParametersImportFilename, i);
		printf("\nReading input data from file %s", testCaseFilename);
		if ( tem_arq(testCaseImportDir, testCaseFilename, "")) {
			testCaseFile = abrearq(testCaseImportDir, testCaseFilename, "", 0);
			if (testCaseFile == NULL) {
				fprintf(stdout, "\nError reading input data");
			}
			fecharq(testCaseFile);
			if (exec_from_ascii(executableDir, executableFilename, instrumentedExecutableFilename, parameters, workingDir, testSessionName, &(TREG(&testSet)), 120,  enableTrace, SHELL, isInteractive) == ERRO) {
				fprintf(stdout, "\nCould not run executable against input data and command line parameters");
			} else {
				TREG(&testSet).interativo = isInteractive;
				inic_to_buf(TREG(&testSet).param, sizeof(TREG(&testSet).param));
				inic_from_buf(parameters);
		   		for (c = from_buf(); c != NULL; c = from_buf())	{
					if (to_buf(c) == ERRO) {
						break;
					}
				}
		        	if (! isempty(Label)) {
					sprintf(XLabel, "%s%d", Label, i);
				} else {
        				XLabel[0] = '\0';
				}

			        if (strlen(XLabel) <= LABELSIZE) {
        				strcpy(TREG(&testSet).label, XLabel);
				} else {
     					msg("Invalid label");
					TREG(&testSet).label[0] = '\0';
				}

				if (insere_tcase(&testSet,  enableTrace) == ERRO) {
					fprintf(stderr, "\nCould not import the test case %d", i);
				} else {
					cont++;
			        	if (verbosityChar != '\0' && ! isspace(verbosityChar)) {       
						fprintf(stdout, "%c", verbosityChar);
				       		fflush(stdout);
					}
				}
			}
		}
	}

	fprintf(stdout, "\n%d test cases imported from ASCII files\n", cont);
	descarrega_arquivo_tcase(&testSet);

	return OK;
}
Example #4
0
/**
 * Shot data of a test case.
 *
 * @param i Number of test case
 * @param phis Physical record number of this test case. If you do not know
 * it, set it to zero (so that Proteum look for this data by itself).
 */
int
ListaTCase(int i, int phis)
{
	int	n, j, k, t;
	struct vetfunc	*p;
	char c;

   k = i;
   if (! phis) 
      k = ltofis_tcase(&testSet, i);
   if (k == ERRO)
	return;
   if (le_tcase_reg(&testSet, k) == ERRO)
	return;

   printf("\nTeste Case # %d %d", i, k);
   printf("\nLabel:\t%s", TREG(&testSet).label);
   printf("\n\t%s", TAB_FIS(&testSet)[k].desabili? "DISABLED": "ENABLED");
   if (TAB_FIS(&testSet)[k].error)
	printf("\n\tTest case caused an ERROR");
   printf("\n\tExec. Time (CPU): %ld", TREG(&testSet).exetempo); 
   printf("\n\tExec. Time (total): %ld", TREG(&testSet).totaltempo);
   printf("\n\tReturn Code: %d", TREG(&testSet).retcode);
   if (TAB_FIS(&testSet)[k].error)
	printf(" (Failure with test case)");
   printf("\n\tParameters: %s", (char *) build_param(TREG(&testSet).param));
   printf("\n\tInput Size: %d", TREG(&testSet).tamanho_ent);
   printf("\n\tOutput Size: %d", TREG(&testSet).tamanho_sai);
   printf("\n\tStderr Size: %d", TREG(&testSet).tamanho_err);

   printf("\n\tInput:\n");
   posiciona(TFILEIO(&testSet), TREG(&testSet).apont_ent);
   for (j = 0; j < TREG(&testSet).tamanho_ent; j++)
   {
	fscanf(TFILEIO(&testSet), "%c", &c);
	printf("%c", c);
   }

/*   copy_file(TFILEIO(&testSet), TREG(&testSet).apont_ent, 
				TREG(&testSet).tamanho_ent, stdout); */

   t = TREG(&testSet).tamanho_ent;
   printf("\n\tOutput:\n");
   copy_file(TFILEIO(&testSet), TREG(&testSet).apont_ent + t, 
				TREG(&testSet).tamanho_sai, stdout);
   t += TREG(&testSet).tamanho_sai;
   printf("\n\tStderr:\n");
   copy_file(TFILEIO(&testSet), TREG(&testSet).apont_ent + t, 
				TREG(&testSet).tamanho_err, stdout);
   printf("\nTravessed blocks:");
   tcase_get_log(&testSet, -1, -1);
   if ( testSet.log != NULL)
      for (n = 0; n < testSet.log->nfunction; n++)
      {
	 p = &(testSet.log->vetfunc[n]);
	 printf("\n\tFunction: %ld\n\tBlocks: ", p->function);
	 for (j = 1; j <= p->nnode; j++)
	 {
	   if (get_log_bit(p->nodes, j))
		printf("%d ", j);
	 }
      }

   printf("\n");

}