generated from hulk/gd32e23x_template
主函数中重复执行,500ms间隔获取温度数据
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "rs485_protocol.h"
|
||||
|
||||
extern uint8_t g_temperature_uint8[2];
|
||||
|
||||
void process_command(uint8_t *cmd, size_t length) {
|
||||
char combined_str[3];
|
||||
validation_result_t validate = VALIDATION_SUCCESS;
|
||||
@@ -18,11 +20,9 @@ void process_command(uint8_t *cmd, size_t length) {
|
||||
// printf("%d", length);
|
||||
sprintf(combined_str, "%c%c", cmd[3], cmd[4]);
|
||||
if (strcmp(combined_str, "M1") == 0) {
|
||||
|
||||
ultrasonic_distance_report();
|
||||
} else if (strcmp(combined_str, "M2") == 0) {
|
||||
printf("%c%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0x6B, 0xCC);
|
||||
// tempture_value_report();
|
||||
gd60914_tempture();
|
||||
} else if (strcmp(combined_str, "M3") == 0)
|
||||
{
|
||||
printf("%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0xCC);
|
||||
@@ -130,3 +130,15 @@ void ultrasonic_distance_report(void) {
|
||||
printf("%c%c%c%c", package_data[0], package_data[1], package_data[2], package_data[3]);
|
||||
printf("%c", calculate_crc(combined_data, 8));
|
||||
}
|
||||
|
||||
void gd60914_tempture(void) {
|
||||
static uint8_t package_header[3] = {0xB5, 0xF0, 0x02};
|
||||
|
||||
uint8_t combined_data[5];
|
||||
memcpy(combined_data, package_header, 3);
|
||||
memcpy(combined_data + 3, g_temperature_uint8, 2);
|
||||
|
||||
printf("%c%c%c", package_header[0], package_header[1], package_header[2]);
|
||||
printf("%c%c", g_temperature_uint8[1], g_temperature_uint8[0]);
|
||||
printf("%c", calculate_crc(combined_data, 6));
|
||||
}
|
||||
Reference in New Issue
Block a user