void CommandLine(void)
{
	u08 c;
	/* Variable to Run or stop program */
	Run = TRUE;

	/* Clears the screen and sets the cursor under the Title */
	vt100ClearScreen();
	vt100SetCursorPos(1,0);

	rprintfProgStrM("\r\n\t\t\tStepper Motor Driver - Serial Console\r\n");

	cmdlineInit();
	cmdlineSetOutputFunc(uartSendByte);

	cmdlineAddCommand("quit", quitCommandLine);
	cmdlineAddCommand("help", helpDisplay);
	cmdlineAddCommand("step", runMotor);

	cmdlineInputFunc('\r');

	while(Run)
	{
		while( uartReceiveByte(&c) )
			cmdlineInputFunc(c);

		cmdlineMainLoop();

	}

	rprintfCRLF();
	rprintf("Program halted.");


}
Exemplo n.º 2
0
int 
main(int argc, char **argv)
{
	char ch;

	cprintf("Main started\nVersion: ");
	cprintf(MAIN_VERSION);
	cprintf("\n");

	for (ch = 0; ch < 26; ch++) {
		osram_write(osram_init[ch]);
	};

	rs485Init();
	steppersInit();

	cmdlineInit();
	cmdlineAddCommand("help", do_help);
	cmdlineAddCommand("?", do_help);
	cmdlineAddCommand("dump", do_dump);
	cmdlineAddCommand("ls", do_ls);
	cmdlineAddCommand("dir", do_ls);
	cmdlineAddCommand("mv", do_rename);
	cmdlineAddCommand("rename", do_rename);
	cmdlineAddCommand("rm", do_rm);
	cmdlineAddCommand("delete", do_rm);
	cmdlineAddCommand("spi_speed", do_spi_speed);
	cmdlineAddCommand("osram", do_osram);
	cmdlineAddCommand("flash", do_flash);
	cmdlineAddCommand("readmem", do_readmem);
	cmdlineAddCommand("rd", do_rd);
	cmdlineAddCommand("wr", do_wr);
	cmdlineAddCommand("rd32", do_rd32);
	cmdlineAddCommand("wr32", do_wr32);
	cmdlineAddCommand("step", do_step);
	cmdlineAddCommand("build", do_build);
	cmdlineAddCommand("sendcmd", do_sendcmd);
	cmdlineAddCommand("reset", (void *)0xE000);
	cmdlinePrintPrompt();

	while (1) {
		if (getc_nowait(&ch)) {
			cmdlineInputFunc(ch);
		};
		cmdlineMainLoop();
		rs485MainLoop();
		steppersMainLoop();
	};

	cprintf("\ndone\n");
		
	return 0;
}
Exemplo n.º 3
0
void setup_menu (void) {                                                        // function for setup menu
  char cmd;                                                                     // variable used as buffer for debug USART and debug menu service 
  menuInit();
  printf("\n\rPress CTRL+C if you want to exit menu and continue running program\n\r");
  cmdlinePrintPrompt();
  while (1) {
    cmd=TM_USART_Getc(MENU_USART);
    if(cmd==0x03) {                                                             // check for CTRL+C keypress send from terminal emulator
      printf("\n\rCTRL+C was detected, leaving menu\n\r");
      break;
     }
    cmdlineInputFunc(cmd);
    Delay(100);
    cmdlineMainLoop();
  }   
}
Exemplo n.º 4
0
/*------------------------------------------------------------------------------------*/
void tkCmd(void * pvParameters)
{

u08 c;
u08 ticks;
( void ) pvParameters;

	while ( !startTask )
		vTaskDelay( ( TickType_t)( 100 / portTICK_RATE_MS ) );

	cmdlineInit();
	cmdlineSetOutputFunc(pvFreeRTOS_UART1_writeChar);

	cmdlineAddCommand((u08 *)("cls"), cmdClearScreen );
	cmdlineAddCommand((u08 *)("help"), cmdHelpFunction);
	cmdlineAddCommand((u08 *)("reset"), cmdResetFunction);
	cmdlineAddCommand((u08 *)("read"), cmdReadFunction);
	cmdlineAddCommand((u08 *)("write"), cmdWriteFunction);
	cmdlineAddCommand((u08 *)("redial"), cmdRedialFunction);
	cmdlineAddCommand((u08 *)("status"), cmdStatusFunction);


	// Espero la notificacion para arrancar
	vTaskDelay( ( TickType_t)( 500 / portTICK_RATE_MS ) );

	snprintf_P( cmd_printfBuff,sizeof(cmd_printfBuff),PSTR("starting tkCmd..\r\n\0"));
	FreeRTOS_write( &pdUART1, cmd_printfBuff, sizeof(cmd_printfBuff) );

	ticks = 1;
	FreeRTOS_ioctl( &pdUART1,ioctlSET_TIMEOUT, &ticks );

	// loop
	for( ;; )
	{
		u_clearWdg(WDG_CMD);

		c = '\0';	// Lo borro para que luego del un CR no resetee siempre el timer.
		// el read se bloquea 50ms. lo que genera la espera.
		while ( FreeRTOS_read( &pdUART1, &c, 1 ) == 1 ) {
			cmdlineInputFunc(c);
		}

		/* run the cmdline execution functions */
		cmdlineMainLoop();
	}
}
Exemplo n.º 5
0
void goCmdline(void)
{
	u08 c;

	// print welcome message
	vt100ClearScreen();
	vt100SetCursorPos(1,0);
	rprintfProgStrM("\r\nWelcome to the Command Line Test Suite!\r\n");

	// initialize cmdline system
	cmdlineInit();

	// direct cmdline output to uart (serial port)
	cmdlineSetOutputFunc(uartSendByte);

	// add commands to the command database
	cmdlineAddCommand("exit",		exitFunction);
	cmdlineAddCommand("help",		helpFunction);
	cmdlineAddCommand("dumpargs1",	dumpArgsStr);
	cmdlineAddCommand("dumpargs2",	dumpArgsInt);
	cmdlineAddCommand("dumpargs3",	dumpArgsHex);

	// send a CR to cmdline input to stimulate a prompt
	cmdlineInputFunc('\r');

	// set state to run
	Run = TRUE;

	// main loop
	while(Run)
	{
		// pass characters received on the uart (serial port)
		// into the cmdline processor
		while(uartReceiveByte(&c)) cmdlineInputFunc(c);

		// run the cmdline execution functions
		cmdlineMainLoop();
	}

	rprintfCRLF();
	rprintf("Exited program!\r\n");
}
Exemplo n.º 6
0
void tkCmd(void * pvParameters)
{

u08 c;

( void ) pvParameters;

	// !!! Requiere que este inicializado el FRTOS porque usa semaforos.
	MCP_init();		// IO ports for hardware

	vTaskDelay( (portTickType)( 1000 / portTICK_RATE_MS ) );

	initDebugRtc();
	initBlueTooth();

	vt100ClearScreen(CMD_UART);

	// Inicializo los parametros de trabajo ( leo la internal EE ).
	loadSystemParams();

	// Inicializo la memoria. Leo el estado de los punteros ( leo la external EE).
	BD_init();
	//
	vTaskDelay( (portTickType)( 100 / portTICK_RATE_MS ) );
	snprintf_P( cmd_printfBuff,CHAR128,PSTR("\r\n.INIT EEmem BD: wrPtr=%d, rdPtr=%d, recUsed=%d, recFree=%d\r\n\0"),  BD_getWRptr(),  BD_getRDptr(), BD_getRcsUsed(), BD_getRcsFree() );
	logPrintStr(LOG_NONE, cmd_printfBuff);
	switch (mcpDevice) {
	case MCP23008:
#ifdef CHANNELS_3
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("System: 3 analogIn,2 digitalIn\r\n\0"));
#endif
#ifdef CHANNELS_8
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("System: 8 analogIn,2 digitalIn\r\n\0"));
#endif
		break;
	case MCP23018:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("System: 3 analogIn,2 digitalIn,4 valves\r\n\0"));
		break;
	default:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("ERROR !! No analog system detected\r\n\0"));
		break;
	}
	logPrintStr(LOG_NONE, cmd_printfBuff);

	// Inicializo el sistema de consignas.
	initConsignas();
	switch (systemVars.consigna.tipo) {
	case CONS_NONE:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("Init consignas: none\r\n\0"));
		break;
	case CONS_DOBLE:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("Init consignas: doble\r\n\0"));
		break;
	default:
		snprintf_P( cmd_printfBuff,CHAR128,PSTR("Init consignas: ERROR\r\n\0"));
		break;
	}
	logPrintStr(LOG_NONE, cmd_printfBuff);
	//


	// Init Banner.
	snprintf_P( cmd_printfBuff,CHAR128,PSTR("\r\nSpymovil %s %s"), SP5K_MODELO, SP5K_VERSION);
	logPrintStr(LOG_NONE, cmd_printfBuff);
	snprintf_P( cmd_printfBuff,CHAR128,PSTR(" %d-%s-%s"), NRO_CHANNELS, EE_TYPE, FTYPE);
	logPrintStr(LOG_NONE, cmd_printfBuff);
	snprintf_P( cmd_printfBuff,CHAR128,PSTR(" %s %s\r\n\0"), SP5K_REV, SP5K_DATE );
	logPrintStr(LOG_NONE, cmd_printfBuff);

#ifdef MEMINFO
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_Uart0TxQueue=%lu\r\n\0"), HE_Uart0TxQueue );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_Uart1RxQueue=%lu\r\n\0"), HE_Uart1RxQueue );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_Uart1TxQueue=%lu\r\n\0"), HE_Uart1TxQueue );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_I2Cbus=%lu\r\n\0"), HE_I2Cbus );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_CmdUart=%lu\r\n\0"), HE_CmdUart );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_GprsUart=%lu\r\n\0"), HE_GprsUart );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_digitalIn=%lu\r\n\0"), HE_digitalIn );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_systemVars=%lu\r\n\0"), HE_systemVars );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_BD=%lu\r\n\0"), HE_BD );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkCmd=%lu\r\n\0"), HE_tkCmd );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkDigitalIn=%lu\r\n\0"), HE_tkDigitalIn );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkData=%lu\r\n\0"), HE_tkData );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkControl=%lu\r\n\0"), HE_tkControl );
	logPrintStr(LOG_NONE, &cmd_printfBuff);
	snprintf_P( &cmd_printfBuff,CHAR128,PSTR("HE_tkGprs=%lu\r\n\0"), HE_tkGprs );
	logPrintStr(LOG_NONE, &cmd_printfBuff);

#endif

	// Habilito al resto del sistema a arrancar
	if (xSemaphoreTake( sem_systemVars, MSTOTAKESYSTEMVARSSEMPH ) == pdTRUE ) {
		systemVars.initStatus = TRUE;
		xSemaphoreGive( sem_systemVars );
	}

	for( ;; )
	{

		// Para medir el uso del stack
		tkCmd_uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );

		clearWdg(WDG_CMD);
		while(xUartGetChar(CMD_UART, &c, (50 / portTICK_RATE_MS ) ) ) {
			cmdlineInputFunc(c);
			// Cada caracer recibido reinicio el timer.
			restartTimerTerminal();
		}
		/* run the cmdline execution functions */
		cmdlineMainLoop();

	}

}
Exemplo n.º 7
0
int main(void)
{
    avr_init();
u08 even;

//    u16 i;
//u08 temp;
	command = 45;
//	actualTemp = 85;

//	u16 temp;
    for(;;)
    {
        // Tasks here.
        // Command line reception of commands...
		// pass characters received on the uart (serial port)
		// into the cmdline processor
//        while(uartReceiveByte(&c)){
//        vt100SetCursorPos(1, 0);
//        uartSendByte(c);
//        cmdlineInputFunc(c);
//
//        }
        // bounce the character, keep to the top 3 rows...

		// run the cmdline execution functions
       	vt100SetCursorPos(3, 0);
		cmdlineMainLoop();
        // Command line reception ends here



    	if (APP_STATUS_REG & BV(DO_SAMPLE))
    	{
    		readMAX6675(&tempData);		// get data to tempData variable
    		CLEAR_SAMPLE_FLAG;
    	//debug, invert pin
    	PIND ^= BV(PD5);
    
    	//update PID
    //	output = pid_Controller(command, tempData, &PID_data);
    
    	//invert PID
    //	output = PHASE_ANGLE_LIMIT_HIGH - output;
    	}


    	if(APP_STATUS_REG & BV(DO_PID))
    	{
    		#ifdef REG_PID	
    		//update PID
    		output = pid_Controller(command, tempData, &PID_data);
#ifndef CMDLINE
    #ifndef RX_DBG
    		rprintf("PID raw: ");
    		rprintfNum(10, 6,  TRUE, ' ',   output);		rprintfCRLF();
    #endif
    		//invert & limit PID
            if(output > 29700) output = 700;
            //output = PHASE_ANGLE_LIMIT_HIGH - output;
    #ifndef RX_DBG
    		rprintf("PID scaled: ");
    		rprintfNum(10, 6,  TRUE, ' ',   output);		rprintfCRLF();
    #endif
#endif
    		#endif
    
    		#ifdef REG_PD
    
    		#endif
    //		actualTemp +=10;
    //		OCR0A = output;
    		CLEAR_PID_FLAG;
    
//    	}
/*
		if((temp = 0xFFFF-output) > 30000)
		{	temp = 30000;}
		else if (temp < 1000)
		{	temp = 1000;}
*/

    // Limit to within 1 half-phase:
    	if((output > PHASE_ANGLE_LIMIT_HIGH) || (output < 0)){
#ifndef CMDLINE
#ifndef RX_DBG
    		rprintf("Max out");rprintfCRLF();
#endif
#endif
    		output = PHASE_ANGLE_LIMIT_HIGH;	// don't fire the triac at all!
    		SET_HOLD_FIRE;						// set flag to not fire triac
    	}
    	else
    	{		
    		CLEAR_HOLD_FIRE;						// set flag to fire triac
    	}
    	
    	if ((output < PHASE_ANGLE_LIMIT_LOW)){  // || (output < 0))
#ifndef CMDLINE
#ifndef RX_DBG
    		rprintf("Min out");rprintfCRLF();
#endif
#endif
    		output = PHASE_ANGLE_LIMIT_LOW;		// fire the triac at zerocrozz to get complete halfwave
    
    	}
#ifndef WALK_PHASEANGLE
		OCR1A = output;
#endif
		//OCR1A = PHASE_ANGLE_LIMIT_LOW;
		//OCR1A = PHASE_ANGLE_LIMIT_HIGH;
	}



#ifdef DEBUG_SER
//	uartPrintfNum(10, 6,  TRUE, ' ',   1234);  -->  " +1234"
//	uartPrintfNum(16, 6, FALSE, '.', 0x5AA5);  -->  "..5AA5"

//	rprintfNum(10, 4,  FALSE, ' ',   tempData);//		rprintfCRLF();
#ifndef CMDLINE
#ifndef RX_DBG

            if(sensorDisconnected)
        	{
        		rprintfProgStrM("Disconnected Probe!\r\n");
        	}
        	else
        	{

            rprintf("Process Value: ");
    		rprintfNum(10, 4,  FALSE, ' ',   tempData);		rprintfCRLF();
    
    		rprintf("Target Value: ");
    		rprintfNum(10, 4,  FALSE, ' ',   command);		rprintfCRLF();
    
    //  	rprintf("PID Phaselimit: ");
    //  	rprintfNum(10, 6,  TRUE, ' ',   output);		rprintfCRLF();
    
    		rprintf("OCR1A: ");
    		rprintfNum(10, 6,  FALSE, ' ',   OCR1A);	rprintfCRLF();
    
            //-----------
    //		rprintf("dummy: ");
    //		rprintfNum(10, 6,  TRUE, ' ',   _DUMMY);		rprintfCRLF();
    
    		rprintf("E ");
    		rprintfNum(10, 4,  TRUE, ' ',   _ERROR);		rprintfCRLF();
    
    		rprintf("P ");
    		rprintfNum(10, 8,  TRUE, ' ',   _PTERM);		rprintfCRLF();
    
    		rprintf("I ");
    		rprintfNum(10, 8,  TRUE, ' ',   _ITERM);		rprintfCRLF();
    
    		rprintf("D ");
    		rprintfNum(10, 8,  TRUE, ' ',   _DTERM);		rprintfCRLF();
    //-----------
    
            }
    
        	vt100SetCursorPos(3, 0);
        	if(even++ == 10){
        		vt100ClearScreen();
                vt100SetCursorPos(3,0);
        		even = 0;
        	}
#endif //#ifndef RX_DBG
#endif //#ifndef CMDLINE
#endif //#ifdef DEBUG_SER
    }
    
    return(0);
}