去掉合包亮灯的锁,防止无法写入
This commit is contained in:
parent
e8670b0775
commit
ad4da8ea92
15
main.c
15
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");
|
||||
@ -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,16 +2592,20 @@ void *thread_timeout_check(void *arg) {
|
||||
|
||||
// 合并点亮线程
|
||||
void *thread_3015_lighton_merge(void *arg) {
|
||||
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;
|
||||
total_all += total;
|
||||
int batch_size = 10;
|
||||
int sent = 0;
|
||||
while (sent < total) {
|
||||
int this_batch = (total - sent > batch_size) ? batch_size : (total - sent);
|
||||
LOG_I("-------total:%d, sent:%d, this batch: %d------\n", total, sent, this_batch);
|
||||
if (isLightEnable && this_batch > 0) {
|
||||
isLightOn = true;
|
||||
isLightOnByRule = 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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user