arch/sim/src/: Simulator restore the console even error handler call host exit directly.

This commit is contained in:
Xiang Xiao 2019-12-16 09:01:25 -06:00 committed by Gregory Nutt
parent 6c362c8521
commit 3a5e2b7ce7
3 changed files with 16 additions and 20 deletions

View File

@ -40,16 +40,13 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <assert.h>
#include <nuttx/init.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/power/pm.h>
#include <nuttx/syslog/syslog_rpmsg.h>
#include "up_internal.h"
@ -104,12 +101,6 @@ int main(int argc, char **argv, char **envp)
#endif
}
#ifdef USE_DEVCONSOLE
/* Restore the original terminal mode and return the exit code */
simuart_terminate();
#endif
return g_exitcode;
}

View File

@ -285,7 +285,6 @@ void simuart_start(void);
int simuart_putc(int ch);
int simuart_getc(bool block);
bool simuart_checkc(void);
void simuart_terminate(void);
/* up_uartwait.c **********************************************************/

View File

@ -40,6 +40,7 @@
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <termios.h>
#include <pthread.h>
#include <errno.h>
@ -113,6 +114,17 @@ static void setrawmode(void)
(void)tcsetattr(0, TCSANOW, &raw);
}
/****************************************************************************
* Name: restoremode
****************************************************************************/
static void restoremode(void)
{
/* Restore the original terminal mode */
(void)tcsetattr(0, TCSANOW, &g_cooked);
}
/****************************************************************************
* Name: simuart_thread
****************************************************************************/
@ -212,6 +224,10 @@ void simuart_start(void)
setrawmode();
/* Restore the original terminal mode before exit */
atexit(restoremode);
/* Start the simulated UART thread -- all default settings; no error
* checking.
*/
@ -298,13 +314,3 @@ bool simuart_checkc(void)
return g_uarthead != g_uarttail;
}
/****************************************************************************
* Name: simuart_terminate
****************************************************************************/
void simuart_terminate(void)
{
/* Restore the original terminal mode */
(void)tcsetattr(0, TCSANOW, &g_cooked);
}