Re: close the command shell
Posted: Mon Sep 22, 2014 9:54 am
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.
Shell logs out automatically after 5 seconds of idle.
Reset the chip this way:
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();