blob: 03a5926eab912a3089cbcd2bab28c95ad2d516de [file] [log] [blame]
b.liu8583dce2024-04-03 13:30:08 +08001#include <sys/types.h>
2#include <dirent.h>
3#include <unistd.h>
4#include <stdio.h>
5#include <string.h>
6#include <fcntl.h>
7#include <stdlib.h>
8#include <unistd.h>
9#include <dlfcn.h>
10
11#include"lynq-qser-thermal-demo.h"
12
13
14int (*get_thermal_zone)(int *numbers, int size);
15
16
17int main(int argc, char *argv[]){
18 int numbers[MAX_SIZE];
19 int ret = 0;
20 const char *lynq_libpath_thermal = "/lib/liblynq-qser-thermal.so";
21
22 void *dlHandle_thermal = dlopen(lynq_libpath_thermal, RTLD_NOW);
23 if (dlHandle_thermal == NULL)
24 {
25 printf("dlopen dlHandle_thermal failed: %s\n", dlerror());
26 exit(EXIT_FAILURE);
27 }
28 get_thermal_zone = (int(*)(int *numbers, int size))dlsym(dlHandle_thermal,"get_thermal_zone");
29 if(NULL != get_thermal_zone)
30 {
31 ret = get_thermal_zone(numbers, MAX_SIZE);
32 if (ret <= 0) {
33 printf("get_thermal_zone error\n");
34 return -1;
35 }
36 }else{
37 printf("get_thermal_zone dlsym error\n");
38 }
39
40 for (int j = 0; j < ret; ++j) {
41 printf("[%s-%d] temp[%d] = %d \n", __func__, __LINE__, j, numbers[j]);
42 }
43
44 return 0;
45}
46
47
48
49