Code Monkey home page Code Monkey logo

wiringpi-perl's Introduction

#WiringPi for Perl

WiringPi: An implementation of most of the Arduino Wiring functions for the Raspberry Pi

#Quick Build

##Requirements

sudo apt-get install swig2.0 libperl-dev

##Building

Clone this repo: git clone http://github.com/wiringpi/wiringpi-perl

Enter the directory: cd wiringpi-perl

Run the build script: ./build.sh

##Testing

Run ./test.pl to import and test the module by reading the pull-up on an i2c pin.

Use sudo perl -d -e 1 to play with the library in interactive mode.

#Note

This is a wrapper around Gordon Henderson's WiringPi, full details of the library here: http://www.wiringpi.com

wiringpi-perl's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wiringpi-perl's Issues

perl: symbol lookup error: wiringpi.so: undefined symbol: softPwmStop

The compilation works and i can initialize the module.
When the first pinMode command is called it crashes with an error.

perl -e 'use wiringpi; print wiringpi::wiringPiSetup()."\n";wiringpi::pinMode(1, 0);'
perl: symbol lookup error: /usr/lib/perl/5.14/wiringpi.so: undefined symbol: softPwmStop

subdirectory WiringPi is empty

When I cloned WiringPi-Perl the sub directory WiringPi remained empty. I needed to clone WiringPi additionally into the directory. Not sure whether this is the intended use or correct. If yes it would be worth adding it to the README

Build Fails

I'm not able to build. Below is the message I'm getting with an output of perl -v and the location of EXTERN.h on my system.
Raspberry PI 2 B

:~/WiringPi-Perl# ./build.sh

`
wiringpi_wrap.c:730:20: fatal error: EXTERN.h: No such file or directory
 #include "EXTERN.h"
                    ^
compilation terminated.
WiringPi/wiringPi/wiringPi.c: In function ‘wiringPiSetup’:
WiringPi/wiringPi/wiringPi.c:315:18: warning: incompatible implicit declaration of built-in function ‘malloc’
   if ((gpioMem = malloc (BLOCK_SIZE + (PAGE_SIZE-1))) == NULL)
                  ^
gcc: error: wiringpi_wrap.o: No such file or directory

:~/WiringPi-Perl# perl -v

This is perl 5, version 20, subversion 2 (v5.20.2) built for arm-linux-gnueabihf-thread-multi-64int
(with 42 registered patches, see perl -V for more detail)

:~/WiringPi-Perl# locate EXTERN.h

/usr/lib/arm-linux-gnueabihf/perl/5.20.2/CORE/EXTERN.h

Compilation fails

Hi,

I tried to compile and install your module, but unfortunately I can't make it work here. I have a Raspberry Pi 2 Model B. I 'git clone'd the wiringpi-perl repo and inside this repo cloned the normal wiringpi libs. so far it seemed to work. But serial.h is missing. Even if I rename wiringSerial.h to serial.h (or vice versa) it doesn't work.

The error seems to be in wiringpi_wrap.c
I get several errors like this:

/usr/lib/perl5/core_perl/CORE/handy.h:124:34: error: 'bool' uindeclared (first use in this function) ....
yadda yadda....

I had to rewrite the build.sh script to use my correct perl path here, but there seems to be an inconistency between versions afaics.

regards,
manuel

serial.h missing for compilation

I had a message complaining that the file serial.h was missing. Checked WiringPi/wiringPi/ and found wiringSerial.h compilation worked after I renamed wiringSerial.h to serial.h

Perl Example

# !/usr/bin/perl
# test1.pl

use wiringpi;
use constant {
    OUTPUT=>1,
    INPUT=>0,
    HIGH=>1,
    LOW=>0
};

$SIG{'INT'}=&safe_exit;
$SIG{'QUIT'}=&safe_exit;
$SIG{**DIE**}=&safe_exit;

print("Raspberry Pi wiringPi test program\n");
if( wiringpi::wiringPiSetup()==-1 ){
    die 1;
}

for( my $pin=0;$pin<8;++$pin ){
    wiringpi::pinMode($pin,OUTPUT);
}

wiringpi::pinMode(8,INPUT);

@data=(
        [0,1,1],
        [1,1,1],
    [0,0,0],[2,1,1],
    [1,0,0],[3,1,1],
    [2,0,0],[4,1,1],
    [3,0,0],[5,1,1],
    [4,0,0],[6,1,1],
    [5,0,0],[7,1,1],
    [6,0,1],
    [7,0,1],
        [7,1,1],
        [6,1,1],
    [7,0,0],[5,1,1],
    [6,0,0],[4,1,1],
    [5,0,0],[3,1,1],
    [4,0,0],[2,1,1],
    [3,0,0],[1,1,1],
    [2,0,0],[0,1,1],
    [1,0,1],
    [0,0,1],
    [9,9,9]
);

my $inc=0;

while( 1==1 ){
    my( $pin,$state,$duration )=@{$data[$inc]};
    if( $pin+$state+$duration==27 ){
        $inc=0;
        next;
    }
    wiringpi::digitalWrite($pin,$state);
    if( wiringpi::digitalRead(8)==LOW ){
        wiringpi::delay($duration_10);
    }else{
        wiringpi::delay( $duration_100 );
    }
    ++$inc;
}
# this just turns off all the LEDs when you exit the script

sub safe_exit{
    for( my $pin=0;$pin<8;++$pin ){
        wiringpi::digitalWrite($pin,LOW);
    }
    exit 1;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.