From 647c836a379d94b3b9a28f363bd55772761cf635 Mon Sep 17 00:00:00 2001 From: norly Date: Sat, 2 Mar 2019 18:33:20 +0100 Subject: [PATCH] VAG_DEBUG --- include/vag-bap.h | 3 +++ src/bap-rx.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/vag-bap.h b/include/vag-bap.h index cf24fd7..8e96623 100644 --- a/include/vag-bap.h +++ b/include/vag-bap.h @@ -1,6 +1,9 @@ #ifndef __VAG_BAP_H__ #define __VAG_BAP_H__ +#include +#define VAG_DEBUG(...) do { fprintf(stdout, __VA_ARGS__); } while(0) + #include diff --git a/src/bap-rx.c b/src/bap-rx.c index 2e6c0cd..d82f03d 100644 --- a/src/bap-rx.c +++ b/src/bap-rx.c @@ -17,7 +17,7 @@ struct BAP_Frame* vag_bap_handle_can_frame(struct BAP_RXer *bap, struct can_fram //printf("Received BAP frame from CAN ID %03x\n", frame->can_id); if (frame->can_dlc < 2) { - printf("Error: Frame too short\n"); + VAG_DEBUG("Error: Frame too short\n"); } if (frame->data[0] & 0x80) { @@ -31,17 +31,17 @@ struct BAP_Frame* vag_bap_handle_can_frame(struct BAP_RXer *bap, struct can_fram unsigned this_len; if (frame->can_dlc < 4) { - printf("Error: Frame too short\n"); + VAG_DEBUG("Error: Frame too short\n"); } if (bap->mfchannel[mfchannel]) { - printf("bap_handle_can_frame: new start frame for open channel\n"); + VAG_DEBUG("bap_handle_can_frame: new start frame for open channel\n"); } bap->mfchannel[mfchannel] = NULL; bap_frame = vag_bap_frame_alloc(); if (!bap_frame) { - printf("bap_handle_can_frame: Failed to allocate new frame\n"); + VAG_DEBUG("bap_handle_can_frame: Failed to allocate new frame\n"); return NULL; } @@ -57,7 +57,7 @@ struct BAP_Frame* vag_bap_handle_can_frame(struct BAP_RXer *bap, struct can_fram this_len = frame->can_dlc - 4; if (this_len > bap_frame->len) { - printf("bap_handle_can_frame: this_len > len\n"); + VAG_DEBUG("bap_handle_can_frame: this_len > len\n"); free(bap_frame); bap->mfchannel[mfchannel] = NULL; @@ -83,14 +83,14 @@ struct BAP_Frame* vag_bap_handle_can_frame(struct BAP_RXer *bap, struct can_fram bap_frame = bap->mfchannel[mfchannel]; if (!bap_frame) { - printf("bap_handle_can_frame: continuation frame for unknown mf channel %d\n", + VAG_DEBUG("bap_handle_can_frame: continuation frame for unknown mf channel %d\n", mfchannel); } this_len = frame->can_dlc - 1; if ((bap->len_done[mfchannel] + this_len) > bap_frame->len) { - printf("bap_handle_can_frame: len_done + this_len > len\n"); + VAG_DEBUG("bap_handle_can_frame: len_done + this_len > len\n"); free(bap_frame); bap->mfchannel[mfchannel] = NULL; @@ -117,7 +117,7 @@ struct BAP_Frame* vag_bap_handle_can_frame(struct BAP_RXer *bap, struct can_fram bap_frame = calloc(1, sizeof(struct BAP_Frame)); if (!bap_frame) { - printf("bap_handle_can_frame: Failed to allocate new frame\n"); + VAG_DEBUG("bap_handle_can_frame: Failed to allocate new frame\n"); return NULL; } -- 2.39.5