Skip to content

Commit d4d3040

Browse files
committed
【修复】输出信息多一个回车的问题
1 parent 51898a4 commit d4d3040

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

port/mpy_main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ static char *heap = RT_NULL;
6868
void mpy_main(const char *filename) {
6969
int stack_dummy;
7070
stack_top = (void *)&stack_dummy;
71+
rt_uint16_t old_flag;
7172

7273
rtt_getchar_init();
7374

@@ -98,6 +99,11 @@ void mpy_main(const char *filename) {
9899
mp_obj_list_init(mp_sys_argv, 0);
99100
readline_init0();
100101

102+
/* Save the open flag */
103+
old_flag = rt_console_get_device()->open_flag;
104+
/* clean the stream flag. stream flag will automatically append '\r' */
105+
rt_console_get_device()->open_flag &= ~RT_DEVICE_FLAG_STREAM;
106+
101107
if (filename) {
102108
#ifndef MICROPYTHON_USING_UOS
103109
rt_kprintf("Please enable uos module in sys module option first.\n");
@@ -137,6 +143,9 @@ void mpy_main(const char *filename) {
137143
}
138144
}
139145

146+
/* restore the open flag */
147+
rt_console_get_device()->open_flag = old_flag;
148+
140149
gc_sweep_all();
141150

142151
mp_deinit();

0 commit comments

Comments
 (0)