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 CC=gcc
libs=info_infrared.o info_light.o info_pin.o info_sound.o info_ultrasound.o 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 infrared: info_infrared
$(CC) -c info_infrared.c $(CC) info_infrared.c -o info_infrared -lwiringPi
$(CC) info_infrared.o -o info_infrared -lwiringPi light: info_light
light: info_light.o $(CC) info_light.c -o info_light -lwiringPi
$(CC) -c info_light.c pin: info_pin
$(CC) info_light.o -o info_light -lwiringPi $(CC) info_pin.c -o info_pin -lwiringPi
pin: info_pin.o sound: info_sound
$(CC) -c info_pin.c $(CC) info_sound.c -o info_sound -lwiringPi
$(CC) info_pin.o -o info_pin -lwiringPi ultrasound: info_ultrasound
sound: info_sound.o $(CC) info_ultrasound.c -o info_ultrasound -lwiringPi
$(CC) -c info_sound.c wind_: wind
$(CC) info_sound.o -o info_sound -lwiringPi ${CC} wind.c -o wind
ultrasound: info_ultrasound.o
$(CC) -c info_ultrasound.c
$(CC) info_ultrasound.o -o info_ultrasound -lwiringPi
.PHONY : clean .PHONY : clean
clean : clean :

View File

@ -184,7 +184,7 @@ function sound()
function wind_daemon() function wind_daemon()
{ {
while true; do while true; do
${bindir}/wind > ${bindir}/data/wind.data; : 温度传感器获取室内温度信息. ${bindir}/wind -d ${device} > ${bindir}/data/wind.data; : 温度传感器获取室内温度信息.
SLEEP 9; SLEEP 9;
done 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 <time.h>
#include <stdlib.h> #include <stdlib.h>
#define N 80 #define N 99
int main(int argc, char *argv[]) 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 path[50] = "/sys/bus/w1/devices/";
char rom[20]; char rom[20];
@ -19,6 +37,9 @@ int main(int argc, char *argv[])
FILE *fp; FILE *fp;
char *temp; char *temp;
float value; float value;
char *device; // 设备
if(optarg == '\0')
strcmp(device, optarg);
system("sudo modprobe w1-gpio"); system("sudo modprobe w1-gpio");
system("sudo modprobe w1-therm"); system("sudo modprobe w1-therm");
@ -27,7 +48,7 @@ int main(int argc, char *argv[])
} }
while((direntp = readdir(dirp)) != NULL) { while((direntp = readdir(dirp)) != NULL) {
if(strstr(direntp->d_name, "28-0")) { if(strstr(direntp->d_name, device)) {
strcpy(rom, direntp->d_name); strcpy(rom, direntp->d_name);
} }
} }