task_communication(6720).c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "task_communication.h"
  2. // 定义测试函数
  3. void test_isPointInPolygon() {
  4. // 定义多边形的经纬度坐标集合
  5. double polygonLat[] = {34.34934, 34.25916, 34.36221, 34.21619};
  6. double polygonLng[] = {108.84569, 108.80257, 109.03829, 109.05611};
  7. // 测试点在多边形内部的情况
  8. double point1Lat = 34.33312;
  9. double point1Lng = 108.8531;
  10. /* 尝试获取互斥量,等待无限长时间 */
  11. if(osMutexAcquire(s_messageDate_locationHandle, osWaitForever) == osOK)
  12. {
  13. /* 安全地访问s_rs485RecDate结构体 */
  14. point1Lat = s_messageDate.latitude / 100000;
  15. point1Lng = s_messageDate.longitude / 100000;
  16. /* 访问完成,释放互斥量 */
  17. osMutexRelease(s_messageDate_locationHandle);
  18. }
  19. bool result1 = isPointInPolygon(point1Lat, point1Lng, polygonLat, polygonLng);
  20. printf("Test case 1: Point (%f, %f) is%s inside the polygon.\n", point1Lat, point1Lng, result1 ? "" : " not");
  21. }
  22. /* USER CODE BEGIN Header_Task_communication */
  23. /**
  24. * @brief Function implementing the communication thread.
  25. * @param argument: Not used
  26. * @retval None
  27. */
  28. /* USER CODE END Header_Task_communication */
  29. void task_communication_content(void)
  30. {
  31. unsigned long times = 0;
  32. LED0_TOGGLE(); // 灯翻转
  33. EC800_FTP_OTA_Upgrade(); // OTA升级
  34. // 固件升级时不做其他操作,保证固件更新的完成
  35. if(s_ec800Date.hardwareUpdate != 0){
  36. HAL_NVIC_DisableIRQ(USART3_IRQn); // 避免被中斷
  37. // HAL_NVIC_DisableIRQ(USART1_IRQn);
  38. vTaskSuspend(ec800_dataUploaHandle); // 挂起任务
  39. osDelay(200);
  40. }else{
  41. // test_isPointInPolygon(); // 电子围栏
  42. //
  43. // rs485_poll_sendReceive(); // 与车进行通信
  44. osDelay(1000);
  45. }
  46. // times = getRunTimeCounterValue();
  47. // printf("test_isPointInPolygon:%ld\r\n", times);
  48. }