prepare for new patch list
This commit is contained in:
parent
5dbf258da4
commit
78cdbdda2c
|
@ -1,26 +0,0 @@
|
|||
*.o
|
||||
.vscode
|
||||
build/
|
||||
bin/
|
||||
obj-x86_64-linux-gnu/
|
||||
debian/tmp/
|
||||
debian/files/
|
||||
debian/libkysdk-disk/
|
||||
debian/libkysdk-disk-dev/
|
||||
debian/libkysdk-filesystem/
|
||||
debian/libkysdk-filesystem-dev/
|
||||
debian/libkysdk-hardware/
|
||||
debian/libkysdk-hardware-dev/
|
||||
debian/libkysdk-package/
|
||||
debian/libkysdk-package-dev/
|
||||
debian/libkysdk-proc/
|
||||
debian/libkysdk-proc-dev/
|
||||
debian/libkysdk-sysinfo/
|
||||
debian/libkysdk-sysinfo-dev/
|
||||
debian/libkysdk-system/
|
||||
debian/libkysdk-system-dev/
|
||||
debian/libkysdk-systime/
|
||||
debian/libkysdk-systime-dev/
|
||||
debian/libkysdk*.substvars
|
||||
debian/libkysdk*.debhelper
|
||||
debian/.debhelper
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,29 @@
|
|||
libkysdk-system (1.2.1-ok3) yangtze; urgency=medium
|
||||
libkysdk-system (2.0.0.0) yangtze; urgency=medium
|
||||
|
||||
*Bug号:
|
||||
*需求号:
|
||||
*其他修改:[新增] 新增获取网卡有线无线类型厂家信息、以及模块信息接口
|
||||
[新增] 新增获取bios信息接口
|
||||
[新增] 新增获取主板信息接口
|
||||
[新增] 新增获取网关信息,获取指定端口状态接口
|
||||
[新增] 新增获取系统中usb设备信息接口
|
||||
[新增] 新增获取cpu温度,获取指定硬盘温度,获取瞬时网速接口
|
||||
[新增] 新增获取分辨率接口
|
||||
[新增] 新增根据进程号获取进程信息接口,根据进程名获取进程信息接口,获取进程全部信息接口
|
||||
[修改] 新增获取磁盘信息接口
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Fri, 17 Oct 2022 09:22:40 +0800
|
||||
|
||||
libkysdk-system (1.2.1.1) yangtze; urgency=medium
|
||||
|
||||
*Bug号:134984,134990,125178,133854
|
||||
*需求号:
|
||||
*其他修改:ocr增加RISC-V架构编译
|
||||
control文件指定与base相关包的的依赖版本号
|
||||
|
||||
-- szm-min <shaozhimin@kylinos.cn> Tue, 23 Aug 2022 09:22:40 +0800
|
||||
|
||||
libkysdk-system (1.2.1.0build3test3) yangtze; urgency=medium
|
||||
|
||||
* 【修改】RISC-V架构编译错误
|
||||
|
||||
|
|
|
@ -6,19 +6,21 @@ Build-Depends: debhelper-compat (= 12),
|
|||
cmake,
|
||||
libc6-dev,
|
||||
libsystemd-dev,
|
||||
libcjson-dev,
|
||||
libdbus-1-dev,
|
||||
libdbus-glib-1-dev,
|
||||
libglib2.0-dev,
|
||||
libkysdk-log-dev,
|
||||
libkysdk-config-dev,
|
||||
libkysdk-utils-dev,
|
||||
libkysdk-timer-dev,
|
||||
libkysdk-log-dev(>=1.2.0),
|
||||
libkysdk-config-dev(>=1.2.0),
|
||||
libkysdk-utils-dev(>=1.2.0),
|
||||
libkysdk-timer-dev(>=1.2.0),
|
||||
libqt5core5a,
|
||||
qtbase5-dev,
|
||||
libudev-dev,
|
||||
libopencv-dev,
|
||||
libarchive-dev,
|
||||
libtesseract-dev
|
||||
libtesseract-dev,
|
||||
libxrandr-dev
|
||||
Standards-Version: 4.4.1
|
||||
Homepage: http://gitlab2.kylin.com/kysdk/kysdk-system
|
||||
|
||||
|
@ -38,6 +40,9 @@ Depends: ${shlibs:Depends},
|
|||
systemd,
|
||||
libglib2.0-0,
|
||||
libkysdk-systemcommon,
|
||||
libkysdk-location,
|
||||
libkysdk-net,
|
||||
libkysdk-realtime
|
||||
Multi-Arch: same
|
||||
Description: 麒麟开发者套件 - 系统层套件,提供系统信息、磁盘信息、系统时间等API与服务
|
||||
|
||||
|
@ -55,7 +60,10 @@ Depends: ${shlibs:Depends},
|
|||
libkysdk-proc-dev,
|
||||
libkysdk-hardware-dev,
|
||||
libkysdk-package-dev,
|
||||
libkysdk-powermanagement-dev
|
||||
libkysdk-powermanagement-dev,
|
||||
libkysdk-location-dev,
|
||||
libkysdk-net-dev,
|
||||
libkysdk-realtime-dev
|
||||
Multi-Arch: same
|
||||
Description: 麒麟开发者套件 - 系统层套件 - 开发库,提供系统信息、磁盘信息、系统时间等API与服务
|
||||
|
||||
|
@ -64,7 +72,7 @@ Architecture: any
|
|||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-log,
|
||||
libkysdk-log(>=1.2.0),
|
||||
libkysdk-systemcommon
|
||||
Multi-Arch: same
|
||||
Description: 系统磁盘信息获取库
|
||||
|
@ -75,8 +83,8 @@ Section: utils
|
|||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-disk,
|
||||
libkysdk-log-dev,
|
||||
libkysdk-utils-dev,
|
||||
libkysdk-log-dev(>=1.2.0),
|
||||
libkysdk-utils-dev(>=1.2.0),
|
||||
libblkid-dev,
|
||||
libudev-dev
|
||||
Multi-Arch: same
|
||||
|
@ -87,11 +95,11 @@ Architecture: any
|
|||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-log,
|
||||
libkysdk-log(>=1.2.0),
|
||||
dbus,
|
||||
systemd,
|
||||
libglib2.0-0,
|
||||
libkysdk-timer,
|
||||
libkysdk-timer(>=1.2.0),
|
||||
libkysdk-systemcommon
|
||||
Multi-Arch: same
|
||||
Description: 系统时间相关操作库
|
||||
|
@ -103,7 +111,7 @@ Depends: ${shlibs:Depends},
|
|||
${misc:Depends},
|
||||
libkysdk-systime,
|
||||
libglib2.0-dev,
|
||||
libkysdk-timer-dev
|
||||
libkysdk-timer-dev(>=1.2.0)
|
||||
Multi-Arch: same
|
||||
Description: 系统时间相关操作库 - 开发库
|
||||
|
||||
|
@ -112,10 +120,12 @@ Architecture: any
|
|||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-log,
|
||||
libkysdk-log(>=1.2.0),
|
||||
dbus,
|
||||
libglib2.0-0,
|
||||
systemd,
|
||||
libcjson1,
|
||||
libxrandr2,
|
||||
libkysdk-systemcommon
|
||||
Multi-Arch: same
|
||||
Description: 系统信息获取库
|
||||
|
@ -126,12 +136,14 @@ Section: utils
|
|||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-sysinfo,
|
||||
libkysdk-log-dev,
|
||||
libkysdk-utils-dev,
|
||||
libkysdk-log-dev(>=1.2.0),
|
||||
libkysdk-utils-dev(>=1.2.0),
|
||||
libsystemd-dev,
|
||||
libcjson-dev,
|
||||
libdbus-1-dev,
|
||||
libdbus-glib-1-dev,
|
||||
libglib2.0-dev
|
||||
libglib2.0-dev,
|
||||
libxrandr-dev
|
||||
Multi-Arch: same
|
||||
Description: 系统信息获取库 - 开发库
|
||||
|
||||
|
@ -140,9 +152,9 @@ Architecture: any
|
|||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-log,
|
||||
libkysdk-log(>=1.2.0),
|
||||
libqt5core5a,
|
||||
libkysdk-config,
|
||||
libkysdk-config(>=1.2.0),
|
||||
systemd,
|
||||
libkysdk-systemcommon
|
||||
Multi-Arch: same
|
||||
|
@ -154,8 +166,8 @@ Section: utils
|
|||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-filesystem,
|
||||
libkysdk-log-dev,
|
||||
libkysdk-config-dev,
|
||||
libkysdk-log-dev(>=1.2.0),
|
||||
libkysdk-config-dev(>=1.2.0),
|
||||
libsystemd-dev,
|
||||
qtbase5-dev
|
||||
Multi-Arch: same
|
||||
|
@ -166,8 +178,8 @@ Architecture: any
|
|||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-log,
|
||||
libkysdk-config,
|
||||
libkysdk-log(>=1.2.0),
|
||||
libkysdk-config(>=1.2.0),
|
||||
systemd,
|
||||
libkysdk-systemcommon
|
||||
Multi-Arch: same
|
||||
|
@ -179,8 +191,8 @@ Section: utils
|
|||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-hardware,
|
||||
libkysdk-log-dev,
|
||||
libkysdk-config-dev,
|
||||
libkysdk-log-dev(>=1.2.0),
|
||||
libkysdk-config-dev(>=1.2.0),
|
||||
libsystemd-dev
|
||||
Multi-Arch: same
|
||||
Description: 硬件信息获取库 - 开发库
|
||||
|
@ -226,7 +238,7 @@ Architecture: any
|
|||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-log,
|
||||
libkysdk-log(>=1.2.0),
|
||||
libkysdk-systemcommon
|
||||
Multi-Arch: same
|
||||
Description: 电源管理库
|
||||
|
@ -236,7 +248,7 @@ Architecture: any
|
|||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-log-dev,
|
||||
libkysdk-log-dev(>=1.2.0),
|
||||
libkysdk-powermanagement
|
||||
Multi-Arch: same
|
||||
Description: 电源管理 - 开发库
|
||||
|
@ -269,3 +281,57 @@ Depends: ${shlibs:Depends},
|
|||
${misc:Depends}
|
||||
Multi-Arch: same
|
||||
Description: kysdk-system层公用数据包
|
||||
|
||||
# Package: libkysdk-location
|
||||
# Architecture: any
|
||||
# Section: utils
|
||||
# Depends: ${shlibs:Depends},
|
||||
# ${misc:Depends},
|
||||
# libkysdk-systemcommon,
|
||||
# Multi-Arch: same
|
||||
# Description: 地理位置库
|
||||
|
||||
# Package: libkysdk-location-dev
|
||||
# Architecture: any
|
||||
# Section: utils
|
||||
# Depends: ${shlibs:Depends},
|
||||
# ${misc:Depends},
|
||||
# libkysdk-location
|
||||
# Multi-Arch: same
|
||||
# Description: 地理位置库 - 开发库
|
||||
|
||||
Package: libkysdk-net
|
||||
Architecture: any
|
||||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-systemcommon
|
||||
Multi-Arch: same
|
||||
Description: 网络信息库
|
||||
|
||||
Package: libkysdk-net-dev
|
||||
Architecture: any
|
||||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-net
|
||||
Multi-Arch: same
|
||||
Description: 网络信息库 - 开发库
|
||||
|
||||
Package: libkysdk-realtime
|
||||
Architecture: any
|
||||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-systemcommon
|
||||
Multi-Arch: same
|
||||
Description: 运行时信息库
|
||||
|
||||
Package: libkysdk-realtime-dev
|
||||
Architecture: any
|
||||
Section: utils
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libkysdk-realtime
|
||||
Multi-Arch: same
|
||||
Description: 运行时信息库 - 开发库
|
|
@ -1,3 +1,6 @@
|
|||
usr/include/kysdk/kysdk-system/libkync.h
|
||||
usr/include/kysdk/kysdk-system/libkycpu.h
|
||||
usr/include/kysdk/kysdk-system/libkybios.h
|
||||
usr/include/kysdk/kysdk-system/libkyboard.h
|
||||
usr/include/kysdk/kysdk-system/libkyusb.h
|
||||
development-files/kysdk-hardware.pc usr/share/pkgconfig/
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
usr/include/kysdk/kysdk-system/libkynetinfo.h
|
||||
development-files/kysdk-net.pc usr/share/pkgconfig/
|
|
@ -0,0 +1 @@
|
|||
usr/lib/kysdk/kysdk-system/libkynetinfo.so*
|
|
@ -1,2 +1,3 @@
|
|||
usr/include/kysdk/kysdk-system/libkyrtinfo.h
|
||||
usr/include/kysdk/kysdk-system/libkyprocess.h
|
||||
development-files/kysdk-proc.pc usr/share/pkgconfig/
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
usr/include/kysdk/kysdk-system/libkyrealtimeinfo.h
|
||||
development-files/kysdk-realtime.pc usr/share/pkgconfig/
|
|
@ -0,0 +1 @@
|
|||
usr/lib/kysdk/kysdk-system/libkyrealtime.so*
|
|
@ -1,2 +0,0 @@
|
|||
0001-ocr-RISC-V.patch
|
||||
0002-RISC-V.patch
|
|
@ -1,6 +1,6 @@
|
|||
Name: libkysdk-disk
|
||||
Description: kysdk system layer disk component
|
||||
Requires: kysdk-log kysdk-utils libudev blkid
|
||||
Version: 1.2.0
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkydiskinfo -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -1,6 +1,6 @@
|
|||
Name: libkysdk-filesystem
|
||||
Description: kysdk system layer filesystem component
|
||||
Requires: kysdk-log kysdk-config libsystemd Qt5Core
|
||||
Version: 1.2.0
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkyfilewatcher -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -1,6 +1,6 @@
|
|||
Name: libkysdk-hardware
|
||||
Description: kysdk system layer hardware component
|
||||
Requires: kysdk-log kysdk-config libsystemd
|
||||
Version: 1.2.0
|
||||
Requires: kysdk-log kysdk-config libsystemd libudev1
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkyhw -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -0,0 +1,6 @@
|
|||
Name: libkysdk-location
|
||||
Description: kysdk system layer location
|
||||
Requires:
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkylocation -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -0,0 +1,5 @@
|
|||
Name: libkysdk-net
|
||||
Description: kysdk system layer netinfo
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkynetinfo -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -1,5 +1,5 @@
|
|||
Name: libkysdk-ocr
|
||||
Description: kysdk system ocr package component
|
||||
Version: 1.2.0
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkyocr -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -1,5 +1,5 @@
|
|||
Name: libkysdk-package
|
||||
Description: kysdk system layer package component
|
||||
Version: 1.2.0
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkypackage -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -1,6 +1,6 @@
|
|||
Name: libkysdk-powermanagement
|
||||
Description: kysdk system layer powermanagement component
|
||||
Requires: kysdk-log
|
||||
Version: 1.2.0
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkypowermanagement -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -1,5 +1,5 @@
|
|||
Name: libkysdk-proc
|
||||
Description: kysdk system layer process component
|
||||
Version: 1.2.0
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkyrtinfo -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Name: libkysdk-realtime
|
||||
Description: kysdk system layer realtime
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkyrealtimeinfo -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -1,6 +1,6 @@
|
|||
Name: libkysdk-sysinfo
|
||||
Description: kysdk system layer sysinfo component
|
||||
Requires: kysdk-log kysdk-utils libsystemd dbus-1 dbus-glib-1 gio-2.0 gio-unix-2.0 glib-2.0 gmodule-2.0 gmodule-export-2.0 gmodule-no-export-2.0 gobject-2.0 gthread-2.0
|
||||
Version: 1.2.0
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkysysinfo -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Name: libkysdk-system
|
||||
Description: kysdk system layer
|
||||
Requires: kysdk-disk kysdk-filesystem kysdk-hardware kysdk-package kysdk-proc kysdk-sysinfo
|
||||
Version: 1.2.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkydiskinfo -lkyfilewatcher -lkyhw -lkypackage -lkysysinfo -lkyrtinfo -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Requires: kysdk-disk kysdk-filesystem kysdk-hardware kysdk-package kysdk-proc kysdk-sysinfo kysdk-location kysdk-net kysdk-realtime
|
||||
Version: 2.0.0
|
||||
Libs: -L/usr/lib/kysdk/kysdk-system/ -lkydiskinfo -lkyfilewatcher -lkyhw -lkypackage -lkysysinfo -lkyrtinfo -lkylocation -lkynetinfo -lkyrealtime -Wl,-rpath=/usr/lib/kysdk/kysdk-system/
|
||||
Cflags: -I/usr/include/kysdk/kysdk-system/
|
|
@ -6,17 +6,7 @@ add_subdirectory(proc)
|
|||
add_subdirectory(packages)
|
||||
add_subdirectory(filesystem)
|
||||
add_subdirectory(powermanagement)
|
||||
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
|
||||
add_subdirectory(kdkocr)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
|
||||
add_subdirectory(kdkocr)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64")
|
||||
add_subdirectory(kdkocr)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
||||
add_subdirectory(kdkocr)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64")
|
||||
add_subdirectory(kdkocr)
|
||||
else()
|
||||
message(STATUS "host processor architecture is not supported for ocr")
|
||||
endif()
|
||||
add_subdirectory(kdkocr)
|
||||
add_subdirectory(location)
|
||||
add_subdirectory(net)
|
||||
add_subdirectory(realtime)
|
|
@ -1,6 +1,6 @@
|
|||
aux_source_directory(. SOURCESCODE)
|
||||
add_library(kydiskinfo SHARED ${SOURCESCODE})
|
||||
set_target_properties(kydiskinfo PROPERTIES VERSION 1.2.0 SOVERSION 1)
|
||||
set_target_properties(kydiskinfo PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
add_executable(test-getdiskinfo test/getdiskinfo.c)
|
||||
add_executable(test-getdisklist test/getdisklist.c)
|
||||
find_library(UDEV_LIB udev)
|
||||
|
|
|
@ -141,28 +141,34 @@ static int get_disk_identifier(int fd, kdk_diskinfo *di)
|
|||
klog_warning("ioctl 执行失败:%s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *model = strndup((char*)&hd[27], 40);
|
||||
// char *fwrev = strndup(&hd[23], 8); // 固件版本
|
||||
char *fwrev = strndup(&hd[23], 8); // 固件版本
|
||||
char *serno = strndup((char*)&hd[10], 20);
|
||||
|
||||
di->serial = malloc(strlen(serno) + 1);
|
||||
di->model = malloc(strlen(model) + 1);
|
||||
if (! di->serial || ! di->model)
|
||||
di->fwrev = malloc(strlen(fwrev) + 1);
|
||||
if (! di->serial || ! di->model || !di->fwrev)
|
||||
{
|
||||
klog_emerg("内存分配失败:%s\n", strerror(errno));
|
||||
SAFE_FREE(model);
|
||||
SAFE_FREE(serno);
|
||||
SAFE_FREE(fwrev);
|
||||
return KDK_ENOMEM;
|
||||
}
|
||||
|
||||
strcpy(di->serial, serno);
|
||||
strcpy(di->model, model);
|
||||
strcpy(di->fwrev, fwrev);
|
||||
|
||||
strstripspace(di->serial);
|
||||
strstripspace(di->model);
|
||||
strstripspace(di->fwrev);
|
||||
|
||||
SAFE_FREE(model);
|
||||
SAFE_FREE(serno);
|
||||
SAFE_FREE(fwrev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -270,6 +276,8 @@ static int get_disk_type(kdk_diskinfo *di)
|
|||
}
|
||||
|
||||
// 获取转速信息(固态除外)
|
||||
|
||||
|
||||
|
||||
out:
|
||||
return 0;
|
||||
|
@ -458,7 +466,20 @@ kdk_diskinfo *kdk_get_diskinfo(const char *diskname)
|
|||
klog_err("No disk MODEL info matched :%s\n",diskname);
|
||||
}
|
||||
|
||||
|
||||
const char *p_name = res->name;
|
||||
res->fwrev = (char *)malloc(FWREV_SIZE * sizeof(char));
|
||||
p_name += strlastof(p_name, '/');
|
||||
char syspath[PATH_MAX];
|
||||
sprintf(syspath, "/sys/block/%s/device/firmware_rev", p_name);
|
||||
int tfd = open(syspath, O_RDONLY);
|
||||
if (tfd <= 0)
|
||||
{
|
||||
strcpy(res->fwrev, "None");
|
||||
}else{
|
||||
char buf[10] = {0};
|
||||
read(tfd, buf, FWREV_SIZE);
|
||||
strcpy(res->fwrev, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (get_disk_space(fd, res))
|
||||
|
@ -471,7 +492,10 @@ kdk_diskinfo *kdk_get_diskinfo(const char *diskname)
|
|||
goto err_out;
|
||||
}
|
||||
|
||||
if (get_disk_type)
|
||||
if (get_disk_type(res))
|
||||
{
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
out:
|
||||
close(fd);
|
||||
|
@ -491,5 +515,6 @@ void kdk_free_diskinfo(kdk_diskinfo *disk)
|
|||
SAFE_FREE(disk->vendor);
|
||||
SAFE_FREE(disk->model);
|
||||
SAFE_FREE(disk->mount_path);
|
||||
SAFE_FREE(disk->fwrev);
|
||||
SAFE_FREE(disk);
|
||||
}
|
|
@ -5,6 +5,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FWREV_SIZE 20
|
||||
|
||||
typedef enum _kdk_disk_type{
|
||||
DISK_TYPE_HDD, // 机械
|
||||
DISK_TYPE_SSD, // 固态
|
||||
|
@ -66,6 +68,7 @@ typedef struct _kdk_diskinfo{
|
|||
char *mount_path; // 挂载路径
|
||||
kdk_disk_format format; // 格式化类型
|
||||
kdk_disk_partition_type part_type; // 分区类型
|
||||
char *fwrev; //固件版本信息
|
||||
|
||||
}kdk_diskinfo;
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ static void display_disk_info(kdk_diskinfo *di)
|
|||
printf("Disk Model:\t%s\n", di->model ? di->model : "None");
|
||||
printf("Disk Serial:\t%s\n", di->serial ? di->serial : "None");
|
||||
printf("Disk Partition Number:\t%u\n", di->partition_nums);
|
||||
printf("Disk Type:\t%d\n", di->disk_type);
|
||||
printf("Disk fwrev:\t%s\n", di->fwrev);
|
||||
}
|
||||
|
||||
static void display_disk_list(char **disklist)
|
||||
|
|
|
@ -5,7 +5,7 @@ aux_source_directory(. SOURCECODE)
|
|||
find_package(Qt5Core)
|
||||
include_directories(${Qt5Core_INCLUDE_DIRS})
|
||||
add_library(kyfilewatcher SHARED ${SOURCECODE})
|
||||
set_target_properties(kyfilewatcher PROPERTIES VERSION 1.2.0 SOVERSION 1)
|
||||
set_target_properties(kyfilewatcher PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
add_executable(kyfilewatcher-test test/kyfilewatcher-test.cpp)
|
||||
target_link_libraries(kyfilewatcher kylog kyconf systemd pthread ${Qt5Core_LIBRARIES})
|
||||
target_link_libraries(kyfilewatcher-test kyfilewatcher)
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
aux_source_directory(. SOURCESCODE)
|
||||
include_directories(.)
|
||||
add_library(kyhw SHARED ${SOURCESCODE})
|
||||
set_target_properties(kyhw PROPERTIES VERSION 1.2.0 SOVERSION 1)
|
||||
set_target_properties(kyhw PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
add_executable(kync-test test/kync-test.c)
|
||||
add_executable(kycpu-test test/kycpu-test.c)
|
||||
target_link_libraries(kyhw kylog kyconf pthread systemd)
|
||||
add_executable(kyusb-test test/kyusb-test.c)
|
||||
add_executable(kybios-test test/kybios-test.c)
|
||||
add_executable(kyboard-test test/kyboard-test.c)
|
||||
target_link_libraries(kyhw kylog kyconf pthread systemd udev)
|
||||
target_link_libraries(kync-test kyhw)
|
||||
target_link_libraries(kycpu-test kyhw)
|
||||
target_link_libraries(kyusb-test kyhw)
|
||||
target_link_libraries(kybios-test kyhw)
|
||||
target_link_libraries(kyboard-test kyhw)
|
||||
|
||||
install(TARGETS kyhw
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
@ -15,4 +21,13 @@ install(FILES libkync.h
|
|||
DESTINATION include/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkycpu.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkybios.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkyboard.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkyusb.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
|
@ -0,0 +1,33 @@
|
|||
#include "libkybios.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
const char *kdk_bios_get_vendor()
|
||||
{
|
||||
char *vendor = (char *)calloc(32,sizeof(char));
|
||||
FILE *fd = fopen("/sys/class/dmi/id/bios_vendor","r");
|
||||
if(fd)
|
||||
{
|
||||
fgets(vendor,32,fd);
|
||||
fclose(fd);
|
||||
}
|
||||
return vendor;
|
||||
}
|
||||
|
||||
const char *kdk_bios_get_version()
|
||||
{
|
||||
char *version = (char *)calloc(32,sizeof(char));
|
||||
FILE *fd = fopen("/sys/class/dmi/id/bios_version","r");
|
||||
if(fd)
|
||||
{
|
||||
fgets(version,32,fd);
|
||||
fclose(fd);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
void kdk_bios_free(char* info)
|
||||
{
|
||||
free(info);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef LIBKYBIOSINFO_H
|
||||
#define LIBKYBIOSINFO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern const char *kdk_bios_get_vendor();
|
||||
|
||||
extern const char *kdk_bios_get_version();
|
||||
|
||||
extern void kdk_bios_free(char *info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
#include "libkyboard.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
const char *kdk_board_get_name()
|
||||
{
|
||||
char *name = (char *)calloc(32,sizeof(char));
|
||||
FILE *fd = fopen("/sys/class/dmi/id/board_name","r");
|
||||
if(fd)
|
||||
{
|
||||
fgets(name,32,fd);
|
||||
fclose(fd);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *kdk_board_get_date()
|
||||
{
|
||||
char *date = (char *)calloc(32,sizeof(char));
|
||||
FILE *fd = fopen("/sys/class/dmi/id/bios_date","r");
|
||||
if(fd)
|
||||
{
|
||||
fgets(date,32,fd);
|
||||
fclose(fd);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
const char *kdk_board_get_serial()
|
||||
{
|
||||
char *serial = (char *)calloc(32,sizeof(char));
|
||||
FILE *fd = fopen("/sys/class/dmi/id/board_serial","r");
|
||||
if(fd)
|
||||
{
|
||||
fgets(serial,32,fd);
|
||||
fclose(fd);
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
|
||||
const char *kdk_board_get_vendor()
|
||||
{
|
||||
char *vendor = (char *)calloc(32,sizeof(char));
|
||||
FILE *fd = fopen("/sys/class/dmi/id/board_vendor","r");
|
||||
if(fd)
|
||||
{
|
||||
fgets(vendor,32,fd);
|
||||
fclose(fd);
|
||||
}
|
||||
return vendor;
|
||||
}
|
||||
|
||||
void kdk_board_free(char* info)
|
||||
{
|
||||
free(info);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef LIBKYBOARDINFO_H
|
||||
#define LIBKYBOARDINFO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern const char *kdk_board_get_name();
|
||||
|
||||
extern const char *kdk_board_get_date();
|
||||
|
||||
extern const char *kdk_board_get_serial();
|
||||
|
||||
extern const char *kdk_board_get_vendor();
|
||||
|
||||
extern void kdk_board_free(char *info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -15,6 +15,7 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <unistd.h>
|
||||
|
||||
enum cardspec{
|
||||
NCSPEC_ALL,
|
||||
|
@ -38,6 +39,8 @@ enum cardcfg{
|
|||
|
||||
#define NC_IPv4_SIZE 16
|
||||
#define NC_MAC_SIZE 18
|
||||
#define SIOCGIWNAME 0x8B01
|
||||
#define PCIID_PATH "/usr/share/misc/pci.ids"
|
||||
|
||||
static enum cardstat _get_card_stat(const char *nc)
|
||||
{
|
||||
|
@ -313,6 +316,82 @@ char* kdk_nc_get_private_ipv6(const char *nc)
|
|||
return ipv6;
|
||||
}
|
||||
|
||||
int kdk_nc_is_wireless(const char *nc)
|
||||
{
|
||||
char buffer[2 * IFNAMSIZ + 1];
|
||||
int fd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
strncpy(buffer, nc, sizeof(buffer));
|
||||
return ioctl(fd, SIOCGIWNAME, &buffer) == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
int kdk_nc_get_vendor_and_product(const char *nc, char *vendor, char *product)
|
||||
{
|
||||
char filename[64] = "0";
|
||||
sprintf(filename, "/sys/class/net/%s/device", nc);
|
||||
if (0 != access(filename, F_OK))
|
||||
return -1; //非物理网卡,可能是逻辑网卡如 lo: 本地环回
|
||||
FILE *fp = NULL;
|
||||
char vendorId[64] = "0";
|
||||
char productId[64] = "0";
|
||||
strcpy(vendorId, filename);
|
||||
strcpy(productId, filename);
|
||||
//读厂家id
|
||||
if (NULL != (fp = fopen(strcat(vendorId, "/vendor"), "r")))
|
||||
{
|
||||
fgets(vendorId, sizeof(vendorId), fp);
|
||||
fclose(fp);
|
||||
}
|
||||
//读设备id
|
||||
if (NULL != (fp = fopen(strcat(productId, "/device"), "r")))
|
||||
{
|
||||
fgets(productId, sizeof(vendorId), fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
long u[4]; // 0,1存储网卡的厂家和设备ID,2,3存储pci.ids文件读到的ID
|
||||
memset(u, 0, sizeof(u));
|
||||
sscanf(vendorId, "%lx", &u[0]);
|
||||
sscanf(productId, "%lx", &u[1]);
|
||||
|
||||
char line[512] = "0";
|
||||
if (NULL != (fp = fopen(PCIID_PATH, "r")))
|
||||
{
|
||||
long unsigned int level = 0;
|
||||
while (fgets(line, sizeof(line), fp))
|
||||
{
|
||||
// 忽略空行和注释
|
||||
if (strlen(line) == 0 || line[0] == '#')
|
||||
continue;
|
||||
|
||||
//行前无制表符代表厂家id,一个制表符代表设备id
|
||||
level = 0;
|
||||
while (level < strlen(line) && line[level] == '\t')
|
||||
level++;
|
||||
//获取厂家名称
|
||||
if (0 == level)
|
||||
{
|
||||
sscanf(line, "%lx", &u[2]);
|
||||
if (u[0] == u[2])
|
||||
strcpy(vendor, line + level + 6);
|
||||
}
|
||||
//在对应的厂家id下查找设备id
|
||||
if (1 == level && u[0] == u[2])
|
||||
{
|
||||
sscanf(line, "%lx", &u[3]);
|
||||
if (u[1] == u[3])
|
||||
{
|
||||
strcpy(product, line + level + 6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void kdk_nc_freeall(char **list)
|
||||
{
|
||||
if (! list)
|
||||
|
|
|
@ -72,6 +72,24 @@ extern char** kdk_nc_get_ipv4(const char* nc);
|
|||
*/
|
||||
extern char* kdk_nc_get_private_ipv6(const char *nc);
|
||||
|
||||
/**
|
||||
* @brief 获取指定网卡的有线/无线类型
|
||||
*
|
||||
* @param nc 网卡名称,如eno1
|
||||
* @return int 0 有线 1 无线
|
||||
*/
|
||||
extern int kdk_nc_is_wireless(const char *nc);
|
||||
|
||||
/**
|
||||
* @brief 获取指定网卡的厂商名称和设备型号
|
||||
*
|
||||
* @param nc 网卡名称,如eno1
|
||||
* @param vendor 网卡制造厂商,出参,需要提前分配好空足够空间
|
||||
* @param porduct 网卡型号,出参,需要提前分配好空足够空间
|
||||
* @return int 成功返回 0 失败返回 -1
|
||||
*/
|
||||
extern int kdk_nc_get_vendor_and_product(const char *nc, char *vendor, char *product);
|
||||
|
||||
/**
|
||||
* @brief 获取指定网卡的所有IPv6地址
|
||||
*
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
#include "libkyusb.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <libudev.h>
|
||||
|
||||
/// @brief
|
||||
/// @return usb device info
|
||||
pDriverInfoList kdk_usb_get_list()
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_enumerate *enumerate;
|
||||
struct udev_list_entry *list_entry, *dev_list_entry;
|
||||
struct udev_device *dev, *device, *interface;
|
||||
|
||||
pDriverInfoList list = NULL;
|
||||
pDriverInfoList prevnode = NULL;
|
||||
pDriverInfoList curnode = NULL;
|
||||
|
||||
/* Create the udev object */
|
||||
udev = udev_new();
|
||||
if (!udev)
|
||||
{
|
||||
printf("Can't create udev");
|
||||
return list;
|
||||
}
|
||||
|
||||
/*enum devices*/
|
||||
enumerate = udev_enumerate_new(udev);
|
||||
|
||||
// 添加筛选条件 普通usb设备路径/sys/class/hidraw,U盘路径/sys/class/block
|
||||
// udev_enumerate_add_match_subsystem(enumerate, "hidraw");
|
||||
// udev_enumerate_add_match_subsystem(enumerate, "block");
|
||||
|
||||
//扫描设备
|
||||
udev_enumerate_scan_devices(enumerate);
|
||||
|
||||
//获取设备列表
|
||||
list_entry = udev_enumerate_get_list_entry(enumerate);
|
||||
//遍历
|
||||
udev_list_entry_foreach(dev_list_entry, list_entry)
|
||||
{
|
||||
const char *path;
|
||||
|
||||
//创建dev_device设备对象
|
||||
path = udev_list_entry_get_name(dev_list_entry);
|
||||
device = udev_device_new_from_syspath(udev, path);
|
||||
if(!device)
|
||||
{
|
||||
kdk_usb_free(list);
|
||||
break;
|
||||
}
|
||||
|
||||
//获取interface父节点,此节点记录设备类型
|
||||
interface = udev_device_get_parent_with_subsystem_devtype(device, "usb", "usb_interface");
|
||||
if (!interface)
|
||||
{
|
||||
goto free;
|
||||
}
|
||||
|
||||
//非usb设备直接进入下一轮循环
|
||||
dev = udev_device_get_parent_with_subsystem_devtype(device, "usb", "usb_device");
|
||||
if (!dev)
|
||||
{
|
||||
goto free;
|
||||
}
|
||||
|
||||
//同一款外设会生成两个设备文件,原因不明。暂时先手动去重
|
||||
pDriverInfoList tmp = list;
|
||||
int isRepetive = 0;
|
||||
while (tmp)
|
||||
{
|
||||
if(0 == strcmp(tmp->data->devNode,udev_device_get_devnode(dev)))
|
||||
{
|
||||
isRepetive = 1;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if(isRepetive)
|
||||
{
|
||||
goto free;
|
||||
}
|
||||
|
||||
//申请节点内存
|
||||
if(NULL == list)
|
||||
{
|
||||
list = (pDriverInfoList)calloc(1, sizeof(DriverInfoList));
|
||||
curnode = list;
|
||||
}
|
||||
else
|
||||
curnode = (pDriverInfoList)calloc(1, sizeof(DriverInfoList));
|
||||
|
||||
if (NULL == curnode)
|
||||
{
|
||||
printf("Request Memory For List Failed");
|
||||
kdk_usb_free(list);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
curnode->data = (pDriverInfo)calloc(1, sizeof(DriverInfo));
|
||||
if (NULL == curnode->data)
|
||||
{
|
||||
printf("Request Memory For Data Failed");
|
||||
kdk_usb_free(list);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sprintf(curnode->data->name, "%s", udev_device_get_sysattr_value(dev, "product"));
|
||||
sprintf(curnode->data->type, "%s", udev_device_get_sysattr_value(interface, "bInterfaceClass"));
|
||||
sprintf(curnode->data->pid, "%s", udev_device_get_sysattr_value(dev, "idProduct"));
|
||||
sprintf(curnode->data->vid, "%s", udev_device_get_sysattr_value(dev, "idVendor"));
|
||||
sprintf(curnode->data->serialNo, "%s", udev_device_get_sysattr_value(dev, "serial"));
|
||||
sprintf(curnode->data->devNode ,"%s", udev_device_get_devnode(dev));
|
||||
// sprintf(curnode->data->vendor, "%s", udev_device_get_sysattr_value(dev, "manufacturer"));
|
||||
|
||||
if (NULL != prevnode)
|
||||
prevnode->next = curnode;
|
||||
prevnode = curnode;
|
||||
curnode = NULL;
|
||||
free:
|
||||
if(device)
|
||||
udev_device_unref(device);
|
||||
}
|
||||
udev_enumerate_unref(enumerate);
|
||||
udev_unref(udev);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void kdk_usb_free(pDriverInfoList list)
|
||||
{
|
||||
pDriverInfoList tmp = NULL;
|
||||
while (list)
|
||||
{
|
||||
tmp = list;
|
||||
list = list->next;
|
||||
free(tmp->data);
|
||||
free(tmp);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef LIBKYUSBINFO_H
|
||||
#define LIBKYUSBINFO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* usb设备信息
|
||||
*/
|
||||
typedef struct driver_info
|
||||
{
|
||||
char name[32];
|
||||
char type[2 + 1];
|
||||
char pid[4 + 1];
|
||||
char vid[4 + 1];
|
||||
char serialNo[32];
|
||||
char devNode[32];
|
||||
} DriverInfo, *pDriverInfo;
|
||||
|
||||
/*
|
||||
* usb设备信息链表
|
||||
*/
|
||||
typedef struct driver_list
|
||||
{
|
||||
struct driver_info *data;
|
||||
struct driver_list *next;
|
||||
} DriverInfoList, *pDriverInfoList;
|
||||
|
||||
extern pDriverInfoList kdk_usb_get_list();
|
||||
|
||||
extern void kdk_usb_free(pDriverInfoList list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
#include "stdio.h"
|
||||
#include "../libkybios.h"
|
||||
int main()
|
||||
{
|
||||
printf("vendor: %s",kdk_bios_get_vendor());
|
||||
printf("version: %s",kdk_bios_get_version());
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#include "stdio.h"
|
||||
#include "../libkyboard.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("name : %s", kdk_board_get_name());
|
||||
printf("vendor : %s", kdk_board_get_vendor());
|
||||
printf("date : %s", kdk_board_get_date());
|
||||
printf("serial : %s", kdk_board_get_serial());
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#include "stdio.h"
|
||||
#include "../libkyusb.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
pDriverInfoList list = kdk_usb_get_list();
|
||||
if(list)
|
||||
{
|
||||
pDriverInfoList tmp = list;
|
||||
while (tmp)
|
||||
{
|
||||
printf("Name: %s\t",tmp->data->name);
|
||||
printf("Class: %s\t",tmp->data->type);
|
||||
printf("PID: %s\t",tmp->data->pid);
|
||||
printf("VID: %s\t",tmp->data->vid);
|
||||
printf("Serial: %s\t",tmp->data->serialNo);
|
||||
printf("DevNode: %s\n",tmp->data->devNode);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
|
||||
}
|
||||
kdk_usb_free(list);
|
||||
return 0;
|
||||
}
|
|
@ -68,8 +68,12 @@ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libs/amd64/paddle_inference/paddle/li
|
|||
add_definitions(-DLOONGARCH64)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
||||
add_definitions(-DLOONGARCH64)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "riscv64")
|
||||
add_definitions(-DLOONGARCH64)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64")
|
||||
add_definitions(-DLOONGARCH64)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "armv8l")
|
||||
add_definitions(-DLOONGARCH64)
|
||||
else()
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i386")
|
||||
message(STATUS "i386 architecture detected")
|
||||
|
@ -181,11 +185,21 @@ elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64")
|
|||
add_library(kyocr SHARED libkyocr.cpp)
|
||||
target_link_libraries(kyocr ${kyocr_libraries})
|
||||
target_compile_options(kyocr PUBLIC ${kyocr_cflags})
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "riscv64")
|
||||
message(loongarch64)
|
||||
add_library(kyocr SHARED libkyocr.cpp)
|
||||
target_link_libraries(kyocr ${kyocr_libraries})
|
||||
target_compile_options(kyocr PUBLIC ${kyocr_cflags})
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "armv8l")
|
||||
message(loongarch64)
|
||||
add_library(kyocr SHARED libkyocr.cpp)
|
||||
target_link_libraries(kyocr ${kyocr_libraries})
|
||||
target_compile_options(kyocr PUBLIC ${kyocr_cflags})
|
||||
else()
|
||||
add_library(kyocr SHARED libkyocr.cpp ocr_main.cpp utility.cpp preprocess_op.cpp postprocess_op.cpp)
|
||||
target_link_libraries(kyocr ${OpenCV_LIBS} ${DEPS})
|
||||
endif()
|
||||
set_target_properties(kyocr PROPERTIES VERSION 1.2.0 SOVERSION 1)
|
||||
set_target_properties(kyocr PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
#target_link_libraries(kdkOCR -lleptonica)
|
||||
|
||||
|
||||
|
@ -205,9 +219,13 @@ elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64")
|
|||
install(FILES ${PROJECT_SOURCE_DIR}/libs/mips64el/paddle_inference/paddle/lib/libpaddle_inference.so DESTINATION lib/)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/libs/libpaddle_inference DESTINATION lib/libpaddle_inference.so)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "riscv64")
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/libs/libpaddle_inference DESTINATION lib/libpaddle_inference.so)
|
||||
# install(FILES ${PROJECT_SOURCE_DIR}/libs/loongarch64/paddle_inference/paddle/lib/libpaddle_inference.so DESTINATION lib/)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "sw_64")
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/libs/libpaddle_inference DESTINATION lib/libpaddle_inference.so)
|
||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "armv8l")
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/libs/libpaddle_inference DESTINATION lib/libpaddle_inference.so)
|
||||
# install(FILES ${PROJECT_SOURCE_DIR}/libs/sw64/paddle_inference/paddle/lib/libpaddle_inference.so DESTINATION lib/)
|
||||
endif()
|
||||
#target_link_libraries(test libkdkOCR.so)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
# include_directories("/usr/include/python3.8")
|
||||
# add_library(kylocation SHARED libkylocation.c)
|
||||
# set_target_properties(kylocation PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
# target_link_libraries(kylocation -lpython3.8)
|
||||
# add_executable(kylocation-test test/kylocation-test.c)
|
||||
# target_link_libraries(kylocation-test kylocation)
|
||||
|
||||
# install(TARGETS kylocation
|
||||
# DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
# install(FILES libkylocation.h
|
||||
# DESTINATION include/kysdk/kysdk-system)
|
|
@ -0,0 +1,46 @@
|
|||
#include "Python.h"
|
||||
|
||||
char *kdk_loaction_get()
|
||||
{
|
||||
char *location = NULL;
|
||||
Py_Initialize();
|
||||
|
||||
//相当于在python中的import sys语句。这个函数相当于直接运行python语句
|
||||
PyRun_SimpleString("import sys");
|
||||
|
||||
//是将搜索路径设置为当前目录。
|
||||
PyRun_SimpleString("sys.path.append('/usr/lib/kysdk/kysdk-system')");
|
||||
// PyRun_SimpleString("from location import getAddress");
|
||||
// PyRun_SimpleString("print(getAddress())");
|
||||
|
||||
PyObject *pModule = NULL;
|
||||
PyObject *pFunc = NULL;
|
||||
PyObject *pResult = NULL;
|
||||
|
||||
pModule = PyImport_ImportModule("location");
|
||||
if (!pModule)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
pFunc = PyObject_GetAttrString(pModule, "getAddress");
|
||||
;
|
||||
if (!pFunc || !PyCallable_Check(pFunc))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
pResult = PyObject_CallObject(pFunc, NULL);
|
||||
if (!pResult)
|
||||
{
|
||||
char tmp[64] = "\0";
|
||||
FILE *fp = popen("curl cip.cc","r");
|
||||
fgets(tmp,sizeof(tmp),fp);
|
||||
if(fgets(tmp,sizeof(tmp),fp))
|
||||
location = (char *)tmp;
|
||||
return location;
|
||||
}
|
||||
PyArg_Parse(pResult, "s", &location);
|
||||
Py_DECREF(pFunc);
|
||||
Py_DECREF(pModule);
|
||||
Py_Finalize();
|
||||
return location;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef LIBKYLOCATION_H
|
||||
#define LIBKYLOCATION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern char *kdk_loaction_get();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
#!/usr/bin/env python3
|
||||
import re
|
||||
import json
|
||||
import requests
|
||||
from urllib.request import urlopen
|
||||
|
||||
def getaddr():
|
||||
text = str(urlopen("http://txt.go.sohu.com/ip/soip").read())
|
||||
ip = re.findall(r'\d+.\d+.\d+.\d+',text)
|
||||
return ip[0]
|
||||
|
||||
def getAddress():
|
||||
url = "http://api.map.baidu.com/location/ip"
|
||||
myParams = {"ak":"4DPAeozisfSCUgSLuC14Ux4iXjeEYNGa","ip":getaddr(),"coor":"bd09ll"}
|
||||
res = requests.get(url=url,params=myParams)
|
||||
decoded_u = res.text.encode('utf-8').decode('unicode_escape')
|
||||
data = json.loads(decoded_u)
|
||||
if data["status"] == 0 :
|
||||
return decoded_u
|
||||
else:
|
||||
return data["message"]
|
|
@ -0,0 +1,8 @@
|
|||
#include "stdio.h"
|
||||
#include "../libkylocation.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("location: %s", kdk_loaction_get());
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
aux_source_directory(. CODE)
|
||||
add_library(kynetinfo SHARED ${CODE})
|
||||
set_target_properties(kynetinfo PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_executable(kynet-test test/kynet-test.c)
|
||||
target_link_libraries(kynet-test kynetinfo)
|
||||
|
||||
install(TARGETS kynetinfo
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkynetinfo.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
|
@ -0,0 +1,164 @@
|
|||
#include "libkynetinfo.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <linux/route.h>
|
||||
static void parse_port_state(int *st, int port, FILE *fp)
|
||||
{
|
||||
char line[1024] = "\0";
|
||||
int lnr = 0;
|
||||
unsigned long rxq, txq, time_len, retr, inode;
|
||||
int num, local_port, rem_port, d, state, uid, timer_run, timeout;
|
||||
char rem_addr[128] = "0", local_addr[128] = "0";
|
||||
struct sockaddr_storage localsas, remsas;
|
||||
struct sockaddr_in *localaddr = (struct sockaddr_in *)&localsas;
|
||||
struct sockaddr_in *remaddr = (struct sockaddr_in *)&remsas;
|
||||
|
||||
#if HAVE_AFINET6
|
||||
char addr6[INET6_ADDRSTRLEN];
|
||||
struct in6_addr in6;
|
||||
extern struct aftype inet6_aftype;
|
||||
#endif
|
||||
|
||||
while (fgets(line, 1024, fp))
|
||||
{
|
||||
if (lnr++ == 0)
|
||||
continue;
|
||||
num = sscanf(line,
|
||||
"%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %*s\n",
|
||||
&d, local_addr, &local_port, rem_addr, &rem_port, &state,
|
||||
&txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode);
|
||||
if (local_port == port)
|
||||
{
|
||||
*st = state;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strlen(local_addr) > 8)
|
||||
{
|
||||
#if HAVE_AFINET6
|
||||
/* Demangle what the kernel gives us */
|
||||
sscanf(local_addr, "%08X%08X%08X%08X",
|
||||
&in6.s6_addr32[0], &in6.s6_addr32[1],
|
||||
&in6.s6_addr32[2], &in6.s6_addr32[3]);
|
||||
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
|
||||
inet6_aftype.input(1, addr6, &localsas);
|
||||
sscanf(rem_addr, "%08X%08X%08X%08X",
|
||||
&in6.s6_addr32[0], &in6.s6_addr32[1],
|
||||
&in6.s6_addr32[2], &in6.s6_addr32[3]);
|
||||
inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
|
||||
inet6_aftype.input(1, addr6, &remsas);
|
||||
localsas.ss_family = AF_INET6;
|
||||
remsas.ss_family = AF_INET6;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
sscanf(local_addr, "%X", &localaddr->sin_addr.s_addr);
|
||||
sscanf(rem_addr, "%X", &remaddr->sin_addr.s_addr);
|
||||
localsas.ss_family = AF_INET;
|
||||
remsas.ss_family = AF_INET;
|
||||
}
|
||||
}
|
||||
|
||||
int kdk_net_get_port_stat(int port)
|
||||
{
|
||||
FILE *fp = fopen("/proc/net/tcp", "r");
|
||||
if (!fp)
|
||||
return -1;
|
||||
int state = 0;
|
||||
parse_port_state(&state, port, fp);
|
||||
|
||||
fp = fopen("/proc/net/tcp6", "r");
|
||||
if (!fp)
|
||||
return -1;
|
||||
parse_port_state(&state, port, fp);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
prouteMapList kdk_net_get_route()
|
||||
{
|
||||
prouteMapList list = NULL, currnode = NULL, prenode = NULL;
|
||||
FILE *fp;
|
||||
char devname[64];
|
||||
unsigned long d, g, m;
|
||||
int r;
|
||||
int flgs, ref, use, metric, mtu, win, ir;
|
||||
|
||||
fp = fopen("/proc/net/route", "r");
|
||||
|
||||
/* Skip the first line. */
|
||||
r = fscanf(fp, "%*[^\n]\n");
|
||||
|
||||
if (r < 0)
|
||||
{
|
||||
/* Empty line, read error, or EOF. Yes, if routing table
|
||||
* is completely empty, /proc/net/route has no header.
|
||||
*/
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n",
|
||||
devname, &d, &g, &flgs, &ref, &use, &metric, &m,
|
||||
&mtu, &win, &ir);
|
||||
|
||||
if (r != 11)
|
||||
{
|
||||
if ((r < 0) && feof(fp))
|
||||
{
|
||||
/* EOF with no (nonspace) chars read. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* # cat /proc/net/route
|
||||
* Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
|
||||
* eth0 00000000 013CA8C0 0003 0 0 0 00000000 0 0 0
|
||||
* eth0 003CA8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
|
||||
* 默认网关的特性: dst为0,netmask为0, Gateway不为0
|
||||
*/
|
||||
if ((flgs & (RTF_GATEWAY | RTF_UP)) &&
|
||||
g != 0 && d == 0 && m == 0)
|
||||
{
|
||||
currnode = (prouteMapList)calloc(1, sizeof(routeMapList));
|
||||
if (!currnode)
|
||||
{
|
||||
kdk_net_free_route(list);
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
struct sockaddr_in sin;
|
||||
memset(&sin, 0, sizeof(struct sockaddr_in));
|
||||
memcpy(&sin.sin_addr, &g, 4);
|
||||
strcpy(currnode->name, devname);
|
||||
strcpy(currnode->addr, inet_ntoa(sin.sin_addr));
|
||||
|
||||
if (!list)
|
||||
prenode = list = currnode;
|
||||
else
|
||||
prenode->next = currnode;
|
||||
prenode = prenode->next;
|
||||
}
|
||||
}
|
||||
|
||||
ERROR:
|
||||
fclose(fp);
|
||||
return list;
|
||||
}
|
||||
|
||||
void kdk_net_free_route(prouteMapList list)
|
||||
{
|
||||
prouteMapList tmp = NULL;
|
||||
while (list)
|
||||
{
|
||||
tmp = list;
|
||||
list = list->next;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef LIBKYNETINFO_H
|
||||
#define LIBKYNETINFO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct route
|
||||
{
|
||||
char name[8];
|
||||
char addr[16];
|
||||
struct route *next;
|
||||
} routeMapList, *prouteMapList;
|
||||
|
||||
/// @brief 获取指定网络端口的状态
|
||||
/// @param port : 端口号
|
||||
/// @return 端口状态 TCP_ESTABLISHED:0x1 TCP_SYN_SENT:0x2 TCP_SYN_RECV:0x3 TCP_FIN_WAIT1:0x4 TCP_FIN_WAIT2:0x5 \
|
||||
TCP_TIME_WAIT:0x6 TCP_CLOSE:0x7 TCP_CLOSE_WAIT:0x8 TCP_LAST_ACL:0x9 TCP_LISTEN:0xa TCP_CLOSING:0xb
|
||||
extern int kdk_net_get_port_stat(int port);
|
||||
|
||||
extern prouteMapList kdk_net_get_route();
|
||||
|
||||
extern void kdk_net_free_route(prouteMapList list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,18 @@
|
|||
#include "../libkynetinfo.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
prouteMapList list = kdk_net_get_route(), tmp = list;
|
||||
while (tmp)
|
||||
{
|
||||
printf("%s default route %s\n", tmp->name, tmp->addr);
|
||||
tmp = list->next;
|
||||
}
|
||||
kdk_net_free_route(list);
|
||||
if (argc < 2)
|
||||
printf("please input test port num\n");
|
||||
else
|
||||
printf("port:%s's state %d\n", argv[1], kdk_net_get_port_stat(atoi(argv[1])));
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
aux_source_directory(. SOURCESCODE)
|
||||
include_directories(.)
|
||||
add_library(kypackage SHARED ${SOURCESCODE})
|
||||
set_target_properties(kypackage PROPERTIES VERSION 1.2.0 SOVERSION 1)
|
||||
set_target_properties(kypackage PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
add_executable(kypackage-test test/kypackage-test.c)
|
||||
target_link_libraries(kypackage-test kypackage)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ project(kypowermanagement LANGUAGES CXX)
|
|||
set(POWERMANAGEMENT_TOP_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED)
|
||||
set_target_properties(kypowermanagement PROPERTIES VERSION 1.2.0 SOVERSION 1)
|
||||
set_target_properties(kypowermanagement PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -g)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
aux_source_directory(. SOURCESCODE)
|
||||
include_directories(.)
|
||||
add_library(kyrtinfo SHARED ${SOURCESCODE})
|
||||
set_target_properties(kyrtinfo PROPERTIES VERSION 1.2.0 SOVERSION 1)
|
||||
set_target_properties(kyrtinfo PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
add_executable(kyrtinfo-test test/kyrtinfo-test.c)
|
||||
target_link_libraries(kyrtinfo-test kyrtinfo)
|
||||
add_executable(kyprocess-test test/kyprocess-test.c)
|
||||
target_link_libraries(kyrtinfo-test kyrtinfo)
|
||||
target_link_libraries(kyprocess-test kyrtinfo)
|
||||
|
||||
install(TARGETS kyrtinfo
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkyrtinfo.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkyprocess.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,226 @@
|
|||
#ifndef LIBKYPROCESS_H
|
||||
#define LIBKYPROCESS_H
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file libkyprocess.h
|
||||
* @author shaozhimin (shaozhimin@kylinos.cn)
|
||||
* @brief 某一进程的瞬时详细信息
|
||||
* @version 0.1
|
||||
* @date 2022-09-13
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
* @defgroup 某一进程的瞬时详细信息
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PRG_SOCKET_PFX "socket:["
|
||||
#define PRG_SOCKET_PFXl (strlen(PRG_SOCKET_PFX))
|
||||
#define PRG_SOCKET_PFX2 "[0000]:"
|
||||
#define PRG_SOCKET_PFX2l (strlen(PRG_SOCKET_PFX2))
|
||||
|
||||
#define LINE_MAX 4096
|
||||
|
||||
#define COLWID 240
|
||||
#define UPTIME_FILE "/proc/uptime"
|
||||
#define MEMINFO "/proc/meminfo"
|
||||
#define MAX_PF_NAME 1024
|
||||
#define PROC_DIR "/proc"
|
||||
#define MAX_PROC_NUM 1024
|
||||
#define PROC_NUM 500
|
||||
#define BUF_SIZE 1024
|
||||
static int uptime_fd = -1;
|
||||
#define LC_NUMERIC __LC_NUMERIC
|
||||
#define __LC_NUMERIC 1
|
||||
static char buf[8192];
|
||||
#define O_RDONLY 00
|
||||
#define BAD_OPEN_MESSAGE \
|
||||
"Error: /proc must be mounted\n" \
|
||||
" To mount /proc at boot you need an /etc/fstab line like:\n" \
|
||||
" proc /proc proc defaults\n" \
|
||||
" In the meantime, run \"mount proc /proc -t proc\"\n"
|
||||
|
||||
#define FILE_TO_BUF(filename, fd) do{ \
|
||||
static int local_n; \
|
||||
if (fd == -1 && (fd = open(filename, O_RDONLY)) == -1) { \
|
||||
fputs(BAD_OPEN_MESSAGE, stderr); \
|
||||
fflush(NULL); \
|
||||
_exit(102); \
|
||||
} \
|
||||
lseek(fd, 0L, SEEK_SET); \
|
||||
if ((local_n = read(fd, buf, sizeof buf - 1)) < 0) { \
|
||||
perror(filename); \
|
||||
fflush(NULL); \
|
||||
_exit(103); \
|
||||
} \
|
||||
buf[local_n] = '\0'; \
|
||||
}while(0)
|
||||
|
||||
#define SET_IF_DESIRED(x,y) do{ if(x) *(x) = (y); }while(0)
|
||||
|
||||
struct pstat {
|
||||
long unsigned int utime_ticks;
|
||||
long unsigned int stime_ticks;
|
||||
long unsigned int cpu_total_time;
|
||||
};
|
||||
|
||||
/* 进程信息 */
|
||||
typedef struct process_info
|
||||
{
|
||||
long proc_pid; //进程id
|
||||
char proc_name[128]; //进程名
|
||||
char proc_command[4096]; //进程启动的命令行,包含启动参数
|
||||
char proc_uid[128]; //进程所属用户 用户uid
|
||||
char start_time[128]; //进程启动的时间 (char * ctime(time_t time) 函数返回值Tue Jul 28 08:50:26 2020)
|
||||
unsigned long utime; //进程cpu使用时间,单位s
|
||||
double proc_cpu; //进程cpu使用率 %
|
||||
double proc_mem; //进程mem使用量 %
|
||||
char proc_state[20]; //进程状态
|
||||
char proc_time[20]; //进程运行时间
|
||||
char proc_port[20]; //进程端口号
|
||||
|
||||
} process_info;
|
||||
|
||||
#define PROCESS_ITEM 14
|
||||
|
||||
typedef struct {
|
||||
unsigned long user;
|
||||
unsigned long nice;
|
||||
unsigned long system;
|
||||
unsigned long idle;
|
||||
}Total_Cpu_Occupy_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
unsigned int pid;
|
||||
unsigned long utime; //user time
|
||||
unsigned long stime; //kernel time
|
||||
unsigned long cutime; //all user time
|
||||
unsigned long cstime; //all dead time
|
||||
}Proc_Cpu_Occupy_t;
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的CPU使用率
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return float CPU使用率
|
||||
*/
|
||||
extern float kdk_get_process_cpu_usage_percent(int proc_num);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的内存占用率
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return float 内存占用率
|
||||
*/
|
||||
extern float kdk_get_process_mem_usage_percent(int proc_num);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的进程状态
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return char* 进程状态
|
||||
*/
|
||||
extern char* kdk_get_process_status(int proc_num);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的端口号占用
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return char* 使用的端口号
|
||||
*/
|
||||
extern int kdk_get_process_port(int proc_num);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的启动时间
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return char* 启动时间
|
||||
*/
|
||||
extern char* kdk_get_process_start_time(int proc_num);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的运行时间
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return char* 运行时间
|
||||
*/
|
||||
extern char* kdk_get_process_running_time(int proc_num);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的cpu时间
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return char* cpu时间
|
||||
*/
|
||||
extern char* kdk_get_process_cpu_time(int proc_num);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的Command
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return char* Command
|
||||
*/
|
||||
extern char* kdk_get_process_command(int proc_num);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的属主
|
||||
*
|
||||
* @param proc_num 进程号
|
||||
* @return char* 属主
|
||||
*/
|
||||
extern char* kdk_get_process_user(int proc_num);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的CPU使用率
|
||||
*
|
||||
* @param proc_name 进程名
|
||||
* @return float CPU使用率
|
||||
*/
|
||||
extern float kdk_procname_get_process_cpu_usage_percent(char *proc_name);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的IO使用率
|
||||
*
|
||||
* @param proc_name 进程名
|
||||
* @return float IO使用率
|
||||
*/
|
||||
extern float kdk_procname_get_process_io_usage_percent(char *proc_name);
|
||||
|
||||
/**
|
||||
* @brief 获取某一进程的信息
|
||||
*
|
||||
* @param proc_name 进程名
|
||||
* @return float 内存占用率
|
||||
*/
|
||||
extern char** kdk_procname_get_process_infomation(char *proc_name);
|
||||
|
||||
/**
|
||||
* @brief 获取进程所有信息
|
||||
*
|
||||
* @return char** 进程所有信息
|
||||
*/
|
||||
extern char** kdk_get_process_all_information();
|
||||
|
||||
/**
|
||||
* @brief 用于回收字符串列表
|
||||
*
|
||||
* @param ptr 字符串列表
|
||||
*/
|
||||
extern inline void kdk_proc_freeall(char **ptr);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
|
@ -70,19 +70,19 @@ float kdk_rti_get_mem_res_usage_percent()
|
|||
if (!fp)
|
||||
return 0.00;
|
||||
|
||||
unsigned long memTotal = 0, memFree = 0;
|
||||
unsigned long memTotal = 0, memAvailable = 0;
|
||||
char buffer[1025];
|
||||
while (fgets(buffer, 1024, fp))
|
||||
{
|
||||
if (lookup(buffer, "MemTotal", &memTotal));
|
||||
else if (lookup(buffer, "MemFree", &memFree));
|
||||
else if (lookup(buffer, "MemAvailable", &memAvailable));
|
||||
|
||||
if (memTotal && memFree)
|
||||
if (memTotal && memAvailable)
|
||||
break;
|
||||
}
|
||||
fclose(fp);
|
||||
if (memTotal)
|
||||
percent = (float)(memTotal - memFree) / (float)memTotal;
|
||||
percent = (float)(memTotal - memAvailable) / (float)memTotal;
|
||||
#endif
|
||||
|
||||
return percent;
|
||||
|
@ -96,18 +96,18 @@ unsigned long kdk_rti_get_mem_res_usage_KiB()
|
|||
if (!fp)
|
||||
return 0;
|
||||
|
||||
unsigned long memTotal = 0, memFree = 0;
|
||||
unsigned long memTotal = 0, memAvailable = 0;
|
||||
char buffer[1025];
|
||||
while (fgets(buffer, 1024, fp))
|
||||
{
|
||||
if (lookup(buffer, "MemTotal", &memTotal));
|
||||
else if (lookup(buffer, "MemFree", &memFree));
|
||||
else if (lookup(buffer, "MemAvailable", &memAvailable));
|
||||
|
||||
if (memTotal && memFree)
|
||||
if (memTotal && memAvailable)
|
||||
break;
|
||||
}
|
||||
fclose(fp);
|
||||
memResUsage = memTotal - memFree;
|
||||
memResUsage = memTotal - memAvailable;
|
||||
#endif
|
||||
|
||||
return memResUsage;
|
||||
|
@ -200,7 +200,7 @@ unsigned long kdk_rti_get_mem_swap_usage_KiB()
|
|||
|
||||
float kdk_rti_get_mem_swap_usage_percent()
|
||||
{
|
||||
unsigned long percent = 0;
|
||||
float percent = 0;
|
||||
#ifdef __linux__
|
||||
FILE *fp = fopen(MEMINFO_FILE, "rt");
|
||||
if (!fp)
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#include "../libkyprocess.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("获取某一进程的CPU利用率:%0.1f\n", kdk_get_process_cpu_usage_percent(3554));
|
||||
printf("获取某一进程的内存占用率:%0.1f\n", kdk_get_process_mem_usage_percent(3554));
|
||||
printf("获取某一进程的进程状态:%s\n", kdk_get_process_status(3554));
|
||||
printf("获取某一进程的进程端口号:%d\n", kdk_get_process_port(3554));
|
||||
printf("获取某一进程的启动时间:%s\n", kdk_get_process_start_time(3554));
|
||||
printf("获取某一进程的运行时间:%s\n", kdk_get_process_running_time(3554));
|
||||
printf("获取某一进程的CPU时间:%s\n", kdk_get_process_cpu_time(3554));
|
||||
printf("获取某一进程的Command:%s\n", kdk_get_process_command(3554));
|
||||
printf("获取某一进程的属主:%s\n", kdk_get_process_user(3554));
|
||||
|
||||
char** pid = kdk_procname_get_process_infomation("qaxbrowser");
|
||||
size_t index = 0;
|
||||
while (pid[index])
|
||||
{
|
||||
printf("pid %s\n", pid[index]);
|
||||
index ++;
|
||||
}
|
||||
kdk_proc_freeall(pid);
|
||||
|
||||
char** info = kdk_get_process_all_information();
|
||||
size_t count = 0;
|
||||
while (info[count])
|
||||
{
|
||||
printf("No. %d\t %s\n", count + 1, info[count]);
|
||||
count ++;
|
||||
}
|
||||
kdk_proc_freeall(info);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
include_directories("smartctl/")
|
||||
aux_source_directory(./smartctl CODE)
|
||||
add_library(kyrealtime SHARED libkyrealtimeinfo.cpp libkyrealtimeinfo.h ${CODE})
|
||||
set_target_properties(kyrealtime PROPERTIES VERSION 2.0.0 SOVERSION 1)
|
||||
|
||||
add_executable(kyrealtime-test test/kyrealtime-test.cpp)
|
||||
target_link_libraries(kyrealtime-test kyrealtime)
|
||||
|
||||
install(TARGETS kyrealtime
|
||||
DESTINATION lib/kysdk/kysdk-system)
|
||||
|
||||
install(FILES libkyrealtimeinfo.h
|
||||
DESTINATION include/kysdk/kysdk-system)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue