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
@@ -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 :
@@ -119,7 +130,7 @@ def erase_flash(action, ctx, args):
119
130
120
131
baud_rate = {
121
132
"names" : ["-b" , "--baud" ],
122
- "help" : "Baud rate." ,
133
+ "help" : "Baud rate for flashing ." ,
123
134
"scope" : "global" ,
124
135
"envvar" : "ESPBAUD" ,
125
136
"default" : 460800 ,
@@ -148,24 +159,35 @@ def erase_flash(action, ctx, args):
148
159
"options" : [baud_rate , port ],
149
160
},
150
161
"monitor" : {
151
- "callback" : monitor ,
152
- "help" : "Display serial output." ,
162
+ "callback" :
163
+ monitor ,
164
+ "help" :
165
+ "Display serial output." ,
153
166
"options" : [
154
- port ,
155
- {
167
+ port , {
156
168
"names" : ["--print-filter" , "--print_filter" ],
157
- "help" : (
158
- "Filter monitor output.\n "
159
- "Restrictions on what to print can be specified as a series of <tag>:<log_level> items "
160
- "where <tag> is the tag string and <log_level> is a character from the set "
161
- "{N, E, W, I, D, V, *} referring to a level. "
162
- 'For example, "tag1:W" matches and prints only the outputs written with '
163
- 'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). '
164
- 'Not specifying a <log_level> or using "*" defaults to Verbose level.\n '
165
- 'Please see the IDF Monitor section of the ESP-IDF documentation '
166
- 'for a more detailed description and further examples.' ),
167
- "default" : None ,
168
- },
169
+ "help" :
170
+ ("Filter monitor output.\n "
171
+ "Restrictions on what to print can be specified as a series of <tag>:<log_level> items "
172
+ "where <tag> is the tag string and <log_level> is a character from the set "
173
+ "{N, E, W, I, D, V, *} referring to a level. "
174
+ 'For example, "tag1:W" matches and prints only the outputs written with '
175
+ 'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). '
176
+ 'Not specifying a <log_level> or using "*" defaults to Verbose level.\n '
177
+ 'Please see the IDF Monitor section of the ESP-IDF documentation '
178
+ 'for a more detailed description and further examples.' ),
179
+ "default" :
180
+ None ,
181
+ }, {
182
+ "names" : ["--monitor-baud" , "-B" ],
183
+ "type" :
184
+ click .INT ,
185
+ "help" : ("Baud rate for monitor.\n "
186
+ "If this option is not provided IDF_MONITOR_BAUD and MONITORBAUD "
187
+ "environment variables and project_description.json in build directory "
188
+ "(generated by CMake from project's sdkconfig) "
189
+ "will be checked for default value." ),
190
+ }
169
191
],
170
192
"order_dependencies" : [
171
193
"flash" ,
0 commit comments