From ad4da8ea92eb07e5ec269f83abf57724f040fa34 Mon Sep 17 00:00:00 2001 From: zzh Date: Fri, 18 Jul 2025 10:54:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=90=88=E5=8C=85=E4=BA=AE?= =?UTF-8?q?=E7=81=AF=E7=9A=84=E9=94=81=EF=BC=8C=E9=98=B2=E6=AD=A2=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index 677f7ea..71e2be6 100644 --- a/main.c +++ b/main.c @@ -59,7 +59,7 @@ int fd; int UPCASE=0; int count_value=0; int getPayloadTime=120*1000;//usecond -char softwareVersion[16]="1.1.20"; +char softwareVersion[16]="1.1.22"; char stationsn[16]="TJ251372224247";//TJ250995217957 char productid[8]="10045"; char appKey[32]="fdhQmhqhvbL1cf1K9mUqt"; @@ -1912,7 +1912,7 @@ void *thread_mqtt_recv(void *arg){ system("mv /userdata/tx_ota /userdata/ota"); system("mv /userdata/ota/ustart.sh /userdata"); system("sync"); - sleep(1); + sleep(15); system("reboot"); }else if(strcmp(mqtt_parm.msg_type,"5003")==0){ LOG_I("5003 need report station info\n"); @@ -2047,7 +2047,7 @@ void *thread_mqtt_recv(void *arg){ if(strcmp(msg_labelconfig_value,"")!=0){ mqtt_service_reply(stationsn,mqtt_parm.msg_messageId,"ok",1,productid); isSendComEnd=false; - isLightOn=false; + isLightOn=false; isLightOnByRule=true; isLabelUp=false; //isSearchLabel=false; @@ -2539,7 +2539,7 @@ int main(int argc, char *argv[]) { // 先检查标准输入是否可用 if (feof(stdin) || ferror(stdin)) { - LOG_I("stdin error or EOF, sleeping for 1 second\n"); + //LOG_I("stdin error or EOF, sleeping for 1 second\n"); sleep(1); continue; } @@ -2592,17 +2592,21 @@ void *thread_timeout_check(void *arg) { // 合并点亮线程 void *thread_3015_lighton_merge(void *arg) { - while (1) { + int total_all = 0; + + while (1) { pthread_mutex_lock(&lightsn_buffer_mutex); if (is_3015_collecting) { time_t now = time(NULL); if ((now - first_3015_time >= 3) || (lightsn_buffer_count >= MAX_LIGHTSN_BUFFER)) { int total = lightsn_buffer_count; - int batch_size = 10; + total_all += total; + int batch_size = 10; int sent = 0; while (sent < total) { int this_batch = (total - sent > batch_size) ? batch_size : (total - sent); - if (isLightEnable && this_batch > 0) { + LOG_I("-------total:%d, sent:%d, this batch: %d------\n", total, sent, this_batch); + if (isLightEnable && this_batch > 0) { isLightOn = true; isLightOnByRule = false; isLabelUp = false; @@ -2673,11 +2677,12 @@ void *thread_3015_lighton_merge(void *arg) { } sent += this_batch; if (sent < total) { - pthread_mutex_unlock(&lightsn_buffer_mutex); // 释放锁等待 sleep(3); - pthread_mutex_lock(&lightsn_buffer_mutex); // 重新加锁 } + + LOG_I("total_all: %d\n", total_all); } + // 不要立即清空buffer,等待isLightOn处理完成 is_3015_collecting = false; first_3015_time = 0;