8000 Merge pull request #176 from pycom/pygate_debug-fix · pycom/pycom-micropython-sigfox@944fb2f · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 944fb2f

Browse files
authored
Merge pull request #176 from pycom/pygate_debug-fix
Pygate debug fix on telnet
2 parents 74e7bd1 + 54de96e commit 944fb2f

File tree

5 files changed

+42
-27
lines changed

5 files changed

+42
-27
lines changed

esp32/pygate/lora_pkt_fwd/jitqueue.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,15 +451,15 @@ void jit_print_queue(struct jit_queue_s *queue, bool show_all) {
451451
int loop_end;
452452

453453
if (jit_queue_is_empty(queue)) {
454-
printf("[jit] queue is empty\n");
454+
mp_printf(&mp_plat_print,"[jit] queue is empty\n");
455455
} else {
456456
pthread_mutex_lock(&mx_jit_queue);
457457

458-
printf("[jit] queue contains %d packets:\n", queue->num_pkt);
459-
printf("[jit] queue contains %d beacons:\n", queue->num_beacon);
458+
mp_printf(&mp_plat_print,"[jit] queue contains %d packets:\n", queue->num_pkt);
459+
mp_printf(&mp_plat_print,"[jit] queue contains %d beacons:\n", queue->num_beacon);
460460
loop_end = (show_all == true) ? JIT_QUEUE_MAX : queue->num_pkt;
461461
for (i = 0; i < loop_end; i++) {
462-
printf(" - node[%d]: count_us=%u - type=%d\n",
462+
mp_printf(&mp_plat_print," - node[%d]: count_us=%u - type=%d\n",
463463
i,
464464
queue->nodes[i].pkt.count_us,
465465
queue->nodes[i].pkt_type);

esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ License: Revised BSD License, see LICENSE.TXT file include in the project
6969
#include "lwip/apps/sntp.h"
7070
#include "utils/interrupt_char.h"
7171
#include "py/obj.h"
72+
#include "py/mpprint.h"
7273
#include "modmachine.h"
7374

7475
/* -------------------------------------------------------------------------- */
@@ -1236,7 +1237,7 @@ void TASK_lora_gw(void *pvParameters) {
12361237
}
12371238

12381239
machine_pygate_set_status(PYGATE_STARTED);
1239-
printf("LoRa GW started\n");
1240+
mp_printf(&mp_plat_print, "LoRa GW started\n");
12401241

12411242
/* main loop task : statistics collection */
12421243
while (!exit_sig && !quit_sig) {
@@ -1325,32 +1326,32 @@ void TASK_lora_gw(void *pvParameters) {
13251326
#if DEBUG_LEVEL >= INFO_
13261327
if ( debug_level >= INFO_){
13271328
MSG_INFO("[main] report\n##### %s #####\n", stat_timestamp);
1328-
printf("### [UPSTREAM] ###\n");
1329-
printf("# RF packets received by concentrator: %u\n", cp_nb_rx_rcv);
1330-
printf("# CRC_OK: %.2f%%, CRC_FAIL: %.2f%%, NO_CRC: %.2f%%\n", 100.0 * rx_ok_ratio, 100.0 * rx_bad_ratio, 100.0 * rx_nocrc_ratio);
1331-
printf("# RF packets forwarded: %u (%u bytes)\n", cp_up_pkt_fwd, cp_up_payload_byte);
1332-
printf("# PUSH_DATA datagrams sent: %u (%u bytes)\n", cp_up_dgram_sent, cp_up_network_byte);
1333-
printf("# PUSH_DATA acknowledged: %.2f%%\n", 100.0 * up_ack_ratio);
1334-
printf("### [DOWNSTREAM] ###\n");
1335-
printf("# PULL_DATA sent: %u (%.2f%% acknowledged)\n" 8000 , cp_dw_pull_sent, 100.0 * dw_ack_ratio);
1336-
printf("# PULL_RESP(onse) datagrams received: %u (%u bytes)\n", cp_dw_dgram_rcv, cp_dw_network_byte);
1337-
printf("# RF packets sent to concentrator: %u (%u bytes)\n", (cp_nb_tx_ok + cp_nb_tx_fail), cp_dw_payload_byte);
1338-
printf("# TX errors: %u\n", cp_nb_tx_fail);
1329+
mp_printf(&mp_plat_print, "### [UPSTREAM] ###\n");
1330+
mp_printf(&mp_plat_print, "# RF packets received by concentrator: %u\n", cp_nb_rx_rcv);
1331+
mp_printf(&mp_plat_print, "# CRC_OK: %.2f%%, CRC_FAIL: %.2f%%, NO_CRC: %.2f%%\n", 100.0 * rx_ok_ratio, 100.0 * rx_bad_ratio, 100.0 * rx_nocrc_ratio);
1332+
mp_printf(&mp_plat_print, "# RF packets forwarded: %u (%u bytes)\n", cp_up_pkt_fwd, cp_up_payload_byte);
1333+
mp_printf(&mp_plat_print, "# PUSH_DATA datagrams sent: %u (%u bytes)\n", cp_up_dgram_sent, cp_up_network_byte);
1334+
mp_printf(&mp_plat_print, "# PUSH_DATA acknowledged: %.2f%%\n", 100.0 * up_ack_ratio);
1335+
mp_printf(&mp_plat_print, "### [DOWNSTREAM] ###\n");
1336+
mp_printf(&mp_plat_print, "# PULL_DATA sent: %u (%.2f%% acknowledged)\n", cp_dw_pull_sent, 100.0 * dw_ack_ratio);
1337+
mp_printf(&mp_plat_print, "# PULL_RESP(onse) datagrams received: %u (%u bytes)\n", cp_dw_dgram_rcv, cp_dw_network_byte);
1338+
mp_printf(&mp_plat_print, "# RF packets sent to concentrator: %u (%u bytes)\n", (cp_nb_tx_ok + cp_nb_tx_fail), cp_dw_payload_byte);
1339+
mp_printf(&mp_plat_print, "# TX errors: %u\n", cp_nb_tx_fail);
13391340
if (cp_nb_tx_requested != 0 ) {
1340-
printf("# TX rejected (collision packet): %.2f%% (req:%u, rej:%u)\n", 100.0 * cp_nb_tx_rejected_collision_packet / cp_nb_tx_requested, cp_nb_tx_requested, cp_nb_tx_rejected_collision_packet);
1341-
printf("# TX rejected (collision beacon): %.2f%% (req:%u, rej:%u)\n", 100.0 * cp_nb_tx_rejected_collision_beacon / cp_nb_tx_requested, cp_nb_tx_requested, cp_nb_tx_rejected_collision_beacon);
1342-
printf("# TX rejected (too late): %.2f%% (req:%u, rej:%u)\n", 100.0 * cp_nb_tx_rejected_too_late / cp_nb_tx_requested, cp_nb_tx_requested, cp_nb_tx_rejected_too_late);
1343-
printf("# TX rejected (too early): %.2f%% (req:%u, rej:%u)\n", 100.0 * cp_nb_tx_rejected_too_early / cp_nb_tx_requested, cp_nb_tx_requested, cp_nb_tx_rejected_too_early);
1341+
mp_printf(&mp_plat_print, "# TX rejected (collision packet): %.2f%% (req:%u, rej:%u)\n", 100.0 * cp_nb_tx_rejected_collision_packet / cp_nb_tx_requested, cp_nb_tx_requested, cp_nb_tx_rejected_collision_packet);
1342+
mp_printf(&mp_plat_print, "# TX rejected (collision beacon): %.2f%% (req:%u, rej:%u)\n", 100.0 * cp_nb_tx_rejected_collision_beacon / cp_nb_tx_requested, cp_nb_tx_requested, cp_nb_tx_rejected_collision_beacon);
1343+
mp_printf(&mp_plat_print, "# TX rejected (too late): %.2f%% (req:%u, rej:%u)\n", 100.0 * cp_nb_tx_rejected_too_late / cp_nb_tx_requested, cp_nb_tx_requested, cp_nb_tx_rejected_too_late);
1344+
mp_printf(&mp_plat_print, "# TX rejected (too early): %.2f%% (req:%u, rej:%u)\n", 100.0 * cp_nb_tx_rejected_too_early / cp_nb_tx_requested, cp_nb_tx_requested, cp_nb_tx_rejected_too_early);
13441345
}
1345-
printf("### [JIT] ###\n");
1346+
mp_printf(&mp_plat_print, "### [JIT] ###\n");
13461347
jit_print_queue (&jit_queue, false);
1347-
printf("### [GPS] ###\n");
1348+
mp_printf(&mp_plat_print, "### [GPS] ###\n");
13481349
if (gps_fake_enable == true) {
1349-
printf("# GPS *FAKE* coordinates: latitude %.5f, longitude %.5f, altitude %i m\n", cp_gps_coord.lat, cp_gps_coord.lon, cp_gps_coord.alt);
1350+
mp_printf(&mp_plat_print, "# GPS *FAKE* coordinates: latitude %.5f, longitude %.5f, altitude %i m\n", cp_gps_coord.lat, cp_gps_coord.lon, cp_gps_coord.alt);
13501351
} else {
1351-
printf("# GPS sync is disabled\n");
1352+
mp_printf(&mp_plat_print, "# GPS sync is disabled\n");
13521353
}
1353-
printf("##### END #####\n");
1354+
mp_printf(&mp_plat_print, "##### END #####\n");
13541355
}
13551356
#endif
13561357

esp32/pygate/lora_pkt_fwd/lora_pkt_fwd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Maintainer: Michael Coracin
2525
#ifndef _LORA_PKTFWD_H
2626
#define _LORA_PKTFWD_H
2727

28+
#include "py/mpprint.h"
29+
2830
int lora_gw_init(char *);
2931
int lora_gw_get_debug_level();
3032
void lora_gw_set_debug_level(int level);

esp32/pygate/lora_pkt_fwd/trace.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Maintainer: Michael Coracin
2929
#include <stdbool.h>
3030
#include "esp32_mphal.h"
3131

32+
#include "py/mpprint.h"
33+
3234
// debug levels
3335
#define DEBUG 4
3436
#define INFO_ 3
@@ -43,7 +45,7 @@ extern int debug_level;
4345
#define MSG_DX(LEVEL, fmt, ...) \
4446
do { \
4547
if (debug_level >= LEVEL) \
46-
printf("[%u] lorapf: " #LEVEL " " fmt, mp_hal_ticks_ms(), ##__VA_ARGS__); \
48+
mp_printf(&mp_plat_print, "[%u] lorapf: " #LEVEL " " fmt, mp_hal_ticks_ms(), ##__VA_ARGS__); \
4749
} while (0)
4850

4951
#if DEBUG_LEVEL >= DEBUG

py/mpprint.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2+
/*
3+
* Copyright (c) 2020, Pycom Limited.
4+
*
5+
* This software is licensed under the GNU GPL version 3 or any
6+
* later version, with permitted additional terms. For more information
7+
* see the Pycom Licence v1.0 document supplied with this file, or
8+
* available at https://www.pycom.io/opensource/licensing
9+
*/
110
/*
211
* This file is part of the MicroPython project, http://micropython.org/
312
*
@@ -503,7 +512,8 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
503512
chrs += mp_print_strn(print, str, prec, flags, fill, width);
504513
break;
505514
}
506-
case 'd': {
515+
case 'd':
516+
case 'i': {
507517
mp_int_t val;
508518
if (long_arg) {
509519
val = va_arg(args, long int);

0 commit comments

Comments
 (0)
0