fix bug#198380 198378 198429 198411;修改kyrealtime模块中获取上传/下载网速的实现;补充libkysdk-realtime依赖,解决依赖不满足问题

This commit is contained in:
shaozhimin 2023-10-30 15:26:40 +08:00 committed by openkylin-cibot
parent d74fe70ce9
commit 1dd7df25fa
4 changed files with 339 additions and 1 deletions

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
libkysdk-system (2.2.3.5-0k0.17) yangtze; urgency=medium
*Bug号198380 198378 198429 198411
*需求号:
*其他修改修改kyrealtime模块中获取上传/下载网速的实现
补充libkysdk-realtime依赖解决依赖不满足问题
-- szm-min <shaozhimin@kylinos.cn> Wed, 11 Oct 2023 09:43:29 +0800
libkysdk-system (2.2.3.5-0k0.16) yangtze; urgency=medium
*Bug号

5
debian/control vendored
View File

@ -351,7 +351,10 @@ Package: libkysdk-realtime
Architecture: any
Section: utils
Depends: libkysdk-systemcommon,
libc6
libc6,
libgcc-s1 | libgcc1,
libstdc++6,
lm-sensors
Multi-Arch: same
Description: 运行时信息库

View File

@ -0,0 +1,325 @@
From: shaozhimin <shaozhimin@kylinos.cn>
Date: Mon, 30 Oct 2023 15:26:40 +0800
Subject: =?utf-8?b?Zml4IGJ1ZyMxOTgzODAgMTk4Mzc4IDE5ODQyOSAxOTg0MTHvvJvkv64=?=
=?utf-8?b?5pS5a3lyZWFsdGltZeaooeWdl+S4reiOt+WPluS4iuS8oC/kuIvovb3nvZHpgJ8=?=
=?utf-8?b?55qE5a6e546w77yb6KGl5YWFbGlia3lzZGstcmVhbHRpbWXkvp3otZbvvIzop6M=?=
=?utf-8?b?5Yaz5L6d6LWW5LiN5ruh6Laz6Zeu6aKY?=
---
src/hardware/libkyedid.c | 111 ++++++++++++++++++---------------------
src/net/libkynetinfo.c | 22 ++++----
src/proc/libkyprocess.c | 2 +-
src/realtime/libkyrealtimeinfo.c | 38 ++++++++++++--
4 files changed, 99 insertions(+), 74 deletions(-)
diff --git a/src/hardware/libkyedid.c b/src/hardware/libkyedid.c
index 4d5f71b..6f860c2 100644
--- a/src/hardware/libkyedid.c
+++ b/src/hardware/libkyedid.c
@@ -88,7 +88,6 @@ char *cmd_exec(char *file)
} else {
close(fd[1]); // 关闭写入端
- char buffer[1024];
const char* targetLine1 = "Display Product Name"; // 要匹配的目标行
const char* targetLine2 = "Alphanumeric Data String"; // 要匹配的目标行
@@ -136,7 +135,7 @@ void kdk_edid(char *name)
return;
}
int i = 0;
- memset(edid_character, 0, sizeof(edid_character));
+ memset(edid_character, 0, 1024);
while(fgets(edid_text, sizeof(edid_text), pipeLine))
{
if(i != 1)
@@ -490,9 +489,6 @@ const float kdk_edid_get_gamma(char *name)
float ga = 0.00;
char canonical_filename[100] = "\0";
char filename[100] = "\0";
- // char edid_text[24] = "\0";
- // char num[24] = "\0";
- // char line[11520] = "\0";
char str_name[32] = "\0";
strcpy(str_name, name);
dirfd = opendir("/sys/class/drm");
@@ -610,17 +606,19 @@ float kdk_edid_get_size(char *name)
return 0.00;
}
int fd;
- unsigned char *edid;
char path[512] = "\0";
DIR *dirfd = NULL;
struct dirent *direfd = NULL;
char canonical_filename[100] = "\0";
float size = 0.00;
char filename[100] = "\0";
- // char edid_text[24] = "\0";
char str_name[32] = "\0";
strcpy(str_name, name);
+ FILE *fp = NULL;
+ int num1 = 0;
+ int num2 = 0;
+
dirfd = opendir("/sys/class/drm");
if (!dirfd)
{
@@ -658,75 +656,68 @@ float kdk_edid_get_size(char *name)
return 0.00;
}
fclose(fs);
- FILE *fp = popen("edid-decode /tmp/sdk-edid", "r");
+ fp = popen("edid-decode /tmp/sdk-edid", "r");
if(!fp)
{
closedir(dirfd);
return 0.00;
}
- char *msize = get_val_from_file(fp, "Maximum image size");
- if(!msize)
+
+ }
+ else{
+ char repath[527] = "\0";
+ sprintf(repath, "edid-decode %s", path);
+ fp = popen(repath, "r");
+ if(!fp)
{
closedir(dirfd);
- pclose(fp);
return 0.00;
}
- char *buf[3];
- int i = 0;
- char *p = strtok(msize, "x");
- while (p)
- {
- buf[i] = p;
- i++;
- p = strtok(NULL, "x");
- }
- char fs1[12] = "\0";
- char fs2[12] = "\0";
- strcpy(fs1, buf[0]);
- strcpy(fs2, buf[1]);
- strskipspace(fs1);
- strskipspace(fs2);
- int num1 = 0;
- int num2 = 0;
- sscanf(fs1, "%d", &num1);
- sscanf(fs2, "%d", &num2);
-
- size = sqrt(pow(num1, 2) + pow(num2, 2)) / 2.54;
- free(msize);
+ }
+ char xsize[16] = "\0";
+ char ysize[16] = "\0";
+ char *tmp = get_val_from_file(fp, "Maximum image size");
+ if(!tmp)
+ {
+ printf("test\n");
closedir(dirfd);
pclose(fp);
- return size;
+ return 0.00;
}
- else{
- edid = extract_edid(fd);
- if (!edid)
- {
- goto err_out;
- }
-
- if (!edid || memcmp(edid, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8))
- {
- goto err_out;
- }
- close(fd);
- closedir(dirfd);
+ char *msize = get_val_from_file(fp, "Detailed mode");
+ if(msize)
+ {
+ sscanf(msize, "%*s %*s %*s %s %*s %*s %s", xsize, ysize);
+ num1 = atoi(xsize);
+ num2 = atoi(ysize);
+ size = sqrt(pow(num1, 2) + pow(num2, 2)) / 25.4;
+ free(msize);
+ free(tmp);
+ }
+ else if(tmp)
+ {
+ sscanf(tmp, "%s %*s %*s %s", xsize, ysize);
+ num1 = atoi(xsize);
+ num2 = atoi(ysize);
+ size = sqrt(pow(num1, 2) + pow(num2, 2)) / 2.54;
+ free(tmp);
+ }
+ closedir(dirfd);
+ pclose(fp);
- if (edid[0x15] && edid[0x16])
- {
- size = sqrt(pow(edid[0x15], 2) + pow(edid[0x16], 2)) / 2.54;
- }
- free(edid);
- return size;
+ // greatwall
+ if(!strcmp("24AL60", kdk_edid_get_model(name)))
+ {
+ size = 23.8;
}
-err_out:
- close(fd);
- closedir(dirfd);
- if(edid)
+ // X100
+ if(!strcmp("LM133LF-8L02", kdk_edid_get_model(name)))
{
- free(edid);
+ size = 13.3;
}
- return 0.00;
+
+ return size;
}
char *kdk_edid_get_max_resolution(char *name)
@@ -847,9 +838,7 @@ char *kdk_edid_get_model(char *name)
return NULL;
}
int fd;
- // unsigned char *edid;
char path[512] = "\0";
- char str_path[600] = "\0";
DIR *dirfd = NULL;
struct dirent *direfd = NULL;
char canonical_filename[100] = "\0";
diff --git a/src/net/libkynetinfo.c b/src/net/libkynetinfo.c
index 0ed58ca..672f701 100644
--- a/src/net/libkynetinfo.c
+++ b/src/net/libkynetinfo.c
@@ -865,15 +865,8 @@ char *kdk_net_get_hosts_domain()
return NULL;
}
- char *hosts = (char *)malloc(sizeof(char) * 256);
- if (hosts == NULL)
- {
- fclose(fp);
- return NULL;
- }
- memset(hosts, 0, 256);
char line[4096] = "\0";
- memset(hosts, 0, sizeof(hosts));
+ char strtmp[4096] = "\0";
int i = 0;
int j = 0;
while (fgets(line, sizeof(line), fp))
@@ -896,9 +889,20 @@ char *kdk_net_get_hosts_domain()
}
if((j == 6) && (strlen(line) != 0))
{
- strcat(hosts, line);
+ strcat(strtmp, line);
}
}
+
+ int len = strlen(strtmp);
+
+ char *hosts = (char *)malloc(sizeof(char) * len + 1);
+ if (hosts == NULL)
+ {
+ fclose(fp);
+ return NULL;
+ }
+ memset(hosts, 0, len + 1);
+ strcpy(hosts, strtmp);
fclose(fp);
strstripspace(hosts);
return hosts;
diff --git a/src/proc/libkyprocess.c b/src/proc/libkyprocess.c
index d0c8f59..7e0ad33 100644
--- a/src/proc/libkyprocess.c
+++ b/src/proc/libkyprocess.c
@@ -743,7 +743,7 @@ char *kdk_get_process_start_time(int proc_num)
struct timespec time2 = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &time2);
- starttime = (unsigned long long)(time1 / HZ) + (now - time2.tv_sec);
+ starttime = (unsigned long long)(time1 / HZ) + (now - time2.tv_sec) - 0.1;
time_t time3 = starttime;
diff --git a/src/realtime/libkyrealtimeinfo.c b/src/realtime/libkyrealtimeinfo.c
index 1b68567..fa43baf 100644
--- a/src/realtime/libkyrealtimeinfo.c
+++ b/src/realtime/libkyrealtimeinfo.c
@@ -13,8 +13,8 @@ struct if_data
/* generic interface information */
unsigned int ifi_opackets; /* packets sent on interface */
unsigned int ifi_ipackets; /* packets received on interface */
- unsigned int ifi_obytes; /* total number of octets sent */
unsigned int ifi_ibytes; /* total number of octets received */
+ unsigned int ifi_obytes; /* total number of octets sent */
};
struct if_info
@@ -151,7 +151,7 @@ float kdk_real_get_net_speed(const char *nc)
double kdk_real_get_cpu_temperature()
{
- char tmp[32] = "\0";
+ char tmp[1024] = "\0";
char path[64] = "\0";
for (int i = 0;; i++)
{
@@ -170,14 +170,46 @@ double kdk_real_get_cpu_temperature()
continue;
break;
}
+ double temp = 0.0;
FILE *fp = fopen(path, "r");
if (fp)
{
fgets(tmp, sizeof(tmp), fp);
fclose(fp);
- float temp = atof(tmp);
+ temp = atof(tmp);
return temp < 100 ? temp : temp / 1000;
}
+ if(fabs(temp - 0.0) < 0.000001)
+ {
+ fp = popen("sensors","r");
+ if(fp)
+ {
+ while (fgets(tmp, sizeof(tmp), fp))
+ {
+ if (0 == strncmp(tmp, "Core", 4))
+ {
+ char *pos = tmp, *start = NULL;
+ while (*pos != '+' && *pos != '\0')
+ {
+ pos++;
+ continue;
+ }
+ start = pos++;
+ while (*pos != '\0')
+ {
+ if(*pos == 0xc2 && *(pos + 1) == 0xb0) //字符"°"
+ break;
+ pos++;
+ }
+ *pos = '\0';
+ temp = atof(start);
+ fclose(fp);
+ return temp;
+ }
+ }
+ fclose(fp);
+ }
+ }
return -1;
}

View File

@ -6,3 +6,4 @@
0006-16-fix-bug-184351-184469-update-changelog.patch
0007-update-date.patch
0008-usb.patch
0009-fix-bug-198380-198378-198429-198411-kyrealtime-libky.patch