123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #include "task_ec800_upload.h"
- /* define ------------------------------------------------------------*/
- #define ANGLE_UPDATE_TIME 50 // 角度更新时间 2s 单位100ms
- #define SPEED_Go_STRAIGHT 25 // 直行速度 25KM/H 用来判断手把扶正 初始化姿态
- /* variables ---------------------------------------------------------*/
- // 拷贝数据
- void Task_Ec800_Uplaod_CopyRs485Date(rs485RecDate *p_rs485RecDate, messageDate *p_messageDate){
- /* 尝试获取互斥量,等待无限长时间 */
- if(osMutexAcquire(mutex_rs485RecDateHandle, osWaitForever) == osOK)
- {
- /* 安全地访问s_rs485RecDate结构体 */
- memcpy(&p_messageDate->vehicleSpeed, &p_rs485RecDate->vehicleSpeed, sizeof(p_rs485RecDate->vehicleSpeed));
- memcpy(&p_messageDate->dailyDrivTime, &p_rs485RecDate->dailyDrivTime, sizeof(p_rs485RecDate->dailyDrivTime));
- memcpy(&p_messageDate->dailyDrivMileage, &p_rs485RecDate->dailyDrivMileage, sizeof(p_rs485RecDate->dailyDrivMileage));
- memcpy(&p_messageDate->accTotalDrivTime_day, &p_rs485RecDate->accTotalDrivTime_day, sizeof(p_rs485RecDate->accTotalDrivTime_day));
- memcpy(&p_messageDate->accTotalDrivTime_h_min, &p_rs485RecDate->accTotalDrivTime_h_min, sizeof(p_rs485RecDate->accTotalDrivTime_h_min));
- memcpy(&p_messageDate->accTotalMileage_h, &p_rs485RecDate->accTotalMileage_h, sizeof(p_rs485RecDate->accTotalMileage_h));
- memcpy(&p_messageDate->accTotalMileage_l, &p_rs485RecDate->accTotalMileage_l, sizeof(p_rs485RecDate->accTotalMileage_l));
- memcpy(&p_messageDate->runTime, &p_rs485RecDate->runTime, sizeof(p_rs485RecDate->runTime));
- memcpy(&p_messageDate->batCompartmentTemp, &p_rs485RecDate->batCompartmentTemp, sizeof(p_rs485RecDate->batCompartmentTemp));
- memcpy(&p_messageDate->demandCur, &p_rs485RecDate->demandCur, sizeof(p_rs485RecDate->demandCur));
- memcpy(&p_messageDate->demandVol, &p_rs485RecDate->demandVol, sizeof(p_rs485RecDate->demandVol));
- memcpy(&p_messageDate->alarmLevel, &p_rs485RecDate->alarmLevel, sizeof(p_rs485RecDate->alarmLevel));
- memcpy(&p_messageDate->alarmType, &p_rs485RecDate->alarmType, sizeof(p_rs485RecDate->alarmType));
- memcpy(&p_messageDate->batSn, &p_rs485RecDate->batSn, sizeof(p_rs485RecDate->batSn));
- memcpy(&p_messageDate->Vehicle_Num, &p_rs485RecDate->Vehicle_Num, sizeof(p_rs485RecDate->Vehicle_Num));
- memcpy(&p_messageDate->VIN, &p_rs485RecDate->VIN, sizeof(p_rs485RecDate->VIN));
-
- /* 访问完成,释放互斥量 */
- osMutexRelease(mutex_rs485RecDateHandle);
- }
- // 车辆状态判断
- if(s_comData.driveStatus == 2){
- p_messageDate->vehicleStatus = 0;
- }else if(s_comData.driveStatus == 3){
- p_messageDate->vehicleStatus = 1;
- }
- // 故障数据copy
- p_messageDate->malfunction = s_comData.Malfunction;
- // 角度数据赋值
- p_messageDate->drivDirection = previousYaw;
- }
- /**
- * @brief 上传故障信息
- * @note 如果存在故障,每秒上传一次故障报告
- * @param 无
- * @retval 无
- */
- void upload_fault_info(void) {
- static uint8_t upload_interval_counter = 0; // 上传间隔计数器
- comData *p_comData = &s_comData;
- // 检查是否存在故障
- if (p_comData->Malfunction == 0) {
- return; // 如果没有故障,直接返回
- }
- // 如果计数器达到上传间隔,上传故障报告
- if (upload_interval_counter % 10 == 0) {
- EC800_uploadFaultReport();
- }
- // 更新计数器
- if (upload_interval_counter < 250) {
- upload_interval_counter++;
- } else {
- upload_interval_counter = 0;
- }
- }
- /**
- * @brief 上传任务内容
- * @param None
- * @note None
- * @retval None
- */
- void task_ec800_content(void)
- {
- // unsigned long times = 0;
- // 蜂鸣器响应
- // control_beep_response();
- // 检测是否正在升级固件
- if(s_ec800Date.hardwareUpdate == 1){
- osDelay(100);
- return;
- }
- // // 拷贝485接收道德数据到待发送的消息中
- // Task_Ec800_Uplaod_CopyRs485Date(&s_rs485RecDate, &s_messageDate);
- //
- // // MQTT服务器数据接收处理
- // handleReceive();
- //
- // // 4G模块的操作
- // EC800_stateTransition_use();
- //
- // // 上传故障信息
- // upload_fault_info();
- // times = getRunTimeCounterValue();
- // printf("task run time: %ld\r\n", times);
- osDelay(100);
- }
|