增加雷达开启、关闭、临时关闭功能,本地电子围栏功能完善

This commit is contained in:
wjw 2025-07-12 10:02:05 +08:00
parent 924d3e9635
commit 501f096df6
7 changed files with 44 additions and 13 deletions

View File

@ -14,7 +14,7 @@
#include "gps_config.h" #include "gps_config.h"
#include "local_tts.h" #include "local_tts.h"
#if 1 #if 0
#include "app_uart.h" #include "app_uart.h"
#define DEBUG(fmt, args...) app_printf("[GPS]" fmt, ##args) #define DEBUG(fmt, args...) app_printf("[GPS]" fmt, ##args)
#else #else

View File

@ -16,7 +16,7 @@
#include "gps_config.h" #include "gps_config.h"
#include "local_tts.h" #include "local_tts.h"
#if 1 #if 0
#include "app_uart.h" #include "app_uart.h"
#define DEBUG(fmt, args...) app_printf("[Broadcast]" fmt, ##args) #define DEBUG(fmt, args...) app_printf("[Broadcast]" fmt, ##args)
#else #else
@ -320,8 +320,6 @@ static void play_attraction_info(AttractionNode* attraction, double distance) {
static void attr_broadcast_task(void* arg) { static void attr_broadcast_task(void* arg) {
(void)arg; // 避免未使用参数警告 (void)arg; // 避免未使用参数警告
BOOL should_play; //是否播放最后判断量 BOOL should_play; //是否播放最后判断量
BOOL introduc=true; //是否播报景区介绍
DEBUG("task begin\r\n"); DEBUG("task begin\r\n");
@ -329,7 +327,6 @@ static void attr_broadcast_task(void* arg) {
{ {
safe_tts_play(park_desc,11); safe_tts_play(park_desc,11);
introduc=false;
} }
while (1) { while (1) {

View File

@ -130,7 +130,7 @@ typedef struct{
uint8_t IO_TX_brake :1; // 1:正常 0:刹车 uint8_t IO_TX_brake :1; // 1:正常 0:刹车
uint8_t A_brake :1; // 1:自动刹车,0:手动刹车 uint8_t A_brake :1; // 1:自动刹车,0:手动刹车
uint8_t A_Speed_Cut :1; // 1:自动减速,0:手动减速 uint8_t A_Speed_Cut :1; // 1:自动减速,0:手动减速
uint8_t P_Radar_EN :1; // 1:雷达使能,0:雷达禁止 uint8_t P_Radar_EN :1; // 2:雷达暂时关闭,1:雷达使能,0:雷达禁止
}; };
uint8_t IO_STA; uint8_t IO_STA;
}; };

View File

@ -26,6 +26,7 @@ typedef enum {
ID_GetLocInfoResp = 0x0201, // 位置信息查询应答 ID_GetLocInfoResp = 0x0201, // 位置信息查询应答
ID_LocTrackingCtrl = 0x8202, // 临时位置跟踪控制 ID_LocTrackingCtrl = 0x8202, // 临时位置跟踪控制
ID_TxtMsgdelivery = 0x8300, // 文本信息下发 ID_TxtMsgdelivery = 0x8300, // 文本信息下发
ID_Paly_Introduction =0x8302, //播放景区介绍
ID_Car_Ctrl = 0x8500, // 车辆控制 ID_Car_Ctrl = 0x8500, // 车辆控制
ID_Car_CtrlResp = 0x0500, // 车辆控制应答 ID_Car_CtrlResp = 0x0500, // 车辆控制应答
ID_Set_Polygon_area = 0x8604, // 设置多边形区域 ID_Set_Polygon_area = 0x8604, // 设置多边形区域

View File

@ -38,7 +38,7 @@ typedef enum {
ID_BrakeLimit_B = 0xF006, //WORD 后退刹车距离 ID_BrakeLimit_B = 0xF006, //WORD 后退刹车距离
ID_SpeedCutLimit_B = 0xF007, //WORD 后退自动减速刹车距离 ID_SpeedCutLimit_B = 0xF007, //WORD 后退自动减速刹车距离
ID_Ban_Fence_Polygon_Delay_OFF = 0xF008, //BYTE 禁止围栏延时关闭时间, 单位秒 ID_Ban_Fence_Polygon_Delay_OFF = 0xF008, //BYTE 禁止围栏延时关闭时间, 单位秒
ID_RadarEN = 0xF009, //BYTE 雷达使能位, 0 代表关闭, 1 代表开启 ID_RadarEN = 0xF009, //BYTE 雷达使能位, 0 代表关闭, 1 代表开启 2代表临时关闭
}set_TermParamID_t; }set_TermParamID_t;
typedef struct{ typedef struct{
uint32_t HeartBeatInterval;// DWORD, 终端心跳发送间隔(s) uint32_t HeartBeatInterval;// DWORD, 终端心跳发送间隔(s)

View File

@ -13,6 +13,7 @@
#include "local_tts.h" #include "local_tts.h"
#include "control_out.h" #include "control_out.h"
#include "radar.h"
#define LOCAL_FENCE_COUNT (sizeof(local_fences) / sizeof(LocalFenceConfig_t)) #define LOCAL_FENCE_COUNT (sizeof(local_fences) / sizeof(LocalFenceConfig_t))
@ -148,7 +149,7 @@ void jt808_Set_CarStatus(uint8_t status){
} }
sys_sta.O_door_lock = (status & 0x01)? 1 : 0; // 设置电门锁状态 sys_sta.O_door_lock = (status & 0x01)? 1 : 0; // 设置电门锁状态
sys_sta.PLT_MODE = (status & 0x02)? 1 : 0; // 平台设置的模式 //1:游客模式,0:管理模式 sys_sta.PLT_MODE = (status & 0x02)? 1 : 0; // 平台设置的模式 //1:游客模式,0:管理模式
sys_sta.P_Radar_EN = (status & 0x04)? 1 : 0; // 1:雷达使能,0:雷达禁止 // sys_sta.P_Radar_EN = (status & 0x04)? 1 : 0; // 1:雷达使能,0:雷达禁止
} }
// 获取车辆状态 // 获取车辆状态
@ -361,8 +362,22 @@ int jt808_setTermParam(set_TermParamID_t param_id, void *param, uint8_t param_le
break; break;
} }
case ID_RadarEN:{// TODO: 雷达使能位 case ID_RadarEN:{// TODO: 雷达使能位
jt808_term_param_item.set_term_param.RadarEN =param_val32 & 0xFF; uint8_t radar_en = param_val32 & 0xFF;
break; JT808_DEBUG("RadarEN=%d", radar_en);
// 更新运行时状态包括值2
osMutexAcquire(radar_mutex, osWaitForever);
sys_sta.P_Radar_EN = radar_en;
osMutexRelease(radar_mutex);
// 只保存0或1到持久化参数
if(radar_en != 2) {
jt808_term_param_item.set_term_param.RadarEN = radar_en;
} else {
// 值2不保存但可以记录日志
JT808_DEBUG("Skip saving temporary RadarEN=2 state");
}
break;
} }
default:{ default:{
// TODO: 未知参数 // TODO: 未知参数
@ -517,7 +532,7 @@ void jt808_LocReport_param_update(void){
jt808_term_param_item.big_loc_report.basic_info.status.IO_TX_brake =sys_sta.IO_TX_brake; // 1:正常 0:刹车 jt808_term_param_item.big_loc_report.basic_info.status.IO_TX_brake =sys_sta.IO_TX_brake; // 1:正常 0:刹车
jt808_term_param_item.big_loc_report.basic_info.status.A_brake =sys_sta.A_brake; // 1:自动刹车,0:手动刹车 jt808_term_param_item.big_loc_report.basic_info.status.A_brake =sys_sta.A_brake; // 1:自动刹车,0:手动刹车
jt808_term_param_item.big_loc_report.basic_info.status.A_Speed_Cut =sys_sta.A_Speed_Cut; // 1:自动减速,0:手动减速 jt808_term_param_item.big_loc_report.basic_info.status.A_Speed_Cut =sys_sta.A_Speed_Cut; // 1:自动减速,0:手动减速
jt808_term_param_item.big_loc_report.basic_info.status.P_Radar_EN =sys_sta.P_Radar_EN; // 1:雷达使能,0:雷达禁止 jt808_term_param_item.big_loc_report.basic_info.status.P_Radar_EN =sys_sta.P_Radar_EN; //2:雷达暂时关闭 1:雷达使能,0:雷达禁止
jt808_term_param_item.big_loc_report.basic_info.status.val32 = Swap32(jt808_term_param_item.big_loc_report.basic_info.status.val32); // 状态信息(转大端) jt808_term_param_item.big_loc_report.basic_info.status.val32 = Swap32(jt808_term_param_item.big_loc_report.basic_info.status.val32); // 状态信息(转大端)
jt808_term_param_item.big_loc_report.basic_info.alarm_flag.val32 = 0; // 清除报警标志 jt808_term_param_item.big_loc_report.basic_info.alarm_flag.val32 = 0; // 清除报警标志

View File

@ -26,6 +26,7 @@
static osThreadId_t os_RADAR_ThreadId; static osThreadId_t os_RADAR_ThreadId;
radar_data_t radar_data; radar_data_t radar_data;
osMutexId_t radar_mutex; // 互斥锁
/****************************************************************************** /******************************************************************************
@ -126,10 +127,15 @@ void radar_CheckData(uint8_t *data, uint16_t data_len){
// 定时处理数和获取数据 // 定时处理数和获取数据
static void RADAR_TaskHandle(void *param){ static void RADAR_TaskHandle(void *param){
uint8_t temp_count =0; uint8_t temp_count =0;
uint16_t time_count =0;
while(1){ while(1){
if(0==sys_sta.P_Radar_EN)
{
continue;
}
osMutexAcquire(radar_mutex, osWaitForever);
if (1==sys_sta.P_Radar_EN) if (1==sys_sta.P_Radar_EN)
{ {
if(radar_CMDSend_cnt != radar_CMDReceive_cnt){ // 发送命令和接收命令计数不一致时,复位自动刹车和减速状态 if(radar_CMDSend_cnt != radar_CMDReceive_cnt){ // 发送命令和接收命令计数不一致时,复位自动刹车和减速状态
@ -155,6 +161,18 @@ static void RADAR_TaskHandle(void *param){
} }
else if (2==sys_sta.P_Radar_EN)
{
time_count++;
if(time_count>=143)
{
sys_sta.P_Radar_EN=1;
time_count=0;
}
}
osMutexRelease(radar_mutex);
osDelay(140/5); // 140ms osDelay(140/5); // 140ms
} }
} }