diff --git a/myfreertos/myfreertos.c b/myfreertos/myfreertos.c index 336cbe2..8b4e804 100644 --- a/myfreertos/myfreertos.c +++ b/myfreertos/myfreertos.c @@ -46,6 +46,10 @@ void SensorDataRequestTask(void *pvParameters); * sync environment data: EE B5 01 */ void SyncEnvironmentDataRequestTask(void *pvParameters); +/** + * 定时制热test +*/ +void HotTestRequestTask(void *pvParameters); @@ -116,6 +120,7 @@ void os_init(void) xTaskCreate(SensorDataRequestTask, "SensorDataRequestTask", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL); xTaskCreate(SyncEnvironmentDataRequestTask, "SyncEnvironmentDataRequestTask", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL); + xTaskCreate(HotTestRequestTask, "HotTestRequestTask", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 3, NULL); vTaskStartScheduler(); @@ -189,13 +194,67 @@ void SensorDataRequestTask(void *pvParameters) { void SyncEnvironmentDataRequestTask(void *pvParameters) { while (1) { - // 发送传感器数据请求的操作 RS485_1_Send_Data_3(); vTaskDelay(SYNC_ENVIRONMENT_DATA_REQUEST_PERIOD); } } +int hot = 0; +/** + * 20%的情况下,加热1min,然后冷却10分钟 +*/ +void HotTestRequestTask(void *pvParameters) { + while (1) { + if (T >= 350) { + hot = 0; + } else { + hot = 10; + + // hot += 10; + // if (hot > 100) { + // hot = 10; + // } + } + u8 temp_data[8] = { 0x10, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }; + + temp_data[4] = hot / 256; + temp_data[5] = hot % 256; + + GetCRC16(temp_data, 6, temp_data + 6, temp_data + 7); + + // RS485_3_Init(9600); + RS485_1_Send_Data(temp_data, 8); + // RS485_1_Send_Data(temp_data, 8); + delay_xms(30); + // RS485_1_Init(9600); + + + // HC595_Send_Byte(gpio_state |= 0x04); // open heater |=0000 0100 0x04 + hot_clod_flag = 2; + + // vTaskDelay(60000); + + + + // temp_data[4] = 0; + // temp_data[5] = 0; + + // GetCRC16(temp_data, 6, temp_data + 6, temp_data + 7); + + // // RS485_3_Init(9600); + // RS485_1_Send_Data(temp_data, 8); + // // RS485_3_Send_Data(temp_data, 8); + // // delay_xms(30); + // // RS485_1_Init(9600); + + // // HC595_Send_Byte(gpio_state &= 0xFB); // close heater &=1111 1011 0xFB + // hot_clod_flag = 0; + + vTaskDelay(1000 * 10); + } +} + u8 temp[4] = {0xaa,0xbb,0xcc,0xdd}; u8 times = 0; @@ -204,7 +263,7 @@ void Sensor_Communication_task(void *pvParameters) while (1) { - + // HC595_Send_Byte(0x00); // cnt_flag=do_mqtt(MQTT_SOCK,NET_CONFIG.rip,1883,5500); // Humidity=H*0.1; // temperature=T*0.1; @@ -466,7 +525,7 @@ void process_sensor_data(u8 *data) { humidity_flag = 0; } - HC595_Send_Byte(gpio_state); + // HC595_Send_Byte(gpio_state); RS485_1_Send_Data_2(); // 上传参数 // delay_xms(200);