From 8a573170e0513f0f90a051c80451a4897bd2ade4 Mon Sep 17 00:00:00 2001 From: bmy <2583236812@qq.com> Date: Fri, 23 Feb 2024 20:41:40 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E6=9B=B4=E6=94=B9=E9=80=9A=E4=BF=A1?= =?UTF-8?q?=E5=B8=A7=E6=8E=A5=E6=94=B6=E5=AE=8C=E6=88=90=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.c | 8 ++++++-- app/tiny_frame/by_tiny_frame_parse.c | 9 +++++---- app/tiny_frame/by_tiny_frame_parse.h | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/main.c b/app/main.c index af00836..028d67c 100644 --- a/app/main.c +++ b/app/main.c @@ -35,9 +35,13 @@ #include "by_tiny_frame_pack.h" /** 测试完成后移除 **/ -void test(void) +void test(uint8_t status) { - printf("hhhhhhok\r\n"); + if (status) { + printf("noooooooo!\r\n"); + } else { + printf("hhhhhhok\r\n"); + } } int main(void) diff --git a/app/tiny_frame/by_tiny_frame_parse.c b/app/tiny_frame/by_tiny_frame_parse.c index d5f627f..0432c14 100644 --- a/app/tiny_frame/by_tiny_frame_parse.c +++ b/app/tiny_frame/by_tiny_frame_parse.c @@ -10,7 +10,7 @@ uint8_t listern_flag; uint16_t listern_timeout; uint16_t listern_timevia; by_tf_parse_frame_t frame_now; -by_tf_parse_success_handle_func parse_success_handle; +by_tf_parse_done_handle_func parse_done_handle; void by_tiny_frame_parse_init(void) { @@ -104,6 +104,7 @@ void by_tiny_frame_parse_run(void) } else { if (listern_timeout <= listern_timevia) { // 接收超时,停止监听 + parse_done_handle(1); by_tiny_frame_parse_end_listern(); #if (BY_TF_DEBUG) printf("by_tf_listern timeout\r\n"); @@ -126,7 +127,7 @@ void by_tiny_frame_parse_run(void) // 接收成功后停止监听 by_tiny_frame_parse_end_listern(); // 解析成功回调 - parse_success_handle(); + parse_done_handle(0); #if (BY_TF_DEBUG) printf("frame parsed!\r\n"); #endif @@ -160,9 +161,9 @@ uint8_t by_tiny_frame_parse_crc(by_tf_parse_frame_t *frame_s) return 1; } -void by_tiny_frame_parse_handle_register(by_tf_parse_success_handle_func func) +void by_tiny_frame_parse_handle_register(by_tf_parse_done_handle_func func) { - parse_success_handle = func; + parse_done_handle = func; } void by_tiny_frame_parse_start_listern(void) diff --git a/app/tiny_frame/by_tiny_frame_parse.h b/app/tiny_frame/by_tiny_frame_parse.h index eeb41a0..2d7a7ac 100644 --- a/app/tiny_frame/by_tiny_frame_parse.h +++ b/app/tiny_frame/by_tiny_frame_parse.h @@ -18,13 +18,13 @@ typedef struct by_tf_parse_frame_t { uint32_t data; } by_tf_parse_frame_t; -typedef void (*by_tf_parse_success_handle_func)(void); +typedef void (*by_tf_parse_done_handle_func)(uint8_t); extern void by_tiny_frame_parse_init(void); extern void by_tiny_frame_parse_uart_handle(uint8_t buff); extern void by_tiny_frame_parse_run(void); extern uint8_t by_tiny_frame_parse_crc(by_tf_parse_frame_t *frame_s); -extern void by_tiny_frame_parse_handle_register(by_tf_parse_success_handle_func func); +extern void by_tiny_frame_parse_handle_register(by_tf_parse_done_handle_func func); extern void by_tiny_frame_parse_start_listern(void); extern void by_tiny_frame_parse_end_listern(void);