1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #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);
- }
- }
- /**
- * @brief 上传任务内容
- * @param None
- * @note None
- * @retval None
- */
- void task_ec800_content(void)
- {
- // unsigned long times = 0;
- static uint8_t firstFlag = 0; // 初次标志
- messageDate *p_messageDate = &s_messageDate; // 定义消息指针
- // 拷贝485接收道德数据到待发送的消息中
- // Task_Ec800_Uplaod_CopyRs485Date(&s_rs485RecDate, &s_messageDate);
- // 4G模块的操作
- EC800_stateTransition_use();
- // 陀螺仪姿态初始化
- // 速度达到5km/s往上,判断手把握正
- if((p_messageDate->vehicleSpeed > SPEED_Go_STRAIGHT) && (firstFlag == 0)){
- firstFlag = 1;
- atk_ms6050_dmp_init();
- printf("ATK-MS6050 DMP init!\r\n");
- }
-
- // 判断车辆是否正在转弯 陀螺仪数据
- // if (isTurning()) {
- // printf("The vehicle is turning.\r\n");
- // } else {
- // printf("Vehicle not turning.\r\n");
- // }
-
- // times = getRunTimeCounterValue();
- // printf("任务运行时间: %ld\r\n", times);
- osDelay(100);
- }
|