1 Commits

Author SHA1 Message Date
Qiea
1c0f3b676f save 2024-11-13 12:30:23 +08:00
7 changed files with 63 additions and 47 deletions

View File

@@ -169,13 +169,14 @@ float* hidden(const float* input_matrix){
return affine1_rslt; return affine1_rslt;
} }
float* output(const float* input_matrix){ float* output(Model model_w, const float* input_matrix){
u8 num = model_w.num_kernels;
float affine2_temp; // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD> float affine2_temp; // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD>
float *affine2_rslt = (float *) mymalloc(SRAMEX,sizeof(float)*7); float *affine2_rslt = (float *) mymalloc(SRAMEX,(sizeof(float)*num));
memset(affine2_rslt, 0, sizeof(float)*7); memset(affine2_rslt, 0, sizeof(float)*num);
// <20><><EFBFBD><EFBFBD>10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // <20><><EFBFBD><EFBFBD>10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(int n=0; n<7; n++) for(int n=0; n<num; n++)
{ {
affine2_temp = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>Ϊ0 affine2_temp = 0; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>Ϊ0
@@ -256,10 +257,10 @@ float* generateMatrix(Model model, const float* value)
return CNN_data; return CNN_data;
} }
float calculate_probabilities(float *input_array) float calculate_probabilities(Model model_w, float *input_array)
{ {
float sum = 0; float sum = 0;
u8 input_num = 7; u8 input_num = model_w.num_kernels;
float *result = (float *) mymalloc(SRAMEX,sizeof(float)*input_num); float *result = (float *) mymalloc(SRAMEX,sizeof(float)*input_num);
memset(result, 0, sizeof(float)*input_num); memset(result, 0, sizeof(float)*input_num);
@@ -297,8 +298,8 @@ float calculate_probabilities(float *input_array)
} }
u8 calculate_layer(float *input_array){ u8 calculate_layer(Model model_w, float *input_array){
u8 input_num = 7; u8 input_num = model_w.num_kernels;
u8 predict_num = 0; u8 predict_num = 0;
float max_temp = -100; float max_temp = -100;
for(int n=0; n<input_num; n++) for(int n=0; n<input_num; n++)
@@ -309,8 +310,8 @@ u8 calculate_layer(float *input_array){
predict_num = n; // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> predict_num = n; // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
} }
} }
//print_rslt(input_array,7,7); print_rslt(input_array,input_num,input_num);
return predict_num+1; return predict_num+0;
} }
@@ -320,9 +321,14 @@ void cnn_run(){
if (check_threshold(data,&value[0])){ if (check_threshold(data,&value[0])){
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100 * 100 <20><><EFBFBD><EFBFBD> //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100 * 100 <20><><EFBFBD><EFBFBD>
float* _data = generateMatrix(data,&value[0]); float* _data = generateMatrix(data,&value[0]);
char kind[50];
DEBUG_PRINTF("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ磡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ:%f ƽ<><C6BD>ֵ:%f <20><>׼<EFBFBD><D7BC>:%f\r\n",value[0],value[1],value[2]); DEBUG_PRINTF("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ磡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ:%f ƽ<><C6BD>ֵ:%f <20><>׼<EFBFBD><D7BC>:%f\r\n",value[0],value[1],value[2]);
DEBUG_PRINTF("<EFBFBD><EFBFBD>ԭʼ<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD>SD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
SDRAM_TO_SD();
char* _uuid = uuid(); char* _uuid = uuid();
CSTX_4G_RegALiYunIOT(1); //<2F><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>ģ<EFBFBD><C4A3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>ϱ<EFBFBD>
send_blocks(_data,_uuid); send_blocks(_data,_uuid);
//<2F><>һ<EFBFBD><EFBFBD><E3A3BA><EFBFBD><EFBFBD>102 * 102 //<2F><>һ<EFBFBD><EFBFBD><E3A3BA><EFBFBD><EFBFBD>102 * 102
@@ -367,10 +373,15 @@ void cnn_run(){
DEBUG_PRINTF("<EFBFBD><EFBFBD><EFBFBD>IJ㿪ʼ\n"); DEBUG_PRINTF("<EFBFBD><EFBFBD><EFBFBD>IJ㿪ʼ\n");
float* affine1_rslt = hidden(pool_rslt_3); float* affine1_rslt = hidden(pool_rslt_3);
DEBUG_PRINTF("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ\r\n"); DEBUG_PRINTF("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ\r\n");
float* affine2_rslt = output(affine1_rslt); float* affine2_rslt = output(fc2_weight, affine1_rslt);
printf("<EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>%f\n",calculate_probabilities(affine2_rslt)); DEBUG_PRINTF("<EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>%f\r\n",calculate_probabilities(fc2_weight, affine2_rslt));
printf("Label is:%d\r\n",calculate_layer(affine2_rslt)); DEBUG_PRINTF("Label is:%d\r\n",calculate_layer(fc2_weight, affine2_rslt));
snprintf(kind, 50,"UUID:%s P:%f Label:%d", _uuid, calculate_probabilities(fc2_weight, affine2_rslt), calculate_layer(fc2_weight, affine2_rslt));
CSTX_4G_ALiYunIOTSenddata_string(kind,"kind_string");
CSTX_4G_RegALiYunIOT(0); //<2F><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>ʱ<EFBFBD><CAB1> <20>ź<EFBFBD>
myfree(SRAMEX,pool_rslt_3); myfree(SRAMEX,pool_rslt_3);
pool_rslt_3 = NULL; pool_rslt_3 = NULL;

View File

@@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include "tools.h" #include "tools.h"
#include "Function.h"
void cnn_run(void); void cnn_run(void);
void _cnn_run(void); void _cnn_run(void);

View File

@@ -14,7 +14,7 @@ Model fc2_bias;
Model fc2_weight; Model fc2_weight;
Model data; Model data;
float data_array[DATA_ARRSIZE] __attribute__((at(0XC0009C40)));
float* modelmym_init(char* model_name){ float* modelmym_init(char* model_name){
if(conv1_bias.array == NULL && strcmp(model_name, "conv1_bias") == 0) if(conv1_bias.array == NULL && strcmp(model_name, "conv1_bias") == 0)
@@ -37,8 +37,8 @@ float* modelmym_init(char* model_name){
return fc2_bias.array = (float*)mymalloc(SRAMEX, FC2_BIAS_ARRSIZE * sizeof(float)); return fc2_bias.array = (float*)mymalloc(SRAMEX, FC2_BIAS_ARRSIZE * sizeof(float));
else if(fc2_weight.array == NULL && strcmp(model_name, "fc2_weight") == 0) else if(fc2_weight.array == NULL && strcmp(model_name, "fc2_weight") == 0)
return fc2_weight.array = (float*)mymalloc(SRAMEX, FC2_WEIGHT_ARRSIZE * sizeof(float)); return fc2_weight.array = (float*)mymalloc(SRAMEX, FC2_WEIGHT_ARRSIZE * sizeof(float));
else if(data.array == NULL && strcmp(model_name, "data") == 0) // else if(data.array == NULL && strcmp(model_name, "data") == 0)
return data.array = (float*)mymalloc(SRAMEX, DATA_ARRSIZE * sizeof(float)); // return data.array = (float*)mymalloc(SRAMEX, DATA_ARRSIZE * sizeof(float));
else if(strcmp(model_name, "all") == 0){ else if(strcmp(model_name, "all") == 0){
if(conv1_bias.array == NULL)conv1_bias.array = (float*)mymalloc(SRAMEX, CONV1_BIAS_ARRSIZE * sizeof(float)); if(conv1_bias.array == NULL)conv1_bias.array = (float*)mymalloc(SRAMEX, CONV1_BIAS_ARRSIZE * sizeof(float));
if(conv1_weight.array == NULL)conv1_weight.array = (float*)mymalloc(SRAMEX, CONV1_WEIGHT_ARRSIZE * sizeof(float)); if(conv1_weight.array == NULL)conv1_weight.array = (float*)mymalloc(SRAMEX, CONV1_WEIGHT_ARRSIZE * sizeof(float));
@@ -50,7 +50,7 @@ float* modelmym_init(char* model_name){
if(fc1_weight.array == NULL)fc1_weight.array = (float*)mymalloc(SRAMEX, FC1_WEIGHT_ARRSIZE * sizeof(float)); if(fc1_weight.array == NULL)fc1_weight.array = (float*)mymalloc(SRAMEX, FC1_WEIGHT_ARRSIZE * sizeof(float));
if(fc2_bias.array == NULL)fc2_bias.array = (float*)mymalloc(SRAMEX, FC2_BIAS_ARRSIZE * sizeof(float)); if(fc2_bias.array == NULL)fc2_bias.array = (float*)mymalloc(SRAMEX, FC2_BIAS_ARRSIZE * sizeof(float));
if(fc2_weight.array == NULL)fc2_weight.array = (float*)mymalloc(SRAMEX, FC2_WEIGHT_ARRSIZE * sizeof(float)); if(fc2_weight.array == NULL)fc2_weight.array = (float*)mymalloc(SRAMEX, FC2_WEIGHT_ARRSIZE * sizeof(float));
if(data.array == NULL)data.array = (float*)mymalloc(SRAMEX, DATA_ARRSIZE * sizeof(float)); // if(data.array == NULL)data.array = (float*)mymalloc(SRAMEX, DATA_ARRSIZE * sizeof(float));
} }
return NULL; return NULL;
} }
@@ -119,9 +119,9 @@ u8 modelmym_free(char* model_name){
return 1; return 1;
} }
else if(data.array != NULL && strcmp(model_name, "data") == 0){ else if(data.array != NULL && strcmp(model_name, "data") == 0){
myfree(SRAMEX,data.array); // myfree(SRAMEX,data.array);
data.array = NULL; memset(data.array, 0 ,data.maxlength);
data.realength = 0; // data.realength = 0;
return 1; return 1;
} }
else if(strcmp(model_name, "all") == 0){ else if(strcmp(model_name, "all") == 0){
@@ -173,7 +173,7 @@ u8 model_write(char* model_name)
Model *_model = model(model_name); Model *_model = model(model_name);
if(_model == NULL || strcmp(model_name, "data") == 0){ if(_model == NULL || strcmp(model_name, "data") == 0){
sprintf(_path, "0:/dataset/_data/%s.txt", model_name); sprintf(_path, "dataset/_data/%s.txt", model_name);
if(f_open(file, (const TCHAR *)_path, 1)){ if(f_open(file, (const TCHAR *)_path, 1)){
DEBUG_PRINTF("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>ģ<EFBFBD>ͻ<EFBFBD>Data<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n"); DEBUG_PRINTF("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>ģ<EFBFBD>ͻ<EFBFBD>Data<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
return 199; return 199;
@@ -184,7 +184,7 @@ u8 model_write(char* model_name)
} }
if(_model -> dname == NULL){ if(_model -> dname == NULL){
sprintf(_path, "0:/dataset/%s.txt", _model -> name); sprintf(_path, "dataset/%s.txt", _model -> name);
if(f_open(file, (const TCHAR *)_path, 1)){ if(f_open(file, (const TCHAR *)_path, 1)){
DEBUG_PRINTF("Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>ͣ<EFBFBD>[%s]\r\n", _path); DEBUG_PRINTF("Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>ͣ<EFBFBD>[%s]\r\n", _path);
return 4; return 4;
@@ -197,7 +197,7 @@ u8 model_write(char* model_name)
} }
if(_model -> dname)sprintf(_datapath, "_data/%s", _model -> dname); if(_model -> dname)sprintf(_datapath, "_data/%s", _model -> dname);
sprintf(_path, "0:/dataset/%s.txt", _model -> dname ? _datapath : _model -> name); sprintf(_path, "dataset/%s.txt", _model -> dname ? _datapath : _model -> name);
if(f_open(file, (const TCHAR *)_path, 1)){ if(f_open(file, (const TCHAR *)_path, 1)){
DEBUG_PRINTF("<EFBFBD>ļ<EFBFBD>[%s]<5D>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>\r\n", _model -> dname ? _model -> dname : _model -> name); DEBUG_PRINTF("<EFBFBD>ļ<EFBFBD>[%s]<5D>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>\r\n", _model -> dname ? _model -> dname : _model -> name);
return 199; return 199;
@@ -286,7 +286,7 @@ u8 model_switchdata(char* data_name){
u8 _len = strlen(data_name); u8 _len = strlen(data_name);
char _path[_len+1+7+35]; char _path[_len+1+7+35];
if(data.array != NULL)modelmym_free("data"); if(data.array != NULL)modelmym_free("data");
sprintf(_path, "0:/dataset/_data/%s.txt",data_name); sprintf(_path, "dataset/_data/%s.txt",data_name);
if(f_open(file,(const TCHAR*)_path,1)){ if(f_open(file,(const TCHAR*)_path,1)){
DEBUG_PRINTF("\r\nData<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>[%s]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n",data_name); DEBUG_PRINTF("\r\nData<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>[%s]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n",data_name);
return 0; return 0;
@@ -361,7 +361,7 @@ void model_init(){
conv1_weight.array = modelmym_init(conv1_weight.name); conv1_weight.array = modelmym_init(conv1_weight.name);
conv1_weight.maxlength = CONV1_WEIGHT_ARRSIZE; conv1_weight.maxlength = CONV1_WEIGHT_ARRSIZE;
conv1_weight.channel = 1; conv1_weight.channel = 1;
conv1_weight.num_kernels = 32; conv1_weight.num_kernels = CONV1_BIAS_ARRSIZE;
conv2_bias.name = "conv2_bias"; conv2_bias.name = "conv2_bias";
conv2_bias.array = modelmym_init(conv2_bias.name); conv2_bias.array = modelmym_init(conv2_bias.name);
@@ -371,7 +371,7 @@ void model_init(){
conv2_weight.array = modelmym_init(conv2_weight.name); conv2_weight.array = modelmym_init(conv2_weight.name);
conv2_weight.maxlength = CONV2_WEIGHT_ARRSIZE; conv2_weight.maxlength = CONV2_WEIGHT_ARRSIZE;
conv2_weight.channel = 32; conv2_weight.channel = 32;
conv2_weight.num_kernels = 64; conv2_weight.num_kernels = CONV2_BIAS_ARRSIZE;
conv3_bias.name = "conv3_bias"; conv3_bias.name = "conv3_bias";
conv3_bias.array = modelmym_init(conv3_bias.name); conv3_bias.array = modelmym_init(conv3_bias.name);
@@ -381,7 +381,7 @@ void model_init(){
conv3_weight.array = modelmym_init(conv3_weight.name); conv3_weight.array = modelmym_init(conv3_weight.name);
conv3_weight.maxlength = CONV3_WEIGHT_ARRSIZE; conv3_weight.maxlength = CONV3_WEIGHT_ARRSIZE;
conv3_weight.channel = 64; conv3_weight.channel = 64;
conv3_weight.num_kernels = 128; conv3_weight.num_kernels = CONV3_BIAS_ARRSIZE;
fc1_bias.name = "fc1_bias"; fc1_bias.name = "fc1_bias";
fc1_bias.array = modelmym_init(fc1_bias.name); fc1_bias.array = modelmym_init(fc1_bias.name);
@@ -398,10 +398,14 @@ void model_init(){
fc2_weight.name = "fc2_weight"; fc2_weight.name = "fc2_weight";
fc2_weight.array = modelmym_init(fc2_weight.name); fc2_weight.array = modelmym_init(fc2_weight.name);
fc2_weight.maxlength = FC2_WEIGHT_ARRSIZE; fc2_weight.maxlength = FC2_WEIGHT_ARRSIZE;
fc2_weight.num_kernels = FC2_BIAS_ARRSIZE;
data.name = "data"; data.name = "data";
data.array = modelmym_init(data.name); data.array = data_array;
data.maxlength = DATA_ARRSIZE; data.maxlength = DATA_ARRSIZE;
data.realength = DATA_ARRSIZE;
data.dname = "data"; data.dname = "data";
memset(data.array, 0, sizeof(float)*DATA_ARRSIZE);
} }

View File

@@ -36,15 +36,12 @@ typedef struct {
#define CONV3_WEIGHT_ARRSIZE (128*64*3*3) //73728 #define CONV3_WEIGHT_ARRSIZE (128*64*3*3) //73728
#define FC1_BIAS_ARRSIZE (128) #define FC1_BIAS_ARRSIZE (128)
#define FC1_WEIGHT_ARRSIZE (128*18432) //2359296 #define FC1_WEIGHT_ARRSIZE (128*18432) //2359296
#define FC2_BIAS_ARRSIZE (7)
#define FC2_WEIGHT_ARRSIZE (7*128) //896
#define is1250000 1
#if is1250000
#define DATA_ARRSIZE (1250000) #define FC2_BIAS_ARRSIZE (4) //4<><34><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#else #define FC2_WEIGHT_ARRSIZE (4*128)
#define DATA_ARRSIZE (100 * 100) #define DATA_ARRSIZE (1300000) //ԭʼ<D4AD><CABC><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> 1300000
#endif

View File

@@ -100,6 +100,6 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{ {
if(htim==(&TIM3_Handler)) if(htim==(&TIM3_Handler))
{ {
LED1=!LED1; //LED1<44><31>ת LED_R=!LED_R; //LED1<44><31>ת
} }
} }

View File

@@ -26,7 +26,7 @@ void send_blocks(float* arr, char* uuid_str){
for (int j = 0; j < 100; ++j) { for (int j = 0; j < 100; ++j) {
int n = snprintf(block + block_index, 100 * 100 - block_index, "%.6f|", arr[i * 100 + j]); int n = snprintf(block + block_index, 100 * 100 - block_index, "%.6f|", arr[i * 100 + j]);
block_index += n; block_index += n;
if (block_index >= 9000) { if (block_index >= 7000) {
block_index = 0; // <20><><EFBFBD>ÿ<EFBFBD> block_index = 0; // <20><><EFBFBD>ÿ<EFBFBD>
_total_len++; _total_len++;
} }
@@ -39,12 +39,14 @@ void send_blocks(float* arr, char* uuid_str){
for (int j = 0; j < 100; ++j) { for (int j = 0; j < 100; ++j) {
int n = snprintf(block + block_index, 100*100 - block_index, "%.6f|", arr[i*100+j]); int n = snprintf(block + block_index, 100*100 - block_index, "%.6f|", arr[i*100+j]);
block_index += n; block_index += n;
if (block_index >= 9000) { if (block_index >= 7000) {
char* _block = (char*) mymalloc(SRAMEX,sizeof(char)*100*100); char* _block = (char*) mymalloc(SRAMEX,sizeof(char)*100*100);
memset(_block, 0 ,sizeof(char)*100*100); memset(_block, 0 ,sizeof(char)*100*100);
block_index = 0; // <20><><EFBFBD>ÿ<EFBFBD> block_index = 0; // <20><><EFBFBD>ÿ<EFBFBD>
sprintf(_block, "{\"uuid\":\"%s\",\"Bid\":\"%d\",\"Eid\":\"%d\",\"Block\":\"%s\"}\n", uuid_str, total_len++, _total_len, block); sprintf(_block, "{\\\"uuid\\\":\\\"%s\\\",\\\"Bid\\\":\\\"%d\\\",\\\"Eid\\\":\\\"%d\\\",\\\"Block\\\":\\\"%s\\\"}\n", uuid_str, total_len++, _total_len, block);
DEBUG_PRINTF("%s", _block); //DEBUG_PRINTF("%s", _block);
CSTX_4G_ALiYunIOTSenddata_string(_block,"data_string");
myfree(SRAMEX,_block); myfree(SRAMEX,_block);
_block = NULL; _block = NULL;
} }
@@ -56,8 +58,9 @@ void send_blocks(float* arr, char* uuid_str){
char* _block = (char*) mymalloc(SRAMEX,sizeof(char)*100*100); char* _block = (char*) mymalloc(SRAMEX,sizeof(char)*100*100);
memset(_block, 0 ,sizeof(char)*100*100); memset(_block, 0 ,sizeof(char)*100*100);
block_index = 0; block_index = 0;
sprintf(_block, "{\"uuid\":\"%s\",\"Bid\":\"%d\",\"Eid\":\"%d\",\"Block\":\"%s\"}\n", uuid_str, total_len, _total_len, block); sprintf(_block, "{\\\"uuid\\\":\\\"%s\\\",\\\"Bid\\\":\\\"%d\\\",\\\"Eid\\\":\\\"%d\\\",\\\"Block\\\":\\\"%s\\\"}\n", uuid_str, total_len, _total_len, block);
DEBUG_PRINTF("%s", _block); //DEBUG_PRINTF("%s", _block);
CSTX_4G_ALiYunIOTSenddata_string(_block,"data_string");
myfree(SRAMEX,_block); myfree(SRAMEX,_block);
_block = NULL; _block = NULL;
} }
@@ -65,4 +68,3 @@ void send_blocks(float* arr, char* uuid_str){
myfree(SRAMEX,block); myfree(SRAMEX,block);
block = NULL; block = NULL;
} }

View File

@@ -1,5 +1,6 @@
#include "cnn_model.h" #include "cnn_model.h"
#include "debug.h" #include "debug.h"
#include "EC800M.h"
char* uuid(void); char* uuid(void);