embeded/raspberry pi2015. 6. 8. 20:31

패키지로 다운로드 될줄 알았는데 안되네..


일단 사용한 녀석은


라즈베리 2

2015-05-05-raspbian-wheezy.img


wiringpi

pi@raspberrypi ~ $ sudo apt-get install git-core

pi@raspberrypi ~ $ mkdir src

pi@raspberrypi ~ $ cd src

pi@raspberrypi ~/src $ git clone git://git.drogon.net/wiringPi

Cloning into 'wiringPi'...

remote: Counting objects: 742, done.

remote: Compressing objects: 100% (676/676), done.

remote: Total 742 (delta 536), reused 96 (delta 58)

Receiving objects: 100% (742/742), 264.80 KiB | 128 KiB/s, done.

Resolving deltas: 100% (536/536), done.

pi@raspberrypi ~/src $ cd wiringPi/

pi@raspberrypi ~/src/wiringPi $ git pull origin

Already up-to-date.

pi@raspberrypi ~/src/wiringPi $ ./build

wiringPi Build script

=====================



WiringPi Library

[UnInstall]

[Compile] wiringPi.c

[Compile] wiringSerial.c

[Compile] wiringShift.c

[Compile] piHiPri.c

[Compile] piThread.c

[Compile] wiringPiSPI.c

[Compile] wiringPiI2C.c

[Compile] softPwm.c

[Compile] softTone.c

[Compile] mcp23008.c

[Compile] mcp23016.c

[Compile] mcp23017.c

[Compile] mcp23s08.c

[Compile] mcp23s17.c

[Compile] sr595.c

[Compile] pcf8574.c

[Compile] pcf8591.c

[Compile] mcp3002.c

[Compile] mcp3004.c

[Compile] mcp4802.c

[Compile] mcp3422.c

[Compile] max31855.c

[Compile] max5322.c

[Compile] sn3218.c

[Compile] drcSerial.c

[Compile] wpiExtensions.c

[Link (Dynamic)]

[Install Headers]

[Install Dynamic Lib]


WiringPi Devices Library

[UnInstall]

[Compile] ds1302.c

[Compile] piNes.c

[Compile] maxdetect.c

[Compile] gertboard.c

[Compile] piFace.c

[Compile] lcd128x64.c

[Compile] lcd.c

[Compile] piGlow.c

[Link (Dynamic)]

[Install Headers]

[Install Dynamic Lib]


GPIO Utility

[Compile] gpio.c

[Compile] readall.c

[Compile] pins.c

[Link]

[Install]


All Done.


NOTE: To compile programs with wiringPi, you need to add:

    -lwiringPi

  to your compile line(s) To use the Gertboard, MaxDetect, etc.

  code (the devLib), you need to also add:

    -lwiringPiDev

  to your compile line(s).


pi@raspberrypi ~/src/wiringPi $ gpio readall

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+

 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |

 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+

 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |

 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |

 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |

 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |

 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |

 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |

 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |

 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |

 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |

 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |

 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |

 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |

 |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |

 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |

 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |

 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |

 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |

 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |

 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |

 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |

 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+

 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |

 +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+ 


[링크 : http://wiringpi.com/download-and-install/]



pi4j

pi@raspberrypi ~/src/java $ wget http://get.pi4j.com/download/pi4j-1.0.deb

--2015-06-08 11:35:02--  http://get.pi4j.com/download/pi4j-1.0.deb

Resolving get.pi4j.com (get.pi4j.com)... 54.231.18.148

Connecting to get.pi4j.com (get.pi4j.com)|54.231.18.148|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 616120 (602K) [application/octet-stream]

Saving to: `pi4j-1.0.deb'


100%[======================================>] 616,120      255K/s   in 2.4s


2015-06-08 11:35:05 (255 KB/s) - `pi4j-1.0.deb' saved [616120/616120]


pi@raspberrypi ~/src/java $ sudo dpkg -i pi4j-1.0.deb

Selecting previously unselected package pi4j.

(데이터베이스 읽는중 ...현재 77870개의 파일과 디렉터리가 설치되어 있습니다.)

pi4j 패키지를 푸는 중입니다 (pi4j-1.0.deb에서) ...

pi4j (1.0) 설정하는 중입니다 ...


pi@raspberrypi ~/src/java $ sudo apt-get install pi4j

패키지 목록을 읽는 중입니다... 완료

의존성 트리를 만드는 중입니다

상태 정보를 읽는 중입니다... 완료

pi4j 패키지는 이미 최신 버전입니다.

0개 업그레이드, 0개 새로 설치, 0개 제거 및 3개 업그레이드 안 함.



pi@raspberrypi ~/src/java $ ls -al /opt/pi4j/lib

합계 496

drwxr-xr-x 2 root root   4096  6월  8 11:35 .

drwxr-xr-x 5 root root   4096  6월  8 11:35 ..

-rw-r--r-- 1 root root 179187  4월 18 16:02 pi4j-core.jar

-rw-r--r-- 1 root root 217311  4월 18 16:02 pi4j-device.jar

-rw-r--r-- 1 root root  74078  4월 18 16:02 pi4j-gpio-extension.jar

-rw-r--r-- 1 root root  17663  4월 18 16:02 pi4j-service.jar


pi@raspberrypi ~/src/java $ vi TriggerGpio.java


import java.util.concurrent.Callable;


import com.pi4j.io.gpio.GpioController;

import com.pi4j.io.gpio.GpioFactory;

import com.pi4j.io.gpio.GpioPinDigitalInput;

import com.pi4j.io.gpio.GpioPinDigitalOutput;

import com.pi4j.io.gpio.PinPullResistance;

import com.pi4j.io.gpio.PinState;

import com.pi4j.io.gpio.RaspiPin;

import com.pi4j.io.gpio.trigger.GpioCallbackTrigger;

import com.pi4j.io.gpio.trigger.GpioPulseStateTrigger;

import com.pi4j.io.gpio.trigger.GpioSetStateTrigger;

import com.pi4j.io.gpio.trigger.GpioSyncStateTrigger;


public class TriggerGpio {


    public static void main(String[] args) throws InterruptedException {


        System.out.println("START");


        // create gpio controller

        final GpioController gpio = GpioFactory.getInstance();


        // provision gpio pin #02 as an input pin with its internal pull down resistor enabled

        final GpioPinDigitalOutput ledPin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_07, PinState.LOW);


        ledPin.setState(PinState.HIGH);


    }

}


pi@raspberrypi ~/src/java $ date;javac -classpath .:classes:/opt/pi4j/lib/'*' TriggerGpio.java ;date

2015. 06. 08. (월) 11:40:03 UTC

2015. 06. 08. (월) 11:40:09 UTC 


pi@raspberrypi ~/src/java $ sudo java -classpath .:classes:/opt/pi4j/lib/'*' TriggerGpio

START


[링크 : http://pi4j.com/download.html]

Posted by 구차니