diff --git a/CMakeLists.txt b/CMakeLists.txt index 72696932..66e3d802 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,4 +43,4 @@ if (ENABLE_FD_LOGS) if (LOG_LEVEL) add_definitions("-DTINY_LOG_LEVEL_DEFAULT=${LOG_LEVEL}") endif() -endif() \ No newline at end of file +endif() diff --git a/examples/linux/hdlc_demo_multithread/hdlc_demo_multithread.cpp b/examples/linux/hdlc_demo_multithread/hdlc_demo_multithread.cpp index 73e7de29..7a26fdc5 100644 --- a/examples/linux/hdlc_demo_multithread/hdlc_demo_multithread.cpp +++ b/examples/linux/hdlc_demo_multithread/hdlc_demo_multithread.cpp @@ -39,7 +39,7 @@ static bool peek_next; static void send_message(const char *message) { tiny_mutex_lock(&queue_mutex); - char *msg = _strdup(message); + char *msg = strdup(message); queue.push(msg); tiny_mutex_unlock(&queue_mutex); } diff --git a/examples/linux/loopback/tiny_loopback.cpp b/examples/linux/loopback/tiny_loopback.cpp index cf327fa4..df60da84 100644 --- a/examples/linux/loopback/tiny_loopback.cpp +++ b/examples/linux/loopback/tiny_loopback.cpp @@ -227,6 +227,7 @@ static int run_fd(tiny_serial_handle_t port) { fprintf(stderr, "Failed to send packet\n"); } + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } else { diff --git a/src/hal/tiny_debug.h b/src/hal/tiny_debug.h index 3b59f02a..e13947a4 100644 --- a/src/hal/tiny_debug.h +++ b/src/hal/tiny_debug.h @@ -65,6 +65,11 @@ extern "C" if ( lvl < g_tiny_log_level ) \ fprintf(stderr, "%08" PRIu32 " ms: " fmt, tiny_millis(), ##__VA_ARGS__); \ } +#define TINY_LOG0(lvl, fmt) \ + { \ + if ( lvl < g_tiny_log_level ) \ + fprintf(stderr, "%08" PRIu32 " ms: " fmt, tiny_millis()); \ + } #else #define TINY_LOG(...) #endif diff --git a/src/proto/crc/tiny_crc.c b/src/proto/crc/tiny_crc.c index dee20f4f..4edb1ba8 100644 --- a/src/proto/crc/tiny_crc.c +++ b/src/proto/crc/tiny_crc.c @@ -161,9 +161,13 @@ uint16_t tiny_chksum(uint16_t sum, const uint8_t* data, int data_length) int get_crc_field_size(hdlc_crc_t crc_type) { - if ( crc_type == 0xFF ) + if ( crc_type == HDLC_CRC_OFF ) { return 0; } + if ( crc_type == HDLC_CRC_DEFAULT ) + { + crc_type = HDLC_CRC_32; + } return (int)crc_type / 8; } diff --git a/src/proto/fd/tiny_fd.c b/src/proto/fd/tiny_fd.c index 91480ef0..3be853cf 100644 --- a/src/proto/fd/tiny_fd.c +++ b/src/proto/fd/tiny_fd.c @@ -38,7 +38,7 @@ #endif #if TINY_FD_DEBUG -#define LOG(lvl, fmt, ...) TINY_LOG(lvl, fmt, __VA_ARGS__) +#define LOG(lvl, fmt, ...) TINY_LOG(lvl, fmt, ##__VA_ARGS__) #else #define LOG(...) #endif