1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #15285 from basilfx/feature/optimize_debug

treewide: more cleanups of ENABLE_DEBUG
This commit is contained in:
Bas Stottelaar 2020-11-03 11:13:53 +01:00 committed by GitHub
commit e8cadc02d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
65 changed files with 478 additions and 546 deletions

View File

@ -72,7 +72,7 @@ void priority_queue_add(priority_queue_t *root, priority_queue_node_t *new_obj)
new_obj->next = NULL;
}
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
void priority_queue_print(priority_queue_t *root)
{
printf("queue:\n");

View File

@ -20,6 +20,7 @@
*/
#include <stdint.h>
#include <inttypes.h>
#include "sched.h"
#include "clist.h"
@ -35,11 +36,6 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
/* For PRIu16 etc. */
#include <inttypes.h>
#endif
#ifdef PICOLIBC_TLS
#include <picotls.h>
#endif

View File

@ -203,10 +203,10 @@ static int _esp_eth_send(netdev_t *netdev, const iolist_t *iolist)
}
}
#if ENABLE_DEBUG
printf ("%s: send %d byte\n", __func__, dev->tx_len);
/* esp_hexdump (dev->tx_buf, dev->tx_len, 'b', 16); */
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf ("%s: send %d byte\n", __func__, dev->tx_len);
/* esp_hexdump (dev->tx_buf, dev->tx_len, 'b', 16); */
}
int ret = 0;
@ -253,9 +253,9 @@ static int _esp_eth_recv(netdev_t *netdev, void *buf, size_t len, void *info)
return -ENOBUFS;
}
#if ENABLE_DEBUG
/* esp_hexdump (dev->rx_buf, dev->rx_len, 'b', 16); */
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
esp_hexdump (dev->rx_buf, dev->rx_len, 'b', 16);
}
/* copy received date and reset the receive length */
memcpy(buf, dev->rx_buf, dev->rx_len);

View File

@ -316,13 +316,14 @@ unsigned int IRAM timer_read(tim_t dev)
{
CHECK_PARAM_RET (dev < HW_TIMER_NUMOF, -1);
#if ENABLE_DEBUG
uint32_t count_lo = timer_get_counter_lo(dev);
DEBUG("%s %u\n", __func__, count_lo);
return count_lo;
#else
return timer_get_counter_lo(dev);
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint32_t count_lo = timer_get_counter_lo(dev);
DEBUG("%s %u\n", __func__, count_lo);
return count_lo;
}
else {
return timer_get_counter_lo(dev);
}
}
void IRAM timer_start(tim_t dev)

View File

@ -167,30 +167,30 @@ NORETURN void IRAM call_start_cpu0 (void)
rtc_clk_apb_freq_get(), rtc_clk_xtal_freq_get()*MHZ,
rtc_clk_slow_freq_get_hz());
#if ENABLE_DEBUG
ets_printf("reset reason: %d\n", reset_reason);
ets_printf("_stack %p\n", sp);
ets_printf("_bss_start %p\n", &_bss_start);
ets_printf("_bss_end %p\n", &_bss_end);
#ifndef MODULE_ESP_IDF_HEAP
ets_printf("_heap_start %p\n", &_sheap);
ets_printf("_heap_end %p\n", &_eheap);
ets_printf("_heap_free %u\n", get_free_heap_size());
#endif /* MODULE_ESP_IDF_HEAP */
#endif /* ENABLE_DEBUG */
if (IS_ACTIVE(ENABLE_DEBUG)) {
ets_printf("reset reason: %d\n", reset_reason);
ets_printf("_stack %p\n", sp);
ets_printf("_bss_start %p\n", &_bss_start);
ets_printf("_bss_end %p\n", &_bss_end);
if (!IS_ACTIVE(MODULE_ESP_IDF_HEAP)) {
ets_printf("_heap_start %p\n", &_sheap);
ets_printf("_heap_end %p\n", &_eheap);
ets_printf("_heap_free %u\n", get_free_heap_size());
}
}
LOG_STARTUP("PRO cpu is up (single core mode, only PRO cpu is used)\n");
/* disable APP cpu */
DPORT_CLEAR_PERI_REG_MASK(DPORT_APPCPU_CTRL_B_REG, DPORT_APPCPU_CLKGATE_EN);
#ifdef MODULE_ESP_IDF_HEAP
/* init heap */
heap_caps_init();
#if ENABLE_DEBUG
ets_printf("Heap free: %u byte\n", get_free_heap_size());
#endif /* ENABLE_DEBUG */
#endif /* MODULE_ESP_IDF_HEAP */
if (IS_ACTIVE(MODULE_ESP_IDF_HEAP)) {
/* init heap */
heap_caps_init();
if (IS_ACTIVE(ENABLE_DEBUG)) {
ets_printf("Heap free: %u byte\n", get_free_heap_size());
}
}
/* init SPI RAM if enabled */
#if CONFIG_SPIRAM_SUPPORT && CONFIG_SPIRAM_BOOT_INIT

View File

@ -24,7 +24,7 @@
#include "esp_heap_trace.h"
#include "priv/esp_heap_caps_priv.h"
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#endif

View File

@ -154,12 +154,12 @@ static void IRAM_ATTR esp_now_scan_peers_done(void)
critical_exit_var(state);
}
#if ENABLE_DEBUG
esp_now_peer_num_t peer_num;
esp_now_get_peer_num(&peer_num);
DEBUG("associated peers total=%d, encrypted=%d\n",
peer_num.total_num, peer_num.encrypt_num);
#endif /* ENABLE_DEBUG */
if (IS_ACTIVE(ENABLE_DEBUG)) {
esp_now_peer_num_t peer_num;
esp_now_get_peer_num(&peer_num);
DEBUG("associated peers total=%d, encrypted=%d\n",
peer_num.total_num, peer_num.encrypt_num);
}
_esp_now_scan_peers_done = true;

View File

@ -594,12 +594,13 @@ static int _esp_wifi_send(netdev_t *netdev, const iolist_t *iolist)
}
}
#if ENABLE_DEBUG
ESP_WIFI_DEBUG("send %d byte", dev->tx_len);
#if MODULE_OD && ENABLE_DEBUG_HEXDUMP
od_hex_dump(dev->tx_buf, dev->tx_len, OD_WIDTH_DEFAULT);
#endif /* MODULE_OD && ENABLE_DEBUG_HEXDUMP */
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
ESP_WIFI_DEBUG("send %d byte", dev->tx_len);
if (IS_ACTIVE(ENABLE_DEBUG_HEXDUMP) && IS_USED(MODULE_OD)) {
od_hex_dump(dev->tx_buf, dev->tx_len, OD_WIDTH_DEFAULT);
}
}
critical_exit();
#ifdef MODULE_ESP_WIFI_AP
@ -665,15 +666,15 @@ static int _esp_wifi_recv(netdev_t *netdev, void *buf, size_t len, void *info)
ringbuffer_remove(&dev->rx_buf, sizeof(uint16_t));
ringbuffer_get(&dev->rx_buf, buf, size);
#if ENABLE_DEBUG
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
if (IS_ACTIVE(ENABLE_DEBUG)) {
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
ESP_WIFI_DEBUG("received %u byte from addr " MAC_STR,
size, MAC_STR_ARG(hdr->src));
ESP_WIFI_DEBUG("received %u byte from addr " MAC_STR,
size, MAC_STR_ARG(hdr->src));
#if MODULE_OD && ENABLE_DEBUG_HEXDUMP
od_hex_dump(buf, size, OD_WIDTH_DEFAULT);
#endif /* MODULE_OD && ENABLE_DEBUG_HEXDUMP */
#endif /* ENABLE_DEBUG */
if (IS_ACTIVE(ENABLE_DEBUG_HEXDUMP) && IS_USED(MODULE_OD)) {
od_hex_dump(buf, size, OD_WIDTH_DEFAULT);
}
}
critical_exit();
return size;

View File

@ -488,15 +488,15 @@ void IRAM_ATTR spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
return;
}
#if ENABLE_DEBUG
if (out) {
DEBUG("out = ");
for (size_t i = 0; i < len; i++) {
DEBUG("%02x ", ((const uint8_t *)out)[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (out) {
DEBUG("out = ");
for (size_t i = 0; i < len; i++) {
DEBUG("%02x ", ((const uint8_t *)out)[i]);
}
DEBUG("\n");
}
DEBUG("\n");
}
#endif
if (cs != SPI_CS_UNDEF) {
gpio_clear(cs);
@ -524,13 +524,13 @@ void IRAM_ATTR spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
gpio_set (cs);
}
#if ENABLE_DEBUG
if (in) {
DEBUG("in = ");
for (size_t i = 0; i < len; i++) {
DEBUG("%02x ", ((const uint8_t *)in)[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (in) {
DEBUG("in = ");
for (size_t i = 0; i < len; i++) {
DEBUG("%02x ", ((const uint8_t *)in)[i]);
}
DEBUG("\n");
}
DEBUG("\n");
}
#endif
}

View File

@ -48,7 +48,7 @@ static inline void eeprom_native_write(void)
DEBUG("Writing data to EEPROM file %s:\n", eeprom_file);
fwrite(_eeprom_buf, 1, ARRAY_SIZE(_eeprom_buf), fp);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
for (size_t i = 0; i < ARRAY_SIZE(_eeprom_buf); i++) {
DEBUG("0x%02X ", _eeprom_buf[i]);
if ((i + 1) % 16 == 0) {
@ -69,7 +69,7 @@ void eeprom_native_read(void)
DEBUG("Reading data from EEPROM file %s:\n", eeprom_file);
fread(_eeprom_buf, 1, ARRAY_SIZE(_eeprom_buf), fp);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
for (size_t i = 0; i < ARRAY_SIZE(_eeprom_buf); i++) {
DEBUG("0x%02X ", _eeprom_buf[i]);
if ((i + 1) % 16 == 0) {

View File

@ -164,7 +164,7 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
{
DEBUG("writing to serial port ");
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
for (size_t i = 0; i < len; i++) {
DEBUG("%02x ", (unsigned char) data[i]);
}

View File

@ -183,14 +183,14 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
(unsigned)len, (void *)info);
if ((buf == NULL) || (len == 0)) {
int res = real_ioctl(dev->sock_fd, FIONREAD, &size);
#if ENABLE_DEBUG
if (res < 0) {
DEBUG("socket_zep::recv: error reading FIONREAD: %s",
strerror(errno));
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (res < 0) {
DEBUG("socket_zep::recv: error reading FIONREAD: %s",
strerror(errno));
}
}
#else
(void)res;
#endif
return size;
}
else if (len > 0) {

View File

@ -44,9 +44,6 @@
#include "native_internal.h"
#define ENABLE_DEBUG 0
#if ENABLE_DEBUG
#define LOCAL_DEBUG (1)
#endif
#include "debug.h"
ssize_t (*real_read)(int fd, void *buf, size_t count);
@ -109,16 +106,18 @@ int (*real_clock_gettime)(clockid_t clk_id, struct timespec *tp);
void _native_syscall_enter(void)
{
_native_in_syscall++;
#if LOCAL_DEBUG
real_write(STDERR_FILENO, "> _native_in_syscall\n", 21);
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
real_write(STDERR_FILENO, "> _native_in_syscall\n", 21);
}
}
void _native_syscall_leave(void)
{
#if LOCAL_DEBUG
real_write(STDERR_FILENO, "< _native_in_syscall\n", 21);
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
real_write(STDERR_FILENO, "< _native_in_syscall\n", 21);
}
_native_in_syscall--;
if (
(_native_sigpend > 0)

View File

@ -0,0 +1,16 @@
// ENABLE_DEBUG must not use parenthesis to be compatible with IS_ACTIVE
@@
constant C;
@@
- #define ENABLE_DEBUG (C)
+ #define ENABLE_DEBUG C
// make sure that ENABLE_DEBUG is zero
@@
@@
- #define ENABLE_DEBUG 1
+ #define ENABLE_DEBUG 0

View File

@ -1,5 +0,0 @@
@@
@@
- #define ENABLE_DEBUG (1)
+ #define ENABLE_DEBUG (0)

View File

@ -144,17 +144,17 @@ int adt7310_init(adt7310_t *dev, spi_t spi, spi_clk_t clk, gpio_t cs)
/* CS */
spi_init_cs(dev->spi, dev->cs);
#if ENABLE_DEBUG
for (int i = 0; i < 8; ++i) {
uint16_t dbg_reg = 0;
status = adt7310_read_reg(dev, i, sizeof(dbg_reg), (uint8_t *)&dbg_reg);
if (status != 0) {
printf("Error reading address 0x%02x", i);
if (IS_ACTIVE(ENABLE_DEBUG)) {
for (int i = 0; i < 8; ++i) {
uint16_t dbg_reg = 0;
status = adt7310_read_reg(dev, i, sizeof(dbg_reg), (uint8_t *)&dbg_reg);
if (status != 0) {
printf("Error reading address 0x%02x", i);
}
dbg_reg = htons(dbg_reg);
printf("%02x: %04" PRIx16 "\n", i, dbg_reg);
}
dbg_reg = htons(dbg_reg);
printf("%02x: %04" PRIx16 "\n", i, dbg_reg);
}
#endif
/* Read ID register from device */
status = adt7310_read_reg(dev, ADT7310_REG_ID, ADT7310_REG_SIZE_ID, &reg);

View File

@ -28,18 +28,10 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
#define DEBUG_DEV(f, d, ...) \
DEBUG("[apds99xx] %s i2c dev=%d addr=%02x: " f "\n", \
__func__, d->params.dev, APDS99XX_I2C_ADDRESS, ## __VA_ARGS__);
#else /* ENABLE_DEBUG */
#define DEBUG_DEV(f, d, ...)
#endif /* ENABLE_DEBUG */
#define ERROR_DEV(f, d, ...) \
LOG_ERROR("[apds99xx] %s i2c dev=%d addr=%02x: " f "\n", \
__func__, d->params.dev, APDS99XX_I2C_ADDRESS, ## __VA_ARGS__);
@ -488,7 +480,7 @@ static int _reg_read(const apds99xx_t *dev, uint8_t reg, uint8_t *data, uint16_t
return -APDS99XX_ERROR_I2C;
}
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[apds99xx] %s i2c dev=%d addr=%02x: read from reg 0x%02x: ",
__func__, dev->params.dev, APDS99XX_I2C_ADDRESS, reg);
for (uint16_t i = 0; i < len; i++) {
@ -504,7 +496,7 @@ static int _reg_write(const apds99xx_t *dev, uint8_t reg, uint8_t *data, uint16_
{
assert(dev != NULL);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[apds99xx] %s i2c dev=%d addr=%02x: write to reg 0x%02x: ",
__func__, dev->params.dev, APDS99XX_I2C_ADDRESS, reg);
for (uint16_t i = 0; i < len; i++) {

View File

@ -205,7 +205,7 @@ static void _status(const ata8520e_t *dev)
uint8_t sigfox2 = spi_transfer_byte(SPIDEV, CSPIN, false, 0);
spi_release(SPIDEV);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
_print_atmel_status(atmel);
_print_sigfox_status(sigfox);
_print_sigfox_status(sigfox2);
@ -272,7 +272,7 @@ int ata8520e_init(ata8520e_t *dev, const ata8520e_params_t *params)
xtimer_usleep(100 * US_PER_MS); /* 100 ms */
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
char sigfox_id[SIGFOX_ID_LENGTH + 1];
ata8520e_read_id(dev, sigfox_id);

View File

@ -103,9 +103,10 @@ static void _atwinc15x0_eth_cb(uint8_t type, void *msg, void *ctrl_buf)
DEBUG("%s type=%u msg=%p len=%d remaining=%d\n", __func__,
type, msg, ctrl->u16DataSize, ctrl->u16RemainigDataSize);
#if MODULE_OD && ENABLE_DEBUG_DUMP
od_hex_dump(msg, ctrl->u16DataSize, 16);
#endif
if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_OD)) {
od_hex_dump(msg, ctrl->u16DataSize, 16);
}
/* the buffer shouldn't be used here */
assert(atwinc15x0->rx_buf == NULL);
@ -258,12 +259,13 @@ static int _atwinc15x0_send(netdev_t *netdev, const iolist_t *iolist)
}
}
#if ENABLE_DEBUG
DEBUG("%s send %d byte", __func__, tx_len);
#if MODULE_OD && ENABLE_DEBUG_DUMP
od_hex_dump(dev->tx_buf, dev->tx_len, OD_WIDTH_DEFAULT);
#endif /* MODULE_OD && ENABLE_DEBUG_HEXDUMP */
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("%s send %d byte", __func__, tx_len);
if (IS_ACTIVE(ENABLE_DEBUG_DUMP) && IS_USED(MODULE_OD)) {
od_hex_dump(atwinc15x0_eth_buf, tx_len, OD_WIDTH_DEFAULT);
}
}
irq_restore(state);
/* send the the packet */
@ -320,14 +322,15 @@ static int _atwinc15x0_recv(netdev_t *netdev, void *buf, size_t len, void *info)
dev->rx_len = 0;
dev->rx_buf = NULL;
#if ENABLE_DEBUG
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
DEBUG("%s received %u byte from addr " ATWINC15X0_MAC_STR "\n",
__func__, rx_size, ATWINC15X0_MAC_STR_ARG(hdr->src));
#if MODULE_OD && ENABLE_DEBUG_DUMP
od_hex_dump(buf, rx_size, OD_WIDTH_DEFAULT);
#endif /* MODULE_OD && ENABLE_DEBUG_HEXDUMP */
#endif /* ENABLE_DEBUG */
if (IS_ACTIVE(ENABLE_DEBUG)) {
ethernet_hdr_t *hdr = (ethernet_hdr_t *)buf;
DEBUG("%s received %u byte from addr " ATWINC15X0_MAC_STR "\n",
__func__, rx_size, ATWINC15X0_MAC_STR_ARG(hdr->src));
if (IS_ACTIVE(ENABLE_DEBUG_DUMP) && IS_USED(MODULE_OD)) {
od_hex_dump(buf, rx_size, OD_WIDTH_DEFAULT);
}
}
irq_restore(state);

View File

@ -512,7 +512,7 @@ static int _reg_read(const ccs811_t *dev, uint8_t reg, uint8_t *data, uint32_t l
#endif
if (res == CCS811_OK) {
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[ccs811] %s dev=%d addr=%02x: read following bytes: ",
__func__, dev->params.i2c_dev, dev->params.i2c_addr);
for (unsigned i = 0; i < len; i++) {
@ -537,7 +537,7 @@ static int _reg_write(const ccs811_t *dev, uint8_t reg, uint8_t *data, uint32_t
int res = CCS811_OK;
if (ENABLE_DEBUG && data && len) {
if (IS_ACTIVE(ENABLE_DEBUG) && data && len) {
printf("[css811] %s dev=%d addr=%02x: write following bytes: ",
__func__, dev->params.i2c_dev, dev->params.i2c_addr);
for (unsigned i = 0; i < len; i++) {

View File

@ -79,7 +79,7 @@ int ds3234_pps_init(const ds3234_params_t *dev)
}
DEBUG("ds3234: init on SPI_DEV(%u)\n", dev->spi);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
for (int k = 0; k <= 0x19; ++k) {
uint8_t dbg_reg = 0;
ds3234_read_reg(dev, k, 1, &dbg_reg);

View File

@ -27,18 +27,10 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
#define DEBUG_DEV(f, d, ...) \
DEBUG("[hmc5883l] %s i2c dev=%d addr=%02x: " f "\n", \
__func__, d->dev, HMC5883L_I2C_ADDRESS, ## __VA_ARGS__);
#else /* ENABLE_DEBUG */
#define DEBUG_DEV(f, d, ...)
#endif /* ENABLE_DEBUG */
#define ERROR_DEV(f, d, ...) \
LOG_ERROR("[hmc5883l] %s i2c dev=%d addr=%02x: " f "\n", \
__func__, d->dev, HMC5883L_I2C_ADDRESS, ## __VA_ARGS__);
@ -251,7 +243,7 @@ static int _reg_read(const hmc5883l_t *dev, uint8_t reg, uint8_t *data, uint16_t
i2c_release(dev->dev);
if (res == 0) {
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[hmc5883l] %s i2c dev=%d addr=%02x: read following bytes: ",
__func__, dev->dev, HMC5883L_I2C_ADDRESS);
for (unsigned i = 0; i < len; i++) {
@ -276,7 +268,7 @@ static int _reg_write(const hmc5883l_t *dev, uint8_t reg, uint8_t data)
DEBUG_DEV("write register 0x%02x", dev, reg);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[hmc5883l] %s i2c dev=%d addr=%02x: write following bytes: ",
__func__, dev->dev, HMC5883L_I2C_ADDRESS);
printf("%02x ", data);

View File

@ -798,7 +798,7 @@ static void _isr(netdev_t *netdev)
}
kw2xrf_write_dreg(dev, MKW2XDM_IRQSTS2, irqsts2);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
/* for debugging only */
kw2xrf_read_dregs(dev, MKW2XDM_IRQSTS1, dregs, MKW2XDM_IRQSTS1 + 3);
if (dregs[MKW2XDM_IRQSTS1] & 0x7f) {

View File

@ -82,7 +82,7 @@ int lsm303dlhc_init(lsm303dlhc_t *dev, const lsm303dlhc_params_t *params)
i2c_release(DEV_I2C);
/* configure mag data ready pin */
gpio_init(DEV_MAG_PIN, GPIO_IN);
if (ENABLE_DEBUG && res == 0) {
if (IS_ACTIVE(ENABLE_DEBUG) && res == 0) {
DEBUG("[OK]\n");
}
else {

View File

@ -40,7 +40,7 @@ static int mtd_mci_init(mtd_dev_t *dev)
return -EIO;
}
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint32_t block_size;
mci_ioctl(GET_BLOCK_SIZE, &block_size);
DEBUG("block size: %lu\n", block_size);

View File

@ -26,12 +26,8 @@
#include <errno.h>
#include "mtd.h"
#if MODULE_XTIMER
#include "xtimer.h"
#include "timex.h"
#else
#include "thread.h"
#endif
#include "byteorder.h"
#include "mtd_spi_nor.h"
@ -113,7 +109,7 @@ static void mtd_spi_cmd_addr_read(const mtd_spi_nor_t *dev, uint8_t opcode,
uint8_t *addr_buf = _be_addr(dev, &addr);
if (ENABLE_TRACE) {
if (IS_ACTIVE(ENABLE_TRACE)) {
TRACE("mtd_spi_cmd_addr_read: addr:");
for (unsigned int i = 0; i < dev->params->addr_width; ++i) {
TRACE(" %02x", addr_buf[i]);
@ -149,7 +145,7 @@ static void mtd_spi_cmd_addr_write(const mtd_spi_nor_t *dev, uint8_t opcode,
uint8_t *addr_buf = _be_addr(dev, &addr);
if (ENABLE_TRACE) {
if (IS_ACTIVE(ENABLE_TRACE)) {
TRACE("mtd_spi_cmd_addr_write: addr:");
for (unsigned int i = 0; i < dev->params->addr_width; ++i) {
TRACE(" %02x", addr_buf[i]);
@ -316,9 +312,10 @@ static inline void wait_for_write_complete(const mtd_spi_nor_t *dev, uint32_t us
{
unsigned i = 0, j = 0;
uint32_t div = 2;
#if ENABLE_DEBUG && defined(MODULE_XTIMER)
uint32_t diff = xtimer_now_usec();
#endif
uint32_t diff = 0;
if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_XTIMER)) {
diff = xtimer_now_usec();
}
do {
uint8_t status;
mtd_spi_cmd_read(dev, dev->params->opcode->rdsr, &status, sizeof(status));
@ -352,10 +349,10 @@ static inline void wait_for_write_complete(const mtd_spi_nor_t *dev, uint32_t us
#endif
} while (1);
DEBUG("wait loop %u times, yield %u times", i, j);
#if ENABLE_DEBUG && defined(MODULE_XTIMER)
diff = xtimer_now_usec() - diff;
DEBUG(", total wait %"PRIu32"us", diff);
#endif
if (IS_ACTIVE(ENABLE_DEBUG) && IS_ACTIVE(MODULE_XTIMER)) {
diff = xtimer_now_usec() - diff;
DEBUG(", total wait %"PRIu32"us", diff);
}
DEBUG("\n");
}

View File

@ -78,7 +78,7 @@
/* Length for passive listings */
#define LIST_PASSIVE_LEN_14443(num) (num * 20)
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
#define PRINTBUFF printbuff
static void printbuff(uint8_t *buff, unsigned len)
{

View File

@ -100,7 +100,7 @@ void rn2xx3_set_internal_state(rn2xx3_t *dev, uint8_t state)
return;
}
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[rn2xx3] new state: ");
switch(state) {
case RN2XX3_INT_STATE_CMD:

View File

@ -322,13 +322,14 @@ static int _read_data(sht3x_dev_t* dev, uint8_t *data, uint8_t len)
i2c_release(dev->i2c_dev);
if (res == 0) {
#if ENABLE_DEBUG
printf("[sht3x] %s bus=%d addr=%02x: read following bytes: ",
__func__, dev->i2c_dev, dev->i2c_addr);
for (int i=0; i < len; i++)
printf("%02x ", data[i]);
printf("\n");
#endif /* ENABLE_DEBUG */
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[sht3x] %s bus=%d addr=%02x: read following bytes: ",
__func__, dev->i2c_dev, dev->i2c_addr);
for (int i=0; i < len; i++) {
printf("%02x ", data[i]);
}
printf("\n");
}
}
else {
DEBUG_DEV("could not read %d bytes from sensor, reason %d",

View File

@ -44,22 +44,22 @@ uint8_t sx127x_get_state(const sx127x_t *dev)
void sx127x_set_state(sx127x_t *dev, uint8_t state)
{
#if ENABLE_DEBUG
switch (state) {
case SX127X_RF_IDLE:
DEBUG("[sx127x] Change state: IDLE\n");
break;
case SX127X_RF_RX_RUNNING:
DEBUG("[sx127x] Change state: RX\n");
break;
case SX127X_RF_TX_RUNNING:
DEBUG("[sx127x] Change state: TX\n");
break;
default:
DEBUG("[sx127x] Change state: UNKNOWN\n");
break;
if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (state) {
case SX127X_RF_IDLE:
DEBUG("[sx127x] Change state: IDLE\n");
break;
case SX127X_RF_RX_RUNNING:
DEBUG("[sx127x] Change state: RX\n");
break;
case SX127X_RF_TX_RUNNING:
DEBUG("[sx127x] Change state: TX\n");
break;
default:
DEBUG("[sx127x] Change state: UNKNOWN\n");
break;
}
}
#endif
dev->settings.state = state;
}
@ -440,28 +440,28 @@ uint8_t sx127x_get_op_mode(const sx127x_t *dev)
void sx127x_set_op_mode(const sx127x_t *dev, uint8_t op_mode)
{
#if ENABLE_DEBUG
switch(op_mode) {
case SX127X_RF_OPMODE_SLEEP:
DEBUG("[sx127x] Set op mode: SLEEP\n");
break;
case SX127X_RF_OPMODE_STANDBY:
DEBUG("[sx127x] Set op mode: STANDBY\n");
break;
case SX127X_RF_OPMODE_RECEIVER_SINGLE:
DEBUG("[sx127x] Set op mode: RECEIVER SINGLE\n");
break;
case SX127X_RF_OPMODE_RECEIVER:
DEBUG("[sx127x] Set op mode: RECEIVER\n");
break;
case SX127X_RF_OPMODE_TRANSMITTER:
DEBUG("[sx127x] Set op mode: TRANSMITTER\n");
break;
default:
DEBUG("[sx127x] Set op mode: UNKNOWN (%d)\n", op_mode);
break;
if (IS_ACTIVE(ENABLE_DEBUG)) {
switch(op_mode) {
case SX127X_RF_OPMODE_SLEEP:
DEBUG("[sx127x] Set op mode: SLEEP\n");
break;
case SX127X_RF_OPMODE_STANDBY:
DEBUG("[sx127x] Set op mode: STANDBY\n");
break;
case SX127X_RF_OPMODE_RECEIVER_SINGLE:
DEBUG("[sx127x] Set op mode: RECEIVER SINGLE\n");
break;
case SX127X_RF_OPMODE_RECEIVER:
DEBUG("[sx127x] Set op mode: RECEIVER\n");
break;
case SX127X_RF_OPMODE_TRANSMITTER:
DEBUG("[sx127x] Set op mode: TRANSMITTER\n");
break;
default:
DEBUG("[sx127x] Set op mode: UNKNOWN (%d)\n", op_mode);
break;
}
}
#endif
/* Replace previous mode value and setup new mode value */
sx127x_reg_write(dev, SX127X_REG_OPMODE,

View File

@ -75,13 +75,14 @@ int tsl2561_init(tsl2561_t *dev, const tsl2561_params_t *params)
TSL2561_COMMAND_MODE | TSL2561_REGISTER_TIMING,
DEV_INTEGRATION | DEV_GAIN, 0);
#if ENABLE_DEBUG
uint8_t timing;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_TIMING, &timing, 0);
DEBUG("[Info] Timing ? %d (expected: %d)\n",
timing, DEV_INTEGRATION | DEV_GAIN);
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint8_t timing;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_TIMING,
&timing, 0);
DEBUG("[Info] Timing ? %d (expected: %d)\n",
timing, DEV_INTEGRATION | DEV_GAIN);
}
_disable(dev);
i2c_release(DEV_I2C);
@ -187,12 +188,13 @@ static void _enable(const tsl2561_t *dev)
i2c_write_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL,
TSL2561_CONTROL_POWERON, 0);
#if ENABLE_DEBUG
uint8_t en;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL, &en, 0);
DEBUG("[Info] Enabled ? %s\n", en == 3 ? "true" : "false");
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint8_t en;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL, &en, 0);
DEBUG("[Info] Enabled ? %s\n", en == 3 ? "true" : "false");
}
}
@ -203,12 +205,12 @@ static void _disable(const tsl2561_t *dev)
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL,
TSL2561_CONTROL_POWEROFF, 0);
#if ENABLE_DEBUG
uint8_t dis;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL, &dis, 0);
DEBUG("[Info] Disabled ? %s\n", dis == 0 ? "true": "false");
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
uint8_t dis;
i2c_read_reg(DEV_I2C, DEV_ADDR,
TSL2561_COMMAND_MODE | TSL2561_REGISTER_CONTROL, &dis, 0);
DEBUG("[Info] Disabled ? %s\n", dis == 0 ? "true": "false");
}
}
static void _read_data(const tsl2561_t *dev, uint16_t *full, uint16_t *ir)

View File

@ -131,7 +131,7 @@ static int dtls_handle_read(dtls_context_t *ctx)
memcpy(&session.addr, &remote.addr.ipv6, sizeof(session.addr));
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("DBG-Client: Msg received from \n\t Addr Src: [");
ipv6_addr_print(&session.addr);
DEBUG("]:%u\n", remote.port);

View File

@ -164,20 +164,16 @@ static void _on_scan_evt(uint8_t type, const ble_addr_t *addr, int8_t rssi,
static void _evt_dbg(const char *msg, int handle, const uint8_t *addr)
{
#if ENABLE_DEBUG
printf("[autoconn] %s (%i|", msg, handle);
if (addr) {
bluetil_addr_print(addr);
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("[autoconn] %s (%i|", msg, handle);
if (addr) {
bluetil_addr_print(addr);
}
else {
printf("n/a");
}
puts(")");
}
else {
printf("n/a");
}
puts(")");
#else
(void)msg;
(void)handle;
(void)addr;
#endif
}
static void _on_netif_evt(int handle, nimble_netif_event_t event,

View File

@ -110,17 +110,13 @@ uint8_t ot_call_command(char* command, void *arg, void* answer)
void output_bytes(const char* name, const uint8_t *aBytes, uint8_t aLength)
{
#if ENABLE_DEBUG
DEBUG("%s: ", name);
for (int i = 0; i < aLength; i++) {
DEBUG("%02x", aBytes[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("%s: ", name);
for (int i = 0; i < aLength; i++) {
DEBUG("%02x", aBytes[i]);
}
DEBUG("\n");
}
DEBUG("\n");
#else
(void)name;
(void)aBytes;
(void)aLength;
#endif
}
OT_COMMAND ot_channel(otInstance* ot_instance, void* arg, void* answer) {

View File

@ -159,7 +159,7 @@ void recv_pkt(otInstance *aInstance, netdev_t *dev)
/* Get RSSI from a radio driver. RSSI should be in [dBm] */
Rssi = (int8_t)rx_info.rssi;
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("Received message: len %d\n", (int) sReceiveFrame.mLength);
for (int i = 0; i < sReceiveFrame.mLength; ++i) {
DEBUG("%x ", sReceiveFrame.mPsdu[i]);
@ -216,7 +216,7 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aE
for (unsigned i = 0; i < IEEE802154_LONG_ADDRESS_LEN; i++) {
reversed_addr[i] = (uint8_t) ((uint8_t *)aExtAddress)[IEEE802154_LONG_ADDRESS_LEN - 1 - i];
}
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
for (unsigned i = 0; i < IEEE802154_LONG_ADDRESS_LEN; ++i) {
DEBUG("%x ", (uint8_t) ((uint8_t *)reversed_addr)[i]);
}
@ -344,7 +344,7 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aPacket)
};
/*Set channel and power based on transmit frame */
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("otPlatRadioTransmit->channel: %i, length %d\n",
(int) aPacket->mChannel, (int)aPacket->mLength);
for (size_t i = 0; i < aPacket->mLength; ++i) {

View File

@ -88,8 +88,7 @@ static int mqtt_read(struct Network *n, unsigned char *buf, int len,
}
} while (rc < len && xtimer_now64().ticks64 < send_tick && rc >= 0);
#ifdef ENABLE_DEBUG
if (IS_USED(MODULE_LWIP) && rc > 0) {
if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_LWIP) && rc > 0) {
DEBUG("MQTT buf asked for %d, available to read %d\n",
rc, tsrb_avail(&tsrb_lwip_tcp));
for (int i = 0; i < rc; i++) {
@ -97,7 +96,6 @@ static int mqtt_read(struct Network *n, unsigned char *buf, int len,
}
DEBUG("\n");
}
#endif
return rc;
}

View File

@ -712,7 +712,7 @@ void *_semtech_loramac_event_loop(void *arg)
/* save the uplink counter */
_save_uplink_counter(mac);
#endif
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (confirm->McpsRequest) {
case MCPS_UNCONFIRMED:
{
@ -755,7 +755,7 @@ void *_semtech_loramac_event_loop(void *arg)
break;
}
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (indication->McpsIndication) {
case MCPS_UNCONFIRMED:
DEBUG("[semtech-loramac] MCPS indication Unconfirmed\n");

View File

@ -117,19 +117,19 @@ static int _event(struct dtls_context_t *ctx, session_t *session,
sock_dtls_t *sock = dtls_get_app_data(ctx);
msg_t msg = { .type = code, .content.ptr = session };
#ifdef ENABLE_DEBUG
switch (code) {
case DTLS_EVENT_CONNECT:
DEBUG("sock_dtls: event connect\n");
break;
case DTLS_EVENT_CONNECTED:
DEBUG("sock_dtls: event connected\n");
break;
case DTLS_EVENT_RENEGOTIATE:
DEBUG("sock_dtls: event renegotiate\n");
break;
if (IS_ACTIVE(ENABLE_DEBUG)) {
switch (code) {
case DTLS_EVENT_CONNECT:
DEBUG("sock_dtls: event connect\n");
break;
case DTLS_EVENT_CONNECTED:
DEBUG("sock_dtls: event connected\n");
break;
case DTLS_EVENT_RENEGOTIATE:
DEBUG("sock_dtls: event renegotiate\n");
break;
}
}
#endif /* ENABLE_DEBUG */
if (!level && (code != DTLS_EVENT_CONNECT)) {
mbox_put(&sock->mbox, &msg);
}

View File

@ -312,13 +312,13 @@ static int _isotp_rcv_ff(struct isotp *isotp, struct can_frame *frame, int ae)
((uint8_t *)isotp->rx.snip->data)[isotp->rx.idx++] = frame->data[i];
}
#if ENABLE_DEBUG
DEBUG("_isotp_rcv_ff: rx.buf=");
for (unsigned i = 0; i < isotp->rx.idx; i++) {
DEBUG("%02hhx", ((uint8_t *)isotp->rx.snip->data)[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("_isotp_rcv_ff: rx.buf=");
for (unsigned i = 0; i < isotp->rx.idx; i++) {
DEBUG("%02hhx", ((uint8_t *)isotp->rx.snip->data)[i]);
}
DEBUG("\n");
}
DEBUG("\n");
#endif
isotp->rx.sn = 1;
@ -360,13 +360,13 @@ static int _isotp_rcv_cf(struct isotp *isotp, struct can_frame *frame, int ae)
}
}
#if ENABLE_DEBUG
DEBUG("_isotp_rcv_cf: rx.buf=");
for (unsigned i = 0; i < isotp->rx.idx; i++) {
DEBUG("%02hhx", ((uint8_t *)isotp->rx.snip->data)[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("_isotp_rcv_cf: rx.buf=");
for (unsigned i = 0; i < isotp->rx.idx; i++) {
DEBUG("%02hhx", ((uint8_t *)isotp->rx.snip->data)[i]);
}
DEBUG("\n");
}
DEBUG("\n");
#endif
if (isotp->rx.idx >= isotp->rx.snip->size) {
isotp->rx.state = ISOTP_IDLE;
@ -392,13 +392,13 @@ static int _isotp_rcv(struct isotp *isotp, struct can_frame *frame)
int ae = (isotp->opt.flags & CAN_ISOTP_EXTEND_ADDR) ? 1 : 0;
uint8_t n_pci_type;
#if ENABLE_DEBUG
DEBUG("_isotp_rcv: id=%" PRIx32 " data=", frame->can_id);
for (int i = 0; i < frame->can_dlc; i++) {
DEBUG("%02hhx", frame->data[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("_isotp_rcv: id=%" PRIx32 " data=", frame->can_id);
for (int i = 0; i < frame->can_dlc; i++) {
DEBUG("%02hhx", frame->data[i]);
}
DEBUG("\n");
}
DEBUG("\n");
#endif
if (ae && frame->data[0] != isotp->opt.rx_ext_address) {
return 1;
@ -448,13 +448,13 @@ static int _isotp_send_fc(struct isotp *isotp, int ae, uint8_t status)
isotp->rx.bs = 0;
#if ENABLE_DEBUG
DEBUG("_isotp_send_fc: id=%" PRIx32 " data=", fc.can_id);
for (int i = 0; i < fc.can_dlc; i++) {
DEBUG("%02hhx", fc.data[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("_isotp_send_fc: id=%" PRIx32 " data=", fc.can_id);
for (int i = 0; i < fc.can_dlc; i++) {
DEBUG("%02hhx", fc.data[i]);
}
DEBUG("\n");
}
DEBUG("\n");
#endif
xtimer_set(&isotp->rx_timer, CAN_ISOTP_TIMEOUT_N_Ar);
isotp->rx.tx_handle = raw_can_send(isotp->entry.ifnum, &fc, isotp_pid);

View File

@ -19,6 +19,7 @@
#include <stdint.h>
#include <errno.h>
#include <inttypes.h>
#include "kernel_defines.h"
@ -30,18 +31,11 @@
#include "assert.h"
#include "memarray.h"
#ifdef MODULE_CAN_MBOX
#include "mbox.h"
#endif
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
/* For PRIu16 etc. */
#include <inttypes.h>
#endif
/**
* This is a can_id element
*/
@ -71,7 +65,7 @@ static void _insert_to_list(can_reg_entry_t **list, filter_el_t *el);
static filter_el_t *_find_filter_el(can_reg_entry_t *list, can_reg_entry_t *entry, canid_t can_id, canid_t mask, void *data);
static int _filter_is_used(unsigned int ifnum, canid_t can_id, canid_t mask);
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
static void _print_filters(void)
{
for (int i = 0; i < (int)CAN_DLL_NUMOF; i++) {
@ -84,7 +78,6 @@ static void _print_filters(void)
}
}
}
#define PRINT_FILTERS() _print_filters()
#else
#define PRINT_FILTERS()
@ -214,13 +207,15 @@ int can_router_register(can_reg_entry_t *entry, canid_t can_id, canid_t mask, vo
filter_el_t *filter;
int ret;
#if ENABLE_DEBUG
if (entry->type == CAN_TYPE_DEFAULT) {
DEBUG("can_router_register: ifnum=%d, pid=%" PRIkernel_pid ", can_id=0x%" PRIx32
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, entry->target.pid, can_id, mask, param);
} else if (entry->type == CAN_TYPE_MBOX) {
DEBUG("can_router_register: ifnum=%d, mbox=%p, can_id=0x%" PRIx32
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, (void *)entry->target.mbox, can_id, mask, param);
#ifdef MODULE_CAN_MBOX
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (entry->type == CAN_TYPE_DEFAULT) {
DEBUG("can_router_register: ifnum=%d, pid=%" PRIkernel_pid ", can_id=0x%" PRIx32
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, entry->target.pid, can_id, mask, param);
} else if (entry->type == CAN_TYPE_MBOX) {
DEBUG("can_router_register: ifnum=%d, mbox=%p, can_id=0x%" PRIx32
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, (void *)entry->target.mbox, can_id, mask, param);
}
}
#endif
@ -263,13 +258,15 @@ int can_router_unregister(can_reg_entry_t *entry, canid_t can_id,
filter_el_t *el;
int ret;
#if ENABLE_DEBUG
if (entry->type == CAN_TYPE_DEFAULT) {
DEBUG("can_router_unregister: ifnum=%d, pid=%" PRIkernel_pid ", can_id=0x%" PRIx32
", mask=0x%" PRIx32 ", data=%p", entry->ifnum, entry->target.pid, can_id, mask, param);
} else if (entry->type == CAN_TYPE_MBOX) {
DEBUG("can_router_unregister: ifnum=%d, mbox=%p, can_id=0x%" PRIx32
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, (void *)entry->target.mbox, can_id, mask, param);
#ifdef MODULE_CAN_MBOX
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (entry->type == CAN_TYPE_DEFAULT) {
DEBUG("can_router_unregister: ifnum=%d, pid=%" PRIkernel_pid ", can_id=0x%" PRIx32
", mask=0x%" PRIx32 ", data=%p", entry->ifnum, entry->target.pid, can_id, mask, param);
} else if (entry->type == CAN_TYPE_MBOX) {
DEBUG("can_router_unregister: ifnum=%d, mbox=%p, can_id=0x%" PRIx32
", mask=0x%" PRIx32 ", data=%p\n", entry->ifnum, (void *)entry->target.mbox, can_id, mask, param);
}
}
#endif
@ -317,9 +314,8 @@ int can_router_dispatch_rx_indic(can_pkt_t *pkt)
int res = 0;
msg_t msg;
msg.type = CAN_MSG_RX_INDICATION;
#if ENABLE_DEBUG
int msg_cnt = 0;
#endif
DEBUG("can_router_dispatch_rx_indic: pkt=%p, ifnum=%d, can_id=%" PRIx32 "\n",
(void *)pkt, pkt->entry.ifnum, pkt->frame.can_id);
@ -335,9 +331,11 @@ int can_router_dispatch_rx_indic(can_pkt_t *pkt)
PRIkernel_pid "\n", entry->target.pid);
atomic_fetch_add(&pkt->ref_count, 1);
msg.content.ptr = can_pkt_alloc_rx_data(&pkt->frame, sizeof(pkt->frame), el->data);
#if ENABLE_DEBUG
msg_cnt++;
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
msg_cnt++;
}
if (!msg.content.ptr || (_send_msg(&msg, entry) <= 0)) {
can_pkt_free_rx_data(msg.content.ptr);
atomic_fetch_sub(&pkt->ref_count, 1);
@ -349,9 +347,9 @@ int can_router_dispatch_rx_indic(can_pkt_t *pkt)
}
}
mutex_unlock(&lock);
#if ENABLE_DEBUG
DEBUG("can_router_dispatch_rx: msg send to %d threads\n", msg_cnt);
#endif
if (atomic_load(&pkt->ref_count) == 0) {
can_pkt_free(pkt);
}

View File

@ -45,15 +45,9 @@
#include "bitarithm.h"
#include "ecc/golay2412.h"
#define ENABLE_DEBUG 0
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
#define DEBUG_FEC_GOLAY2412 (1)
#else
#define DEBUG_FEC_GOLAY2412 (0)
#endif
/* generator matrix transposed [24 x 12] */
static const uint32_t golay2412_Gt[24] = {
0x08ed, 0x01db, 0x03b5, 0x0769, 0x0ed1, 0x0da3, 0x0b47, 0x068f,
@ -75,7 +69,6 @@ static const uint32_t golay2412_H[12] = {
0x00008d1d, 0x00004a3b, 0x00002477, 0x00001ffe
};
#if DEBUG_FEC_GOLAY2412
/* print string of bits to standard output */
static inline void liquid_print_bitstring(uint32_t _x,
uint32_t _n)
@ -86,7 +79,6 @@ static inline void liquid_print_bitstring(uint32_t _x,
printf("%" PRIu32, (_x >> (_n - i - 1)) & 1);
}
}
#endif
#ifndef NDEBUG
static uint32_t block_get_enc_msg_len(uint32_t _dec_msg_len,
@ -107,16 +99,15 @@ static uint32_t block_get_enc_msg_len(uint32_t _dec_msg_len,
/* compute total number of bytes out: ceil(num_bits_out/8) */
uint32_t num_bytes_out = num_bits_out / 8 + ((num_bits_out % 8) ? 1 : 0);
#if DEBUG_FEC_GOLAY2412
printf("block_get_enc_msg_len(%" PRIu32 ",%" PRIu32 ",%" PRIu32 ")\n", _dec_msg_len, _m, _k);
printf(" dec msg len : %" PRIu32 " bytes\n", _dec_msg_len);
printf(" m : %" PRIu32 " bits\n", _m);
printf(" k : %" PRIu32 " bits\n", _k);
printf(" num bits in : %" PRIu32 " bits\n", num_bits_in);
printf(" num blocks : %" PRIu32 "\n", num_blocks);
printf(" num bits out: %" PRIu32 " bits\n", num_bits_out);
printf(" enc msg len : %" PRIu32 " bytes\n", num_bytes_out);
#endif
DEBUG("block_get_enc_msg_len(%" PRIu32 ",%" PRIu32 ",%" PRIu32 ")\n",
_dec_msg_len, _m, _k);
DEBUG(" dec msg len : %" PRIu32 " bytes\n", _dec_msg_len);
DEBUG(" m : %" PRIu32 " bits\n", _m);
DEBUG(" k : %" PRIu32 " bits\n", _k);
DEBUG(" num bits in : %" PRIu32 " bits\n", num_bits_in);
DEBUG(" num blocks : %" PRIu32 "\n", num_blocks);
DEBUG(" num bits out: %" PRIu32 " bits\n", num_bits_out);
DEBUG(" enc msg len : %" PRIu32 " bytes\n", num_bytes_out);
return num_bytes_out;
}
@ -187,84 +178,75 @@ static uint32_t golay2412_decode_symbol(uint32_t _sym_enc,
/* compute syndrome vector, s = r*H^T = ( H*r^T )^T */
s = golay2412_matrix_mul(_sym_enc, _B, 12);
#if DEBUG_FEC_GOLAY2412
printf("s (syndrome vector): "); liquid_print_bitstring(s, 12); printf("\n");
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("s (syndrome vector): ");
liquid_print_bitstring(s, 12);
printf("\n");
}
/* compute weight of s (12 bits) */
uint8_t ws = bitarithm_bits_set_u32(s & 0x00000fff);
#if DEBUG_FEC_GOLAY2412
printf("w(s) = %u\n", ws);
#endif
DEBUG("w(s) = %u\n", ws);
/* step 2: */
e_hat = 0;
if (ws <= 3) {
#if DEBUG_FEC_GOLAY2412
printf(" w(s) <= 3: estimating error vector as [s, 0(12)]\n");
#endif
DEBUG(" w(s) <= 3: estimating error vector as [s, 0(12)]\n");
/* set e_hat = [s 0(12)] */
e_hat = (s << 12) & 0xfff000;
}
else {
/* step 3: search for p[i] s.t. w(s+p[i]) <= 2 */
#if DEBUG_FEC_GOLAY2412
printf(" searching for w(s + p_i) <= 2...\n");
#endif
DEBUG(" searching for w(s + p_i) <= 2...\n");
int8_t s_index = golay2412_parity_search(s, _A);
if (s_index >= 0) {
/* vector found! */
#if DEBUG_FEC_GOLAY2412
printf(" w(s + p[%2i]) <= 2: estimating error vector as [s+p[%2i],"
"u[%2i]]\n", s_index, s_index, s_index);
#endif
DEBUG(" w(s + p[%2i]) <= 2: estimating error vector as "
"[s+p[%2i],u[%2i]]\n", s_index, s_index, s_index);
/* NOTE : uj = 1 << (12-j-1) */
e_hat = ((s ^ _A[s_index]) << 12) | (1 << (11 - s_index));
}
else {
/* step 4: compute s*P */
uint32_t sP = golay2412_matrix_mul(s, _A, 12);
#if DEBUG_FEC_GOLAY2412
printf("s*P: "); liquid_print_bitstring(sP, 12); printf("\n");
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("s*P: ");
liquid_print_bitstring(sP, 12);
printf("\n");
}
/* compute weight of sP (12 bits) */
uint8_t wsP = bitarithm_bits_set_u32(sP & 0x00000fff);
#if DEBUG_FEC_GOLAY2412
printf("w(s*P) = %u\n", wsP);
#endif
DEBUG("w(s*P) = %u\n", wsP);
if (wsP == 2 || wsP == 3) {
/* step 5: set e = [0, s*P] */
#if DEBUG_FEC_GOLAY2412
printf(" w(s*P) in [2,3]: estimating error vector as [0(12), s*P]\n");
#endif
DEBUG(" w(s*P) in [2,3]: estimating error vector as "
"[0(12), s*P]\n");
e_hat = sP;
}
else {
/* step 6: search for p[i] s.t. w(s*P + p[i]) == 2... */
DEBUG(" searching for w(s*P + p_i) == 2...\n");
#if DEBUG_FEC_GOLAY2412
printf(" searching for w(s*P + p_i) == 2...\n");
#endif
int8_t sP_index = golay2412_parity_search(sP, _A);
if (sP_index >= 0) {
/* vector found! */
#if DEBUG_FEC_GOLAY2412
printf(" w(s*P + p[%2i]) == 2: estimating error vector as [u[%2i],"
"s*P+p[%2i]]\n", sP_index, sP_index, sP_index);
#endif
DEBUG(" w(s*P + p[%2i]) == 2: estimating error vector "
"as [u[%2i],s*P+p[%2i]]\n",
sP_index, sP_index, sP_index);
/* NOTE : uj = 1 << (12-j-1)
* [ uj << 1 2 ] [ sP + p[j] ] */
e_hat = (1L << (23 - sP_index)) | (sP ^ _A[sP_index]);
}
else {
/* step 7: decoding error */
#if DEBUG_FEC_GOLAY2412
printf(" **** decoding error\n");
#endif
DEBUG(" **** decoding error\n");
}
}
}
@ -272,14 +254,15 @@ static uint32_t golay2412_decode_symbol(uint32_t _sym_enc,
/* step 8: compute estimated transmitted message: v_hat = r + e_hat */
v_hat = _sym_enc ^ e_hat;
#if DEBUG_FEC_GOLAY2412
printf("r (received vector): ");
liquid_print_bitstring(_sym_enc, 24); printf("\n");
printf("e-hat (estimated error vector): ");
liquid_print_bitstring(e_hat, 24); printf("\n");
printf("v-hat (estimated tx vector): ");
liquid_print_bitstring(v_hat, 24); printf("\n");
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
printf("r (received vector): ");
liquid_print_bitstring(_sym_enc, 24); printf("\n");
printf("e-hat (estimated error vector): ");
liquid_print_bitstring(e_hat, 24); printf("\n");
printf("v-hat (estimated tx vector): ");
liquid_print_bitstring(v_hat, 24); printf("\n");
}
/* compute estimated original message: (last 12 bits of encoded message) */
m_hat = v_hat & 0x0fff;

View File

@ -332,40 +332,43 @@ static inline dhcpv6_opt_t *_opt_next(dhcpv6_opt_t *opt)
static bool _check_status_opt(dhcpv6_opt_status_t *status)
{
/* DHCPV6_STATUS_SUCCESS is 0, so we don't need to fix byte order */
#if ENABLE_DEBUG
if ((status != NULL) && (status->code.u16 != DHCPV6_STATUS_SUCCESS)) {
size_t msg_len = byteorder_ntohs(status->len);
char msg[msg_len - 1];
if (IS_ACTIVE(ENABLE_DEBUG)) {
if ((status != NULL) && (status->code.u16 != DHCPV6_STATUS_SUCCESS)) {
size_t msg_len = byteorder_ntohs(status->len);
char msg[msg_len - 1];
strncpy(msg, status->msg, msg_len - 2);
DEBUG("DHCPv6 client: server returned error (%u) \"%s\"\n",
byteorder_ntohs(status->code), msg);
strncpy(msg, status->msg, msg_len - 2);
DEBUG("DHCPv6 client: server returned error (%u) \"%s\"\n",
byteorder_ntohs(status->code), msg);
}
}
#endif
/* DHCPV6_STATUS_SUCCESS is 0, so we don't need to fix byte order */
return (status == NULL) || (status->code.u16 == DHCPV6_STATUS_SUCCESS);
}
static bool _check_cid_opt(dhcpv6_opt_duid_t *cid)
{
#if ENABLE_DEBUG
if ((byteorder_ntohs(cid->len) != duid_len) ||
(memcmp(cid->duid, duid, duid_len) != 0)) {
DEBUG("DHCPv6 client: message is not for me\n");
if (IS_ACTIVE(ENABLE_DEBUG)) {
if ((byteorder_ntohs(cid->len) != duid_len) ||
(memcmp(cid->duid, duid, duid_len) != 0)) {
DEBUG("DHCPv6 client: message is not for me\n");
}
}
#endif
return ((byteorder_ntohs(cid->len) == duid_len) &&
(memcmp(cid->duid, duid, duid_len) == 0));
}
static bool _check_sid_opt(dhcpv6_opt_duid_t *sid)
{
#if ENABLE_DEBUG
if ((byteorder_ntohs(sid->len) != server.duid_len) ||
(memcmp(sid->duid, server.duid.u8, server.duid_len) != 0)) {
DEBUG("DHCPv6 client: message is not from my server\n");
if (IS_ACTIVE(ENABLE_DEBUG)) {
if ((byteorder_ntohs(sid->len) != server.duid_len) ||
(memcmp(sid->duid, server.duid.u8, server.duid_len) != 0)) {
DEBUG("DHCPv6 client: message is not from my server\n");
}
}
#endif
return ((byteorder_ntohs(sid->len) == server.duid_len) &&
(memcmp(sid->duid, server.duid.u8, server.duid_len) == 0));
}

View File

@ -25,14 +25,15 @@ uint16_t inet_csum_slice(uint16_t sum, const uint8_t *buf, uint16_t len, size_t
uint32_t csum = sum;
DEBUG("inet_sum: sum = 0x%04" PRIx16 ", len = %" PRIu16, sum, len);
#if ENABLE_DEBUG
#ifdef MODULE_OD
DEBUG(", buf:\n");
od_hex_dump(buf, len, OD_WIDTH_DEFAULT);
#else
DEBUG(", buf output only with od module\n");
#endif
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (IS_USED(MODULE_OD)) {
DEBUG(", buf:\n");
od_hex_dump(buf, len, OD_WIDTH_DEFAULT);
} else {
DEBUG(", buf output only with od module\n");
}
}
if (len == 0)
return csum;

View File

@ -25,6 +25,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "od.h"
#include "timex.h"
#include "random.h"
#include "periph/rtt.h"
@ -166,9 +167,6 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
if (!(state->flags & NETDEV_IEEE802154_RAW)) {
gnrc_pktsnip_t *ieee802154_hdr, *netif_hdr;
gnrc_netif_hdr_t *hdr;
#if ENABLE_DEBUG
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
#endif
size_t mhr_len = ieee802154_get_frame_hdr_len(pkt->data);
if (mhr_len == 0) {
@ -207,16 +205,19 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
hdr->rssi = rx_info.rssi;
gnrc_netif_hdr_set_netif(hdr, netif);
pkt->type = state->proto;
#if ENABLE_DEBUG
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
gnrc_netif_addr_to_str(src_str, sizeof(src_str),
gnrc_netif_hdr_get_src_addr(hdr),
hdr->src_l2addr_len),
nread);
#if defined(MODULE_OD)
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
#endif
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
gnrc_netif_addr_to_str(gnrc_netif_hdr_get_src_addr(hdr),
hdr->src_l2addr_len,
src_str),
nread);
if (IS_USED(MODULE_OD)) {
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
}
}
gnrc_pktbuf_remove_snip(pkt, ieee802154_hdr);
pkt = gnrc_pkt_append(pkt, netif_hdr);
}
@ -923,10 +924,8 @@ static void _lwmac_msg_handler(gnrc_netif_t *netif, msg_t *msg)
}
#endif
default: {
#if ENABLE_DEBUG
DEBUG("[LWMAC]: unknown message type 0x%04x"
DEBUG("[LWMAC]: unknown message type 0x%04x "
"(no message handler defined)\n", msg->type);
#endif
break;
}
}

View File

@ -24,9 +24,7 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if defined(MODULE_OD) && ENABLE_DEBUG
#include "od.h"
#endif
static int _send(gnrc_netif_t *netif, gnrc_pktsnip_t *pkt);
static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif);
@ -138,9 +136,6 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
/* Normal mode, try to parse the frame according to IEEE 802.15.4 */
gnrc_pktsnip_t *ieee802154_hdr, *netif_hdr;
gnrc_netif_hdr_t *hdr;
#if ENABLE_DEBUG
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
#endif
size_t mhr_len = ieee802154_get_frame_hdr_len(pkt->data);
/* nread was checked for <= 0 before so we can safely cast it to
@ -193,16 +188,18 @@ static gnrc_pktsnip_t *_recv(gnrc_netif_t *netif)
hdr->rssi = rx_info.rssi;
gnrc_netif_hdr_set_netif(hdr, netif);
dev->driver->get(dev, NETOPT_PROTO, &pkt->type, sizeof(pkt->type));
#if ENABLE_DEBUG
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
gnrc_netif_addr_to_str(gnrc_netif_hdr_get_src_addr(hdr),
hdr->src_l2addr_len,
src_str),
nread);
#if defined(MODULE_OD)
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
#endif
#endif
if (IS_ACTIVE(ENABLE_DEBUG)) {
char src_str[GNRC_NETIF_HDR_L2ADDR_PRINT_LEN];
DEBUG("_recv_ieee802154: received packet from %s of length %u\n",
gnrc_netif_addr_to_str(gnrc_netif_hdr_get_src_addr(hdr),
hdr->src_l2addr_len,
src_str),
nread);
if (IS_USED(MODULE_OD)) {
od_hex_dump(pkt->data, nread, OD_WIDTH_DEFAULT);
}
}
gnrc_pktbuf_remove_snip(pkt, ieee802154_hdr);
pkt = gnrc_pkt_append(pkt, netif_hdr);
}

View File

@ -12,6 +12,8 @@
* @file
*/
#include <inttypes.h>
#include "net/gnrc.h"
#include "od.h"
@ -23,11 +25,6 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
/* For PRIu16 etc. */
#include <inttypes.h>
#endif
gnrc_pktsnip_t *gnrc_icmpv6_echo_build(uint8_t type, uint16_t id, uint16_t seq,
uint8_t *data, size_t data_len)
{

View File

@ -47,14 +47,10 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
static char _stack[GNRC_IPV6_STACK_SIZE + THREAD_EXTRA_STACKSIZE_PRINTF];
#else
static char _stack[GNRC_IPV6_STACK_SIZE];
#endif
#define _MAX_L2_ADDR_LEN (8U)
static char _stack[GNRC_IPV6_STACK_SIZE + DEBUG_EXTRA_STACKSIZE];
#ifdef MODULE_FIB
/**
* @brief buffer to store the entries in the IPv6 forwarding table

View File

@ -703,11 +703,9 @@ _nib_abr_entry_t *_nib_abr_add(const ipv6_addr_t *addr)
DEBUG(" using %p\n", (void *)abr);
memcpy(&abr->addr, addr, sizeof(abr->addr));
}
#if ENABLE_DEBUG
else {
DEBUG(" NIB full\n");
}
#endif /* ENABLE_DEBUG */
return abr;
}

View File

@ -43,7 +43,7 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
#include "evtimer.h"
#endif

View File

@ -15,6 +15,7 @@
#include <assert.h>
#include <string.h>
#include <inttypes.h>
#include "net/gnrc/icmpv6.h"
#include "net/gnrc/ipv6.h"
@ -31,9 +32,6 @@
#define ENABLE_DEBUG 0
#include "debug.h"
/* For PRIu8 etc. */
#include <inttypes.h>
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
gnrc_pktsnip_t *gnrc_ndp_nbr_sol_build(const ipv6_addr_t *tgt,

View File

@ -57,15 +57,15 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_lookup_addr(const ipv6_addr_t *addr)
mutex_unlock(&_ctx_mutex);
#if ENABLE_DEBUG
if (res != NULL) {
DEBUG("6lo ctx: found context (%u, %s/%" PRIu8 ") ",
(res->flags_id & GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK),
ipv6_addr_to_str(ipv6str, &res->prefix, sizeof(ipv6str)),
res->prefix_len);
DEBUG("for address %s\n", ipv6_addr_to_str(ipv6str, addr, sizeof(ipv6str)));
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (res != NULL) {
DEBUG("6lo ctx: found context (%u, %s/%" PRIu8 ") ",
(res->flags_id & GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK),
ipv6_addr_to_str(ipv6str, &res->prefix, sizeof(ipv6str)),
res->prefix_len);
DEBUG("for address %s\n", ipv6_addr_to_str(ipv6str, addr, sizeof(ipv6str)));
}
}
#endif
return res;
}

View File

@ -16,6 +16,9 @@
* @author Peter Kietzmann <peter.kietzmann@haw-hamburg.de>
*/
#include <assert.h>
#include <inttypes.h>
#include "kernel_types.h"
#include "net/gnrc/pktbuf.h"
#include "net/gnrc/netapi.h"
@ -30,14 +33,6 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
/* For PRIu16 etc. */
#include <assert.h>
#include <inttypes.h>
#endif
static inline uint16_t _floor8(uint16_t length)
{
return length & 0xfff8U;

View File

@ -32,12 +32,7 @@
static kernel_pid_t _pid = KERNEL_PID_UNDEF;
#if ENABLE_DEBUG
static char _stack[GNRC_SIXLOWPAN_STACK_SIZE + THREAD_EXTRA_STACKSIZE_PRINTF];
#else
static char _stack[GNRC_SIXLOWPAN_STACK_SIZE];
#endif
static char _stack[GNRC_SIXLOWPAN_STACK_SIZE + DEBUG_EXTRA_STACKSIZE];
/* handles GNRC_NETAPI_MSG_TYPE_RCV commands */
static void _receive(gnrc_pktsnip_t *pkt);

View File

@ -923,16 +923,16 @@ static int _forward_frag(gnrc_pktsnip_t *pkt, gnrc_pktsnip_t *frag_hdr,
DEBUG("to (%s, %u)\n",
gnrc_netif_addr_to_str(vrbe->super.dst, vrbe->super.dst_len,
addr_str), vrbe->out_tag);
#if ENABLE_DEBUG && defined(MODULE_OD)
DEBUG("Original fragmentation header:\n");
od_hex_dump(frag_hdr->data, frag_hdr->size, OD_WIDTH_DEFAULT);
DEBUG("IPHC headers + payload:\n");
frag_hdr = pkt;
while (frag_hdr) {
if (IS_ACTIVE(ENABLE_DEBUG) && IS_USED(MODULE_OD)) {
DEBUG("Original fragmentation header:\n");
od_hex_dump(frag_hdr->data, frag_hdr->size, OD_WIDTH_DEFAULT);
frag_hdr = frag_hdr->next;
DEBUG("IPHC headers + payload:\n");
frag_hdr = pkt;
while (frag_hdr) {
od_hex_dump(frag_hdr->data, frag_hdr->size, OD_WIDTH_DEFAULT);
frag_hdr = frag_hdr->next;
}
}
#endif
gnrc_pktbuf_release(pkt);
(void)frag_hdr;
(void)page;

View File

@ -23,7 +23,7 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif

View File

@ -30,7 +30,7 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#endif

View File

@ -42,11 +42,7 @@ static msg_t _eventloop_msg_queue[TCP_EVENTLOOP_MSG_QUEUE_SIZE];
/**
* @brief Allocate memory for GNRC TCP thread stack.
*/
#if ENABLE_DEBUG
static char _stack[TCP_EVENTLOOP_STACK_SIZE + THREAD_EXTRA_STACKSIZE_PRINTF];
#else
static char _stack[TCP_EVENTLOOP_STACK_SIZE];
#endif
static char _stack[TCP_EVENTLOOP_STACK_SIZE + DEBUG_EXTRA_STACKSIZE];
/**
* @brief Central evtimer for gnrc_tcp event loop

View File

@ -42,11 +42,7 @@ static kernel_pid_t _pid = KERNEL_PID_UNDEF;
/**
* @brief Allocate memory for the UDP thread's stack
*/
#if ENABLE_DEBUG
static char _stack[GNRC_UDP_STACK_SIZE + THREAD_EXTRA_STACKSIZE_PRINTF];
#else
static char _stack[GNRC_UDP_STACK_SIZE];
#endif
static char _stack[GNRC_UDP_STACK_SIZE + DEBUG_EXTRA_STACKSIZE];
/**
* @brief Calculate the UDP checksum dependent on the network protocol

View File

@ -21,6 +21,7 @@
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <inttypes.h>
#include "xtimer.h"
#include "random.h"
@ -32,11 +33,6 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
/* For PRIu16 etc. */
#include <inttypes.h>
#endif
const csma_sender_conf_t CSMA_SENDER_CONF_DEFAULT = {
CONFIG_CSMA_SENDER_MIN_BE_DEFAULT,
CONFIG_CSMA_SENDER_MAX_BE_DEFAULT,

View File

@ -89,13 +89,13 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
int ret = -EHOSTUNREACH;
bool is_all_zeros_addr = true;
#if ENABLE_DEBUG
DEBUG("[fib_find_entry] dst =");
for (size_t i = 0; i < dst_size; i++) {
DEBUG(" %02x", dst[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
DEBUG("[fib_find_entry] dst =");
for (size_t i = 0; i < dst_size; i++) {
DEBUG(" %02x", dst[i]);
}
DEBUG("\n");
}
DEBUG("\n");
#endif
for (size_t i = 0; i < dst_size; ++i) {
if (dst[i] != 0) {
@ -175,15 +175,15 @@ static int fib_find_entry(fib_table_t *table, uint8_t *dst, size_t dst_size,
}
}
#if ENABLE_DEBUG
if (count > 0) {
DEBUG("[fib_find_entry] found prefix on interface %d:", entry_arr[0]->iface_id);
for (size_t i = 0; i < entry_arr[0]->global->address_size; i++) {
DEBUG(" %02x", entry_arr[0]->global->address[i]);
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (count > 0) {
DEBUG("[fib_find_entry] found prefix on interface %d:", entry_arr[0]->iface_id);
for (size_t i = 0; i < entry_arr[0]->global->address_size; i++) {
DEBUG(" %02x", entry_arr[0]->global->address[i]);
}
DEBUG("\n");
}
DEBUG("\n");
}
#endif
*entry_arr_size = count;
return ret;

View File

@ -41,7 +41,7 @@
#define CONFIG_PTHREAD_REAPER_BASE_STACKSIZE (THREAD_STACKSIZE_IDLE)
#endif
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
# define PTHREAD_REAPER_STACKSIZE ((CONFIG_PTHREAD_REAPER_BASE_STACKSIZE) + THREAD_EXTRA_STACKSIZE_PRINTF)
# define PTHREAD_STACKSIZE THREAD_STACKSIZE_MAIN
#else

View File

@ -28,11 +28,11 @@
timex_t timex_add(const timex_t a, const timex_t b)
{
#if ENABLE_DEBUG
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
puts("timex_add on denormalized value");
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
puts("timex_add on denormalized value");
}
}
#endif
timex_t result;
result.seconds = a.seconds + b.seconds;
@ -52,22 +52,22 @@ timex_t timex_set(uint32_t seconds, uint32_t microseconds)
result.seconds = seconds;
result.microseconds = microseconds;
#if ENABLE_DEBUG
if (!timex_isnormalized(&result)) {
puts("timex_set on denormalized value");
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (!timex_isnormalized(&result)) {
puts("timex_set on denormalized value");
}
}
#endif
return result;
}
timex_t timex_sub(const timex_t a, const timex_t b)
{
#if ENABLE_DEBUG
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
puts("timex_sub on denormalized value");
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
puts("timex_sub on denormalized value");
}
}
#endif
timex_t result;
@ -85,11 +85,11 @@ timex_t timex_sub(const timex_t a, const timex_t b)
int timex_cmp(const timex_t a, const timex_t b)
{
#if ENABLE_DEBUG
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
puts("timex_cmp on denormalized value");
if (IS_ACTIVE(ENABLE_DEBUG)) {
if (!timex_isnormalized(&a) || !timex_isnormalized(&b)) {
puts("timex_cmp on denormalized value");
}
}
#endif
if (a.seconds < b.seconds) {
return -1;

View File

@ -31,7 +31,8 @@
#define ENABLE_DEBUG 0
#include "debug.h"
#if ENABLE_DEBUG
#if IS_ACTIVE(ENABLE_DEBUG)
/* Since some of these functions are called by printf, we can't really call
* printf from our functions or we end up in an infinite recursion. */
#include <unistd.h> /* for STDOUT_FILENO */

View File

@ -311,7 +311,7 @@ void ztimer_handler(ztimer_clock_t *clock)
{
DEBUG("ztimer_handler(): %p now=%" PRIu32 "\n", (void *)clock, clock->ops->now(
clock));
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
_ztimer_print(clock);
}
@ -364,7 +364,7 @@ void ztimer_handler(ztimer_clock_t *clock)
_ztimer_update(clock);
if (ENABLE_DEBUG) {
if (IS_ACTIVE(ENABLE_DEBUG)) {
_ztimer_print(clock);
}
DEBUG("ztimer_handler(): %p done.\n", (void *)clock);

View File

@ -50,9 +50,7 @@ static int _init(int argc, char **argv)
if (sdcard_spi_init(card, &sdcard_spi_params[0]) != 0) {
puts("[FAILED]");
#if ENABLE_DEBUG != 1
puts("enable debugging in sdcard_spi.c for further information!");
#endif
puts("enable debugging in sdcard_spi.c for more information!");
return -2;
}
puts("[OK]");