close the command shell

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Jeroen3
Posts: 35
Joined: Wed Apr 02, 2014 10:14 am

Re: close the command shell

Post by Jeroen3 »

I've created my own shell since the included one lacks timeouts. This is the main receive loop.
sh_stream is a SerialDriverfrom either a serialport or a custom SerialDriver compatible fifo from a telnet thread I still need to write since the supplied memstreams are truncating and also lack timeouts.

Code: Select all

   while(!chThdShouldTerminate()){
      int b;
      if( sh_stream != NULL ){
         b = sdGetTimeout(sh_stream, MS2ST(5000));
         if(b < Q_OK){
            sh_stream = NULL;
            chEvtBroadcastFlags(&sh_event, sh_evt_idleTimeout);
         }else{
            sh_putByte( b );
         }      
      }else{
         // Wait to be woken up by sh_start()
         chThdSleep(TIME_INFINITE);
      }
   }   
   chThdExit(0);

Shell logs out automatically after 5 seconds of idle.

Reset the chip this way:

Code: Select all

NVIC_SystemReset();
Post Reply