Skip to content

Commit dc21313

Browse files
committed
Merge branch 'feat/net_debug_support_idf_v54' into 'master'
feat: at_net_debug.py supported esp-idf v5.4 See merge request application/esp-at!1872
2 parents 17e75a9 + b47229c commit dc21313

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

tools/at_net_debug.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
#
3-
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3+
# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
44
# SPDX-License-Identifier: Apache-2.0
55

66
import sys, os, argparse
@@ -194,10 +194,11 @@ def ESP_LOGE(x):
194194
"""
195195

196196
# Find the entry of netif tx returns
197-
at_net_tx_ret_pos_pattern = 'if (ret == ESP_OK) {'
197+
at_net_tx_ret_pos_pattern_v54_before = 'if (ret == ESP_OK) {' # < v5.4
198+
at_net_tx_ret_pos_pattern_v54_after = 'return ret;' # >= v5.4
198199
at_net_tx_ret_caller = """
199200
if (ret != ESP_OK) {
200-
ESP_LOGE("@@if-tx", "netif tx error, tot_len:%d len:%d ret: %d", q->tot_len, q->len, ret);
201+
ESP_LOGE("@@if-tx", "netif tx error, tot_len:%d len:%d ret: %d", p->tot_len, p->len, ret);
201202
}
202203
"""
203204

@@ -311,7 +312,13 @@ def at_patch_net_debug_snippet(args):
311312
raise Exception('No TX caller entry found.')
312313
data = data[:pos] + at_net_tx_caller + '\n ' + data[pos:]
313314

314-
pos = data.find(at_net_tx_ret_pos_pattern)
315+
# add tx caller of netif tx returns for esp-idf version < v5.4
316+
pos = data.find(at_net_tx_ret_pos_pattern_v54_before)
317+
if pos > 0:
318+
data = data[:pos] + at_net_tx_ret_caller + '\n ' + data[pos:]
319+
320+
# add tx caller of netif tx returns for esp-idf version >= v5.4
321+
pos = data.find(at_net_tx_ret_pos_pattern_v54_after)
315322
if pos > 0:
316323
data = data[:pos] + at_net_tx_ret_caller + '\n ' + data[pos:]
317324

0 commit comments

Comments
 (0)