修改通信协议部分,修改版型为0x04

This commit is contained in:
yelvlab 2025-01-08 09:14:18 +08:00
parent 1af7a98a5f
commit 8a7baaf87a
2 changed files with 6 additions and 5 deletions

View File

@ -21,7 +21,7 @@
#define RX_BUFFER_SIZE 32 #define RX_BUFFER_SIZE 32
#define PROTOCOL_PACKAGE_HEADER 0xD5 #define PROTOCOL_PACKAGE_HEADER 0xD5
#define PROTOCOL_BOARD_TYPE 0x03 #define PROTOCOL_BOARD_TYPE 0x04
#define PROTOCOL_PACKAGE_LENGTH 0x02 #define PROTOCOL_PACKAGE_LENGTH 0x02
/******************************************************************************/ /******************************************************************************/
@ -49,7 +49,7 @@ validation_result_t validate_package_type(uint8_t* data);
validation_result_t validate_data_length(uint8_t* data); validation_result_t validate_data_length(uint8_t* data);
void gd60914_tempture(void); void gd60914_tempture_report(void);
void ultrasonic_distance_report(void); void ultrasonic_distance_report(void);

View File

@ -21,8 +21,9 @@ void process_command(uint8_t *cmd, size_t length) {
sprintf(combined_str, "%c%c", cmd[3], cmd[4]); sprintf(combined_str, "%c%c", cmd[3], cmd[4]);
if (strcmp(combined_str, "M1") == 0) { if (strcmp(combined_str, "M1") == 0) {
ultrasonic_distance_report(); ultrasonic_distance_report();
} else if (strcmp(combined_str, "M2") == 0) { } else if (strcmp(combined_str, "M2") == 0)
gd60914_tempture(); {
gd60914_tempture_report();
} else if (strcmp(combined_str, "M3") == 0) } else if (strcmp(combined_str, "M3") == 0)
{ {
printf("%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0xCC); printf("%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0xCC);
@ -131,7 +132,7 @@ void ultrasonic_distance_report(void) {
printf("%c", calculate_crc(combined_data, 8)); printf("%c", calculate_crc(combined_data, 8));
} }
void gd60914_tempture(void) { void gd60914_tempture_report(void) {
static uint8_t package_header[3] = {0xB5, 0xF0, 0x02}; static uint8_t package_header[3] = {0xB5, 0xF0, 0x02};
uint8_t combined_data[5]; uint8_t combined_data[5];