cc -c -o dhtll.o dht11.c cc -o tempmon tempmon.c dht11.o -l wiringPi #### use strict; use warnings; use Inline 'C'; #### perl: symbol lookup error: /home/pi/repos/scripts/c/rpi/dht11/library/_Inline/lib/auto/perl_pl_96d1/perl_pl_96d1.so: undefined symbol: pinMode #### use Config; my $ccflags .= $Config{ccflags} . " -l wiringPi"; use Inline ('C' => 'END', ccflags => $ccflags); #### Running Mkbootstrap for perl_pl_b1a3 () chmod 644 "perl_pl_b1a3.bs" "/home/pi/perl5/perlbrew/perls/perl-5.24.0/bin/perl" "/home/pi/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/ExtUtils/xsubpp" -typemap "/home/pi/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/ExtUtils/typemap" perl_pl_b1a3.xs > perl_pl_b1a3.xsc && mv perl_pl_b1a3.xsc perl_pl_b1a3.c cc -c -I"/home/pi/repos/scripts/c/rpi/dht11/library" -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" -fPIC "-I/home/pi/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/armv7l-linux/CORE" perl_pl_b1a3.c In file included from perl_pl_b1a3.xs:3:0: /home/pi/perl5/perlbrew/perls/perl-5.24.0/lib/5.24.0/armv7l-linux/CORE/XSUB.h:142:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘void’ # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__) ^ perl_pl_b1a3.c:163:1: note: in expansion of macro ‘XS_EXTERNAL’ XS_EXTERNAL(boot_perl_pl_b1a3); /* prototype to pass -Wmissing-prototypes */ ^ Makefile:331: recipe for target 'perl_pl_b1a3.o' failed #### use warnings; use strict; use Config; my $ccflags .= $Config{ccflags} . " -l wiringPi"; use Inline ('C' => 'END', ccflags => $ccflags); #use Inline 'C'; my $dht_pin = 4; my $err_pin = 1; my $temp_limit = 65.0; my $warn_pin = 6; my $ret = read_temp($dht_pin, $err_pin, $temp_limit, $warn_pin); print "$ret\n"; cleanup($dht_pin, $err_pin, $warn_pin); __END__ __C__ #include #include "dht11.h" #include #include #include #include #define MAXTIMINGS 85 float read_temp(int dhtPin, int tempErrPin, float tempErrLimit, int tempWarnPin) { int dht11_dat[5] = { 0, 0, 0, 0, 0 }; uint8_t laststate = HIGH; uint8_t counter = 0; uint8_t j = 0, i; float f; /* fahrenheit */ dht11_dat[0] = dht11_dat[1] = dht11_dat[2] = dht11_dat[3] = dht11_dat[4] = 0; /* pull pin down for 18 milliseconds */ pinMode(dhtPin, OUTPUT); digitalWrite(dhtPin, LOW ); delay( 18 ); /* then pull it up for 40 microseconds */ digitalWrite(dhtPin, HIGH ); delayMicroseconds( 40 ); /* prepare to read the pin */ pinMode(dhtPin, INPUT ); /* detect change and read data */ for ( i = 0; i < MAXTIMINGS; i++ ) { counter = 0; while ( digitalRead( dhtPin ) == laststate ) { counter++; delayMicroseconds( 1 ); if ( counter == 255 ) { break; } } laststate = digitalRead( dhtPin ); if ( counter == 255 ) break; /* ignore first 3 transitions */ if ( (i >= 4) && (i % 2 == 0) ) { /* shove each bit into the storage bytes */ dht11_dat[j / 8] <<= 1; if ( counter > 16 ) dht11_dat[j / 8] |= 1; j++; } } /* * check we read 40 bits (8bit x 5 ) + verify checksum in the last byte * print it out if data is good */ if ( (j >= 40) && (dht11_dat[4] == ( (dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]) & 0xFF) ) ) { f = dht11_dat[2] * 9. / 5. + 32; // debugging // printf("f: %.1f: warn: %.1f\n", f, tempErrLimit); // printf("warnPin: %d\n", tempWarnPin); int warn = 0; if (tempErrPin > -1) { pinMode(tempErrPin, OUTPUT); if (f > tempErrLimit) { warn = 1; digitalWrite(tempErrPin, HIGH); if (tempWarnPin > -1) { pinMode(tempWarnPin, OUTPUT); digitalWrite(tempWarnPin, HIGH); } } else { digitalWrite(tempErrPin, LOW); } } /* * printf( "Humidity = %d.%d %% Temperature = %d.%d *C (%.1f *F)\n", * dht11_dat[0], dht11_dat[1], dht11_dat[2], dht11_dat[3], f ); */ if (warn > 0) { return f; } else { return 0.0; } } } int cleanup(int dhtPin, int tempErrPin, int tempWarnPin) { digitalWrite(dhtPin, LOW); pinMode(dhtPin, INPUT); digitalWrite(tempErrPin, LOW); pinMode(tempErrPin, INPUT); digitalWrite(tempWarnPin, LOW); pinMode(tempWarnPin, INPUT); return(0); }