增加操控端遥控

This commit is contained in:
2026-04-13 20:05:04 +08:00
parent 73a3bd5bbf
commit b508b7b8dd
3 changed files with 19 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
*/ */
#include "app_rc.h" #include "app_rc.h"
#include <stdio.h>
/** 定时器 */ /** 定时器 */
static Timer rc_timer; static Timer rc_timer;
@@ -163,11 +164,13 @@ void rcInputHandler(void *signal_id)
// CRC校验通过更新序列号和使能状态 // CRC校验通过更新序列号和使能状态
rc_app_state.rc_16ch_current_seq = remote_control_16ch_output.frame.SEQ; rc_app_state.rc_16ch_current_seq = remote_control_16ch_output.frame.SEQ;
rc_app_state.rc_16ch_enable = 1; rc_app_state.rc_16ch_enable = 1;
printf("RC: 16ch CRC OK, SEQ=%d, Enable=1\n", rc_app_state.rc_16ch_current_seq);
} }
else else
{ {
// CRC校验失败不更新数据 // CRC校验失败不更新数据
rc_app_state.rc_16ch_enable = 0; rc_app_state.rc_16ch_enable = 0;
printf("RC: 16ch CRC FAILED, Enable=0\n");
} }
} }
else if (signal_id == &un_remote_control_input_can) else if (signal_id == &un_remote_control_input_can)
@@ -175,6 +178,9 @@ void rcInputHandler(void *signal_id)
// 传统遥控器数据更新 // 传统遥控器数据更新
rc_app_state.rc_traditional_current_seq++; rc_app_state.rc_traditional_current_seq++;
rc_app_state.rc_traditional_enable = un_remote_control_input_can.bit_data.enable; rc_app_state.rc_traditional_enable = un_remote_control_input_can.bit_data.enable;
printf("RC: Traditional SEQ=%d, Enable=%d\n",
rc_app_state.rc_traditional_current_seq,
rc_app_state.rc_traditional_enable);
} }
// 节点在线判断和数据输出 // 节点在线判断和数据输出
@@ -259,11 +265,19 @@ void rcInputHandler(void *signal_id)
un_remote_control_input.bit_data.switch_a = 0; un_remote_control_input.bit_data.switch_a = 0;
un_remote_control_input.bit_data.enable = 1; un_remote_control_input.bit_data.enable = 1;
printf("RC: 16ch data processed - Speed=%d, Curvature=%d, Switch_D=%d, Switch_B=%d, Switch_C=%d\n",
un_remote_control_input.bit_data.speed,
un_remote_control_input.bit_data.curvature,
un_remote_control_input.bit_data.switch_d,
un_remote_control_input.bit_data.switch_b,
un_remote_control_input.bit_data.switch_c);
} }
else else
{ {
// 都离线,清空使能 // 都离线,清空使能
un_remote_control_input.bit_data.enable = 0; un_remote_control_input.bit_data.enable = 0;
printf("RC: Both nodes offline, enable=0\n");
} }
publishMessage(&un_remote_control_input, 1); // 优先级为1这里只传递数据指针 publishMessage(&un_remote_control_input, 1); // 优先级为1这里只传递数据指针
@@ -292,4 +306,6 @@ void rcAppInit(void)
// 启动定时器500ms周期 // 启动定时器500ms周期
timerStart(&rc_timer, 500, 1); timerStart(&rc_timer, 500, 1);
printf("RC: Application initialized successfully\n");
} }

View File

@@ -64,7 +64,7 @@ static dwc_eth_config_t g_eth1_cfg = {
.dma_bus_width = 64, .dma_bus_width = 64,
.phy_intf_mode = ETH_PHY_INTF_SEL_RMII, .phy_intf_mode = ETH_PHY_INTF_SEL_RMII,
.set_phy_intf = set_phyif_mode, .set_phy_intf = set_phyif_mode,
.ip = {192, 168, 17, 20}, .ip = {192, 168, 17, 21},
.mask = {255, 255, 255, 0}, .mask = {255, 255, 255, 0},
.phy = g_phy_arr1 .phy = g_phy_arr1

View File

@@ -31,6 +31,7 @@
#include <app/app_light.h> #include <app/app_light.h>
#include "app/app_request.h" #include "app/app_request.h"
#include "app/app_ultrasonic.h" #include "app/app_ultrasonic.h"
#include "app/app_rc.h"
void testAppInit(void); void testAppInit(void);
@@ -129,6 +130,7 @@ int main(void)
requestAppInit(); requestAppInit();
canInterfaceInit(); canInterfaceInit();
bootInterfaceInit(); bootInterfaceInit();
rcAppInit();
// ultrasonicAppInit(); // ultrasonicAppInit();
printf("All init OK ------ %d\n",getCurrentTime()); printf("All init OK ------ %d\n",getCurrentTime());