From fb5772da17a1657620c3b408233e90cfb5953040 Mon Sep 17 00:00:00 2001 From: dgjames <1943357252@qq.com> Date: Sat, 21 Dec 2024 18:59:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- my_pro/myinfrared.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/my_pro/myinfrared.c b/my_pro/myinfrared.c index 57b0c9a..848f09a 100644 --- a/my_pro/myinfrared.c +++ b/my_pro/myinfrared.c @@ -34,7 +34,8 @@ void snake_compare(rt_uint8_t key, rt_uint8_t repeat) if (rt_atomic_load(&now_direction) != 2) rt_atomic_store(&now_direction, 0); - *str = "forward\n"; + rt_strncpy(str,"forward\n",10); + // *str = ; rt_device_write(serial, 0, str, rt_strlen(str)); } @@ -44,7 +45,8 @@ void snake_compare(rt_uint8_t key, rt_uint8_t repeat) { if (rt_atomic_load(&now_direction) != 3) rt_atomic_store(&now_direction, 1); - *str = "left\n"; + // *str = "left\n"; + rt_strncpy(str,"left\n",10); rt_device_write(serial, 0, str, rt_strlen(str)); } @@ -53,7 +55,8 @@ void snake_compare(rt_uint8_t key, rt_uint8_t repeat) { if (rt_atomic_load(&now_direction) != 0) rt_atomic_store(&now_direction, 2); - *str= "back\n"; + // *str= "back\n"; + rt_strncpy(str,"back\n",10); rt_device_write(serial, 0, str, rt_strlen(str)); } @@ -62,7 +65,8 @@ void snake_compare(rt_uint8_t key, rt_uint8_t repeat) { if (rt_atomic_load(&now_direction) != 1) rt_atomic_store(&now_direction, 3); - *str = "right\n"; + rt_strncpy(str,"right\n",10); + // *str = "right\n"; rt_device_write(serial, 0, str, rt_strlen(str)); } @@ -81,7 +85,7 @@ void snake_compare(rt_uint8_t key, rt_uint8_t repeat) if (repeat == 0 && (rt_strcmp(tmp, "73") == 0||rt_strcmp(tmp, "FF") == 0)) { *str = "OK\n"; - /* 发送字符串 */ + rt_strncpy(str,"OK\n",10); rt_device_write(serial, 0, str, rt_strlen(str)); if (page_chosen == 4&& page_stop == 0) {