2
2
import os
3
3
import sys
4
4
5
+ import click
6
+
5
7
from idf_py_actions .errors import FatalError
6
8
from idf_py_actions .global_options import global_options
7
9
from idf_py_actions .tools import ensure_build_directory , run_tool , run_target
@@ -60,7 +62,7 @@ def _get_commandline_options(ctx):
60
62
61
63
return result
62
64
63
- def monitor (action , ctx , args , print_filter ):
65
+ def monitor (action , ctx , args , print_filter , monitor_baud ):
64
66
"""
65
67
Run idf_monitor.py to watch build output
66
68
"""
@@ -81,7 +83,16 @@ def monitor(action, ctx, args, print_filter):
81
83
monitor_args = [PYTHON , idf_monitor ]
82
84
if args .port is not None :
83
85
monitor_args += ["-p" , args .port ]
84
- monitor_args += ["-b" , project_desc ["monitor_baud" ]]
86
+
87
+ if not monitor_baud :
88
+ if os .getenv ("IDF_MONITOR_BAUD" ):
89
+ monitor_baud = os .getenv ("IDF_MONITOR_BAUD" , None )
90
+ elif os .getenv ("MONITORBAUD" ):
91
+ monitor_baud = os .getenv ("MONITORBAUD" , None )
92
+ else :
93
+ monitor_baud = project_desc ["monitor_baud" ]
94
+
95
+ monitor_args += ["-b" , monitor_baud ]
85
96
monitor_args += ["--toolchain-prefix" , project_desc ["monitor_toolprefix" ]]
86
97
87
98
if print_filter is not None :
@@ -112,7 +123,7 @@ def erase_flash(action, ctx, args):
112
123
113
124
baud_rate = {
114
125
"names" : ["-b" , "--baud" ],
115
- "help" : "Baud rate." ,
126
+ "help" : "Baud rate for flashing ." ,
116
127
"scope" : "global" ,
117
128
"envvar" : "ESPBAUD" ,
118
129
"default" : 460800 ,
@@ -141,24 +152,35 @@ def erase_flash(action, ctx, args):
141
152
"options" : [baud_rate , port ],
142
153
},
143
154
"monitor" : {
144
- "callback" : monitor ,
145
- "help" : "Display serial output." ,
155
+ "callback" :
156
+ monitor ,
157
+ "help" :
158
+ "Display serial output." ,
146
159
"options" : [
147
- port ,
148
- {
160
+ port , {
149
161
"names" : ["--print-filter" , "--print_filter" ],
150
- "help" : (
151
- "Filter monitor output.\n "
152
- "Restrictions on what to print can be specified as a series of <tag>:<log_level> items "
153
- "where <tag> is the tag string and <log_level> is a character from the set "
154
- "{N, E, W, I, D, V, *} referring to a level. "
155
- 'For example, "tag1:W" matches and prints only the outputs written with '
156
- 'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). '
157
- 'Not specifying a <log_level> or using "*" defaults to Verbose level.\n '
158
- 'Please see the IDF Monitor section of the ESP-IDF documentation '
159
- 'for a more detailed description and further examples.' ),
160
- "default" : None ,
161
- },
162
+ "help" :
163
+ ("Filter monitor output.\n "
164
+ "Restrictions on what to print can be specified as a series of <tag>:<log_level> items "
165
+ "where <tag> is the tag string and <log_level> is a character from the set "
166
+ "{N, E, W, I, D, V, *} referring to a level. "
167
+ 'For example, "tag1:W" matches and prints only the outputs written with '
168
+ 'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). '
169
+ 'Not specifying a <log_level> or using "*" defaults to Verbose level.\n '
170
+ 'Please see the IDF Monitor section of the ESP-IDF documentation '
171
+ 'for a more detailed description and further examples.' ),
172
+ "default" :
173
+ None ,
174
+ }, {
175
+ "names" : ["--monitor-baud" , "-B" ],
176
+ "type" :
177
+ click .INT ,
178
+ "help" : ("Baud rate for monitor.\n "
179
+ "If this option is not provided IDF_MONITOR_BAUD and MONITORBAUD "
180
+ "environment variables and project_description.json in build directory "
181
+ "(generated by CMake from project's sdkconfig) "
182
+ "will be checked for default value." ),
183
+ }
162
184
],
163
185
"order_dependencies" : [
164
186
"flash" ,
0 commit comments