This commit is contained in:
aixiao 2018-07-02 02:13:22 +00:00
parent 39a1a114c3
commit 3ee8e95084
15 changed files with 38 additions and 20 deletions

View File

@ -1,23 +1,20 @@
CC=gcc
libs=info_infrared.o info_light.o info_pin.o info_sound.o info_ultrasound.o
all: infrared light pin sound ultrasound
all: infrared light pin sound ultrasound wind_
infrared: info_infrared.o
$(CC) -c info_infrared.c
$(CC) info_infrared.o -o info_infrared -lwiringPi
light: info_light.o
$(CC) -c info_light.c
$(CC) info_light.o -o info_light -lwiringPi
pin: info_pin.o
$(CC) -c info_pin.c
$(CC) info_pin.o -o info_pin -lwiringPi
sound: info_sound.o
$(CC) -c info_sound.c
$(CC) info_sound.o -o info_sound -lwiringPi
ultrasound: info_ultrasound.o
$(CC) -c info_ultrasound.c
$(CC) info_ultrasound.o -o info_ultrasound -lwiringPi
infrared: info_infrared
$(CC) info_infrared.c -o info_infrared -lwiringPi
light: info_light
$(CC) info_light.c -o info_light -lwiringPi
pin: info_pin
$(CC) info_pin.c -o info_pin -lwiringPi
sound: info_sound
$(CC) info_sound.c -o info_sound -lwiringPi
ultrasound: info_ultrasound
$(CC) info_ultrasound.c -o info_ultrasound -lwiringPi
wind_: wind
${CC} wind.c -o wind
.PHONY : clean
clean :

View File

@ -184,7 +184,7 @@ function sound()
function wind_daemon()
{
while true; do
${bindir}/wind > ${bindir}/data/wind.data; : 温度传感器获取室内温度信息.
${bindir}/wind -d ${device} > ${bindir}/data/wind.data; : 温度传感器获取室内温度信息.
SLEEP 9;
done
}

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.

View File

@ -1 +1 @@
9062
7721

BIN
gpio/wind

Binary file not shown.

View File

@ -7,9 +7,27 @@
#include <time.h>
#include <stdlib.h>
#define N 80
#define N 99
int main(int argc, char *argv[])
{
int ch;
opterr = 0;
while((ch = getopt(argc, argv, "d:h?")) != -1)
switch (ch) {
case 'd':
_main(optarg);
break;
case 'h': case '?':
printf("wind -d device\n");
exit(0);
break;
default:
;
}
}
int _main(char *optarg)
{
char path[50] = "/sys/bus/w1/devices/";
char rom[20];
@ -19,6 +37,9 @@ int main(int argc, char *argv[])
FILE *fp;
char *temp;
float value;
char *device; // 设备
if(optarg == '\0')
strcmp(device, optarg);
system("sudo modprobe w1-gpio");
system("sudo modprobe w1-therm");
@ -27,7 +48,7 @@ int main(int argc, char *argv[])
}
while((direntp = readdir(dirp)) != NULL) {
if(strstr(direntp->d_name, "28-0")) {
if(strstr(direntp->d_name, device)) {
strcpy(rom, direntp->d_name);
}
}