各类信息只显示一次,错误不显示
This commit is contained in:
15
Core/Inc/Judge.h
Normal file
15
Core/Inc/Judge.h
Normal file
@ -0,0 +1,15 @@
|
||||
//
|
||||
// Created by zhu on 2024/1/31.
|
||||
//
|
||||
|
||||
#ifndef H750_CJSON_JUDGE_H
|
||||
#define H750_CJSON_JUDGE_H
|
||||
#include "string.h"
|
||||
#include "Get_Parameters.h"
|
||||
#include "Control_Adjustment.h"
|
||||
#include "cJSON_Test.h"
|
||||
#include "Store_Information.h"
|
||||
void Judge();
|
||||
|
||||
|
||||
#endif //H750_CJSON_JUDGE_H
|
@ -7,5 +7,5 @@
|
||||
void Control_St(uint8_t st_time){
|
||||
int st= 0;
|
||||
st = st_time;
|
||||
printf("st = %d\n",st);
|
||||
printf("St = %d\n",st);
|
||||
}
|
33
Core/Src/Judge.c
Normal file
33
Core/Src/Judge.c
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Created by zhu on 2024/1/31.
|
||||
//
|
||||
|
||||
#include "Judge.h"
|
||||
|
||||
void Judge(){
|
||||
struct paramstruct *ParamStructPtr;
|
||||
ParamStructPtr = GetParametesptr();
|
||||
if(ParamStructPtr->pn == 1 ){
|
||||
Printf_Pn_Number();
|
||||
}
|
||||
if(ParamStructPtr->sn == 1){
|
||||
Printf_Sn_Number();
|
||||
}
|
||||
if(ParamStructPtr->production_date ==1){
|
||||
Printf_Product_Time();
|
||||
}
|
||||
if(ParamStructPtr->manufacturer ==1){
|
||||
Printf_Manufacturer();
|
||||
}
|
||||
if(ParamStructPtr->Device_Pixel_Length ==1){
|
||||
Printf_Device_Pixel_Length();
|
||||
}
|
||||
if(ParamStructPtr->temperature==1){
|
||||
printf("Temperature:%.1f\r\n",Get_Temperature());
|
||||
}
|
||||
if(ParamStructPtr->Set_Integration_Time!=0){
|
||||
Control_St(ParamStructPtr->Set_Integration_Time);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
#include "cJSON_Test.h"
|
||||
#include "SerialDataProcess.h"
|
||||
|
||||
|
||||
extern bool Printf_Flag ;
|
||||
void SerialDataProcess()
|
||||
{
|
||||
uint8_t len;
|
||||
@ -22,6 +22,9 @@ void SerialDataProcess()
|
||||
cjson(g_usart_rx_buf);
|
||||
g_usart_rx_sta = 0;
|
||||
memset(g_usart_rx_buf, 0, sizeof(g_usart_rx_buf));
|
||||
}else
|
||||
{
|
||||
Printf_Flag = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,11 +14,11 @@ char Device_Pixel_Length[4];
|
||||
uint8_t Set_Integration_Time = 1;
|
||||
|
||||
void Printf_Pn_Number() {
|
||||
strcpy(pn_number, "12345678901");
|
||||
strcpy(pn_number, "IRIS_ZHU_01");
|
||||
printf("%s\n", pn_number);
|
||||
}
|
||||
void Printf_Sn_Number() {
|
||||
strcpy(sn_number, "12345678");
|
||||
strcpy(sn_number, "Sensor_1");
|
||||
printf("%s\n", sn_number);
|
||||
}
|
||||
void Printf_Product_Time() {
|
||||
|
@ -3,8 +3,10 @@
|
||||
#include "cJSON_Test.h"
|
||||
#include "string.h"
|
||||
#include "Store_Information.h"
|
||||
#include "stdlib.h"
|
||||
#include "stdbool.h"
|
||||
struct paramstruct Parameters; //声明结构体对象
|
||||
|
||||
extern bool Printf_Flag ;
|
||||
void cjson(uint8_t g_usart_json_string[])
|
||||
{
|
||||
const char * json_string = g_usart_json_string;
|
||||
@ -43,12 +45,14 @@ void cjson(uint8_t g_usart_json_string[])
|
||||
|
||||
|
||||
|
||||
|
||||
// 释放 cJSON 对象
|
||||
Printf_Flag= true;
|
||||
// 释放 cJSON 对象
|
||||
cJSON_Delete(json);
|
||||
} else {
|
||||
// 处理解析错误
|
||||
printf("JSON parsing error.\n");
|
||||
printf("JSON parsing error JSON parsing error JSON parsing error JSON parsing error.\n");
|
||||
Printf_Flag = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "stdlib.h"
|
||||
#include "Store_Information.h"
|
||||
#include "string.h"
|
||||
#include "Get_Parameters.h"
|
||||
#include "Control_Adjustment.h"
|
||||
#include "Judge.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@ -66,7 +64,7 @@ void SystemClock_Config(void);
|
||||
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
bool Printf_Flag = true;
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@ -120,31 +118,14 @@ int main(void)
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
SerialDataProcess();
|
||||
struct paramstruct *ParamStructPtr;
|
||||
ParamStructPtr = GetParametesptr();
|
||||
if(Printf_Flag== true){
|
||||
Judge();
|
||||
Printf_Flag = false;
|
||||
}
|
||||
|
||||
// paramstruct ->age = 20;
|
||||
|
||||
if(ParamStructPtr->pn == 1 ){
|
||||
Printf_Pn_Number();
|
||||
}
|
||||
if(ParamStructPtr->sn == 1){
|
||||
Printf_Sn_Number();
|
||||
}
|
||||
if(ParamStructPtr->production_date ==1){
|
||||
Printf_Product_Time();
|
||||
}
|
||||
if(ParamStructPtr->manufacturer ==1){
|
||||
Printf_Manufacturer();
|
||||
}
|
||||
if(ParamStructPtr->Device_Pixel_Length ==1){
|
||||
Printf_Device_Pixel_Length();
|
||||
}
|
||||
if(ParamStructPtr->temperature==1){
|
||||
printf("Temperature:%.1f\r\n",Get_Temperature());
|
||||
}
|
||||
if(ParamStructPtr->Set_Integration_Time!=0){
|
||||
Control_St(ParamStructPtr->Set_Integration_Time);
|
||||
}
|
||||
|
||||
//free(ParamStructPtr);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user