Skip to content

Commit 0de6c54

Browse files
committed
new .gitignore + grab value with lm sensors + use C code with C#
1 parent 856bfcc commit 0de6c54

24 files changed

+660
-253
lines changed

.gitignore

+13-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
publish
1+
publish/
22

3+
.vscode/
4+
.idea/
5+
.vs/
36

4-
### generated log files ###
5-
**.log
7+
.gradle/
68

9+
*.so
10+
*.o
711

8-
### csharp output
9-
FanControl/app/include/windows/build
12+
build/
13+
obj/
14+
bin/
1015

11-
### csharp shit
12-
HardwareLib/.vs
13-
HardwareLib/FanControlService/obj
14-
HardwareLib/FanControlService/bin
1516

17+
generated/
1618

17-
### generated proto files ###
18-
FanControl/app/src/jvmMain/java/proto/generated
19-
FanControl/app/src/jvmMain/kotlin/proto/generated
19+
*.log
20+
wix311/
2021

21-
### idea custom modif
22-
/shelf/
23-
**/.idea/workspace.xml
24-
artifacts/
25-
**/.idea/gradle.xml
26-
**/.idea/misc.xml
27-
28-
29-
30-
FanControl/wix311/

Experimental/Makefile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CC = gcc
2+
FLAGS = -g -Wall
3+
EXE = main
4+
LIB = -lsensors
5+
6+
7+
8+
9+
10+
build: main.o sensors.o
11+
$(CC) $(FLAGS) $^ -o $(EXE) $(LIB)
12+
13+
14+
run: build
15+
./main
16+
17+
18+
%.o:%.c
19+
$(CC) $(FLAGS) -c $< $(LIB)
20+
21+
clean:
22+
rm -rf *.o *.gch *.bin $(EXE)
23+
24+

Experimental/main

31.4 KB
Binary file not shown.

Experimental/main.c

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdio.h>
2+
3+
#include "sensors.h"
4+
5+
6+
int main() {
7+
8+
fetch_temp2();
9+
10+
}

Experimental/sensors.c

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#include <stdio.h>
2+
#include <sensors/sensors.h>
3+
4+
5+
void fetch_temp()
6+
{
7+
int res = sensors_init(NULL);
8+
9+
if (res != 0) {
10+
printf("err sensors_init: %d\n", res);
11+
}
12+
13+
sensors_chip_name const * cn;
14+
int c = 0;
15+
while ((cn = sensors_get_detected_chips(0, &c)) != 0) {
16+
printf("Chip: %s %s\n",cn->prefix, cn->path);
17+
18+
sensors_feature const *feat;
19+
int f = 0;
20+
21+
while ((feat = sensors_get_features(cn, &f)) != 0) {
22+
printf(" %d:%s\n", f, feat->name);
23+
24+
sensors_subfeature const *subf;
25+
int s = 0;
26+
27+
while ((subf = sensors_get_all_subfeatures(cn, feat, &s)) != 0) {
28+
printf(" %d:%d:%s/%d = ", f, s, subf->name, subf->number);
29+
30+
double val;
31+
if (subf->flags & SENSORS_MODE_R) {
32+
int rc = sensors_get_value(cn, subf->number, &val);
33+
if (rc < 0) {
34+
printf("err: %d\n", rc);
35+
} else {
36+
printf("%f\n", val);
37+
}
38+
}
39+
}
40+
}
41+
printf("\n");
42+
}
43+
}
44+
45+
46+
void fetch_temp2()
47+
{
48+
int res = sensors_init(NULL);
49+
50+
if (res != 0) {
51+
printf("err sensors_init: %d\n", res);
52+
}
53+
54+
sensors_chip_name const * cn;
55+
int c = 0;
56+
while ((cn = sensors_get_detected_chips(0, &c)) != 0) {
57+
printf("Chip: %s %s\n",cn->prefix, cn->path);
58+
59+
sensors_feature const *feat;
60+
int f = 0;
61+
62+
while ((feat = sensors_get_features(cn, &f)) != 0) {
63+
printf(" %d:%s\n", f, feat->name);
64+
65+
sensors_subfeature const *subf;
66+
int s = 0;
67+
68+
if ((subf = sensors_get_all_subfeatures(cn, feat, &s)) != 0) {
69+
printf(" %d:%s = ", s, subf->name);
70+
71+
double val;
72+
if (subf->flags & SENSORS_MODE_R) {
73+
int rc = sensors_get_value(cn, subf->number, &val);
74+
if (rc < 0) {
75+
printf("err: %d\n", rc);
76+
} else {
77+
printf("%f\n", val);
78+
}
79+
}
80+
}
81+
}
82+
printf("\n");
83+
}
84+
}

Experimental/sensors.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef SENSORS_H
2+
#define SENSORS_H
3+
4+
5+
void fetch_temp();
6+
7+
void fetch_temp2();
8+
9+
#endif

FanControl/.gitignore

-43
This file was deleted.

FanControl/.idea/codeStyles/Project.xml

-16
This file was deleted.

FanControl/.idea/codeStyles/codeStyleConfig.xml

-5
This file was deleted.

FanControl/.idea/uiDesigner.xml

-124
This file was deleted.

FanControl/.idea/vcs.xml

-6
This file was deleted.

HardwareLib/.idea/.idea.HardwareLib/.idea/.gitignore

-13
This file was deleted.

0 commit comments

Comments
 (0)