35 lines
979 B
C

//
// Created by dell on 24-11-29.
//
#include "RS485.h"
#include "gd32e23x.h"
#include "systick.h"
#include <stdio.h>
#include <stdlib.h>
#define MAX_CMD_SIZE 16
#define BUFSIZE 8
extern uint16_t g_distance_uint16;
extern uint16_t g_temperature_uint16;
void process_command(char *cmd) {
if (strncmp(cmd, "M1", 2) == 0) {
printf("M1 -=-=- OK!\r\n");
printf("Distance: %d\r\n", g_distance_uint16);
} else if (strncmp(cmd, "M2", 2) == 0) {
printf("M2 -=-=- OK!\r\n");
printf("Temperature: %d\r\n", g_temperature_uint16);
// } else if (strncmp(cmd, "M3", 2) == 0) {
// char *param_str = cmd + 2; // Skip "M3"
// int param = atoi(param_str + 1); // Skip "S" and convert to integer
// if (param >= 0 && param <= 100) {
// printf("M3 with parameter %d -=-=- OK!\r\n", param);
// } else {
// printf("Invalid parameter for M3 command!\r\n");
// }
} else {
printf("Invalid Command!\r\n");
}
}