首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使脂传感器正常工作

无法使脂传感器正常工作
EN

Stack Overflow用户
提问于 2015-09-29 22:05:01
回答 1查看 236关注 0票数 2

这是我关于脂质传感器的代码。图书馆:

代码语言:javascript
复制
#include <unistd.h>
#include <sensors/sensors.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

关于锂传感器的代码:

代码语言:javascript
复制
char sd[16384]="^\0",bf[1];
char buf2[8192]="^\0";


sensors_chip_name const* scn;
int c=0;
int t4=1;
while((scn=sensors_get_detected_chips(0,&c))!=0)
{
        sensors_feature const *fea;
        int f=0;
        strcat(sd,scn->prefix);
        printf("%s",scn->prefix);
        strcat(sd,":");
        strcat(sd,scn->path);
        strcat(sd,"(");
        while((fea=sensors_get_features(scn,&f))!=0)
        {

                strcat(sd,fea->name);
                strcat(sd,"(");
                sensors_subfeature const *sb;
                int s=0;
                while((sb=sensors_get_all_subfeatures(scn,fea,&s))!=0)
                {
                        t4++;
                        strcat(sd,sb->name);
                        strcat(sd,",");
                        int t3=-1;
                        int i=0;
                        char t8[sizeof(sb->number)];
                        memcpy(&t8,&(sb->number),sizeof(sb->number));
                        strcat(sd,t8);
                        strcat(sd,"!");
                }
                strcat(sd,")");
        }
        strcat(sd,")");

}

所以当我试图打印任何东西时,什么都不会发生。称为sd的char数组返回空。似乎根本就没有传感器可读。

当我从终端运行sensors时,它运行的非常好。我看到了几个核心和芯片温度。

我在这里的某个帖子中实现了这个代码,坦率地说,我并不完全理解它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-21 07:57:28

发布https://stackoverflow.com/users/3629249/user3629249评论作为一个社区的答案。

它需要首先调用sensors_init(),否则芯片列表将为空。

这个函数需要一个sensors配置文件作为参数,或者NULL使用默认的配置文件。

此外,您还可以在这个相关问题中找到一个用法示例:Has anyone been able to use libsensors properly?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32854537

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档