Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Perl meets Real World
Search
mackee
August 29, 2014
Programming
1
6.5k
Perl meets Real World
YAPC::Asia 2014 2014-08-29 by @mackee_w
mackee
August 29, 2014
Tweet
Share
More Decks by mackee
See All by mackee
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
perl for shell, awk and sed programmers
mackee
2
1.5k
今更GoのWebフレームワークを作ろうとしているワケ / Why am I trying to create a Go web framework now?
mackee
1
69
マイクロサービス化を利用した Goへの移行事例
mackee
0
120
PerlでつくるフルスクラッチWebAuthn/パスキー認証 / Demonstration of full-scratch WebAuthn/Passkey Authentication written in Perl
mackee
3
3.4k
SRE定例やその辺の取り組みをアプリケーションエンジニア目線で語る / "Observe" about SRE Meeting by Application Engineer
mackee
0
1.8k
TinyGoで使えるORM sqllaの 紹介とTinyGoで使えるようにするための工夫
mackee
0
1.2k
Go向けORM sqllaの紹介と JOINやUNIONを含んだクエリの扱い方
mackee
0
4.5k
デプロイ今昔物語 〜CGIからサーバーレスまで〜 / The deployment technics
mackee
10
12k
Other Decks in Programming
See All in Programming
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
710
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
320
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
120
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
270
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
310
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
Beyond ORM
77web
3
430
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
1
510
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Bash Introduction
62gerente
608
210k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Embracing the Ebb and Flow
colly
84
4.5k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Transcript
Perl meets Real World 2014-08-29 YAPC::Asia 2014
@mackee_w a.k.a Ϛίϐʔ • ໘ന๏ਓΧϠοΫ ٕज़෦ • αʔόαΠυΤϯδχΞ(Perl) • ιʔγϟϧήʔϜͷ։ൃ/ӡ༻
• ࠓ࡞͍ͬͯΔήʔϜࣄલొडத
ͯ͞
WebΤϯδχΞ͕ ԿނϋʔυΣΞ͔ʁ
ڈগ͚ͩ͠ϋʔυΣΞͷ ࣄΛͨ͠ • ઇࢁͰϥδίϯϔϦΛඈ͢ࣄ • Webͷٕज़͔͠ແ͔ͬͨ • ௐͨΒ࠷ۙͷϋʔυ͍͢͜͝ͱʹͳͬ ͍ͯͨ
ٕͬͨज़ • RaspberryPi • Arduino • OpenCV • Ansible
ϋʔυΣΞ શ෦ҰൠతʹೖखՄೳ
ιϑτΣΞ “Web”ʹ௨ͣΔٕज़ͨͪ
ۤ࿑͚͋ͬͨΕͲ ָ͔ͬͨ͠ͷͰ”ํ๏”ͷ Ұ෦Λհ͠·͢
ࠓ͢͜ͱ • RaspberryPiͱArduino • ΦʔϓϯιʔεϋʔυΣΞ • Perl͚ͩͰωΪΛৼΔ • ࣗ࡞ϋʔυΣΞͱະདྷ
ࠓ͞ͳ͍͜ͱ • ϋϯμ͚ʢձ͔Β͓ͦΒౖ͘ΒΕΔʣ • ճ࿏ઃܭʢཁ͕͋Εผͷػձʹʣ • ΨνͷArduinoʢ͍ͨΒ࠙ձͱ͔Ͱʣ • ͦͷଞΨνిࢠ࡞
ୈҰষ Raspberry PiͱArduino
Raspberry Pi http://commons.wikimedia.org/wiki/File:Raspberry_Pi_Photo.jpg
• ARM 700MHz • 512MB RAM(Model B) • SD CARD
• 100BASE-TX LAN • USB2.0 x 2 • HDMI and RCA VIDEO • Audio • Power by USB
Q. Ͱɺ͜ΕͰPerlಈ͘ͷʁ
A. ͪΖΜಈ͖·͢ʂ
ී௨ͷLinux͕ಈ͘ • Raspbian (DebianͷRasPi͚ΧελϜ) • NOOBS(for beginner) • Pidora(FedoraͷRasPi͚ΧελϜ)
ͦͦͷRasPiͷత • খதֶੜൃల్্ࠃ͚ͷITڭҭ • RCAϏσΦδϟοΫ͕͍͍ͯΔͷൃల్্ ࠃͷϒϥϯςϨϏͰ͏ͨΊ • MinecraftͷRasPi൛ͱ͔͋ͬͯPythonͰΧελ ϚΠζͰ͖ͨΓ͢Δ
kano ࢠڙ͚ͷΦʔϧΠϯϫϯͷPCΩοτ https://www.kickstarter.com/projects/alexklein/kano-a-computer-anyone-can-make
͔͠͠େਓ༷ͯ͠ʑͳ ϓϩδΣΫτ͕ڵͬͨ
RaspberryPiΛͬͨϓϩδΣΫτ
Raspberry Pi Կނ/׆༻͞Ε͔ͨ
·͍͋ΖΜͳཧ༝͋Δ • ͍҆ (B/B+͕4000ԁఔ) • ΫϨδοτΧʔυαΠζ • ଞʹطʹಉछͷͷ͋ͬͨ • ڥ͕͍ͬͯΔ(ग़͕ࣗॳ৺ऀ͚)
• ࡞ྫ͕ଟ͍
GPIO
GPIO - ݱ࣮ੈքʹհೖ͢ΔͨΊͷखஈ
ిؾΛݟฉ͖͠ɺ͠ΌΔ • ϞʔλʔͳͲͷۦಈػثͷಈ࡞ -> ࢛ࢶ • ηϯαʔͰͷपғঢ়گͷݕ -> ޒײ
ిؾͱ͍͏࠷ϨΠϠʔΛ खܰʹѻ͑Δͷ͕RasPi
Arduinoͷ
• ిؾΛѻ͏͜ͱʹಛԽ • 8bit ϚΠίϯΛࡌ • ॲཧೳྗඇৗʹখ͍͞ • USBೖྗઐ༻ •
ྫ֎͋Δ • LinuxͳͲ౸ఈಈ͔ͳ͍ • ϐϯΛૢ࡞͢Δ
Q. Ͱɺ͜ΕͰPerlಈ͘ͷʁ
A. (‘A`) ಈ͔ͳ͍ɻɻɻ
ϋʔυΣΞ୯ମͰඇྗ͕ͩ ΤίγεςϜ͕ڧྗ
Arduino IDE ArduinoʹඞཁͳͷΛશͯ٧ΊࠐΜͩιϑτΣΞ
γʔϧυ ُࢠُํࣜͰ֦ு͢ΔΞλονϝϯτ
ϥΠϒϥϦArduinoΛલఏͱͨ͠Ωοτ
͜͏͍͚Δ
RaspberryPiͰΓ͍ͨ͜ͱ • ը૾ॲཧͱ͔Τϯίʔυͱ͔ॏ͍ͨॲཧ • ෳࡶͳΞϧΰϦζϜΛཁ͢Δͷ • PC͚ͷϥΠϒϥϦ͕͙͢ಈ͖͍͢ • ؆୯ͳΦϯΦϑఔͷϋʔυΣΞ੍ޚ
ArduinoͰΓ͍ͨ͜ͱ • ࣗ࡞ͷిࢠ෦ͳͲͱ࿈ܞ͢Δέʔε • Arduino͚ϥΠϒϥϦ͕͢Ͱʹ͋Δ߹ • PWM੍ޚͳͲͷߴʹΦϯɾΦϑΛΔ߹ • RasPiͩͱ͜͏͍͏͜ͱΛΔͱCPUΛΊͬ ͪΌ৯͏
ීஈ2ͭΛΈ߹ΘͤΔ͜ͱ ͕ଟ͍Ͱ͕͢ɺͦΕޙͷষͰ
ୈೋষ ΦʔϓϯϋʔυΣΞ
ΦʔϓϯιʔεϥΠηϯε • ࣗ༝ͳ࠶൦͕Մೳ • ιʔείʔυ͕ೖखͰ͖Δ • ੜΛ࡞ͬͯྑ͍ • ͦͷଞϥΠηϯε͕ܧঝ͞ΕΔͱ͔
ϋʔυΣΞʹ͓͚Δ Φʔϓϯιʔεͱ
ϋʔυΣΞͷιʔε • ϑΝʔϜΣΞ • ճ࿏ਤ • ෦ใ • ج൘ஔਤ
Arduinoͷྫ
ճ࿏ਤ(Arduino Unoͷ߹) http://arduino.cc/en/Main/ArduinoBoardUno
ج൘ஔਤEagleͱ͍͏ ճ࿏ਤ/ج൘ΤσΟλͷܗࣜͰ ൦͞Ε͍ͯΔ
ͭ·Γ؆୯ʹArduinoΛ ࣗ࡞͢Δ͜ͱ͕ग़དྷΔ
ݱʹΫϩʔϯ͕͍ͬͺ͍ଘࡏ͢Δ
ArduinoΛࣗ࡞͢ΔϝϦοτ • ػೳͷՃ • Ϟʔλʔ੍ޚճ࿏ΛΈࠐΉͱ͔ • ϑοτϓϦϯτͷݮগ • ΊͬͪΌখ͍͞ػثʹੵΈ͍ͨ •
ArduinoͷΤίγεςϜͷԸܙΛड͚ΒΕΔ
ϋʔυΛΦʔϓϯʹ͢Δ͜ͱ • ϋοΫΛଅ͢ • ΤίγεςϜ͕ൃల͍͢͠ • ྲྀߦΔͱ͕ͨ͘͞Μग़ͯ͘Δ • ArduinoRasPi໊લΛ͏ͷΛϥΠη ϯεͰ੍ݶ͍ͯ͠Δ
ΦʔϓϯʹͳΕϋʔυΣΞ ͰϚογϡΞοϓ(ࢮޠ) ग़དྷΔͱ͍͏͜ͱͰ͢Ͷ
ୈࡾষ Perl͚ͩͰωΪΛৼΔ
None
ωΪΛৼΔͱʁʁʁ • ݩʑχίχίಈըͷॳԻϛΫಈըͰωΪΛ ৼΔͷ͕͋Δ • χίχίٕज़෦ͰೖಈըͰΑ͘ࡐʹͳ Δ • ͍ΖΜͳͷͰωΪΛৼ͍ͬͯΔ
ҎԼͷറΓͰ࡞Δ • ϋϯμ͚ͳ͠ ϒϨουϘʔυͳ͠ • Arduinoݴޠॻ͔ͳ͍ • Perlॻ͘(YAPCͳͷͰ)
ࡐྉ • Raspberry Pi Model B • Arduino Leonardo(Ոʹ͋ͬͨ) •
GROVE System
GROVE Systemͱ
͜͏͍͏ͪͬͪΌ͍෦͕͋ͬͯ
͜͏͍͏γʔϧυΛArduinoʹࡌ͚ͬͯ
͜Μͳ͔Μ͡Ͱͭͳ͛ͯ͏
͏ͨΊͷϥΠϒϥϦطʹ උ͞Ε͍ͯΔ
Step 1 Raspberry PiͱArduinoͰ ͓͠ΌΓ͢Δ
Firmata͍ͬͯ͏ͷΛ͍·͢ • FirmataArduinoͱ͔ͷϚΠίϯͱPCؒ Ͱ͓͠ΌΓ͢ΔͨΊͷϓϩτίϧ • ͓खܰಋೖՄೳ
ࠓFirmataͰLEDΛޫΒ͢
PerlͰFirmataΛ͠ΌΔ
ArduinoʹFirmataͷ εέονΛॻ͖ࠐΉ
ϋʔυͷ΄͏ͷ४උ • ArduinoͱGROVE Base ShieldΛଓ • γʔϧυͷD4ʹLEDϞδϡʔϧΛଓ • ArduinoͱRaspberry PiΛͭͳ͛Δ
Step 2 αʔϘϞʔλΛ͏
GROVEͷαʔϘϞʔλ D3ʹͭͳ͍ͩ
Step 3 WebΞϓϦԽ͢Δ
Amon2Ͱ࡞Δ
WebΞϓϦͷػೳ • WebSocketͰ֯ใΛड৴ • ͦͷΛRedisʹॻ͖ࠐΉ
ผϓϩηεͷϫʔΧʔ • ແݶϧʔϓͰRedisͷΛࢹ • มԽ͕͋ΕFirmataͰArduinoʹૹ৴
σϞ
࠷ऴষ ࣗ࡞ϋʔυΣΞͱະདྷ
ϋʔυΣΞΛࣗͰ࡞ΕΔ ࣮࣌֬ʹདྷ͍ͯΔ • 3DϓϦϯλͱ͔ੲߟ͑ΒΕͳ͔ͬͨ • ᝑମΛ͔ͬ͜ྑ͘࡞Δ͕ૉૣ͘ղܾ • ϋʔυΣΞΛखചΓ͢Δ࣌ʹͳͬͨ • Make
Fairͱ͔Ͷ
IRKit http://getirkit.com/
IRKit • தArduinoޓج൘ • ͯ͢Φʔϓϯ • ճ࿏ઃܭᝑମͷઃܭΛݸਓͰߦ͏
ϋʔυΣΞΛ͕ͬͭΓΒ ͣʹ࡞ΕΔ࣌ • ࣗͷख׳ΕͨݴޠͰهड़Ͱ͖Δ • ϋϯμ͚ෆཁ • εςοϓΞοϓ͢ΔͱϒϨουϘʔυ ϋϯμ͚͕ඞཁʹͳΔ͚ΕͲ
·ͩ·ͩΓͳ͍͜ͱ (͕Βͳ͍͚͔ͩ) • ΤϯδχΞϦϯάͱͯ͠ͷΈԽ • PerlͰݴ͏CPANΈ͍ͨͳͭ • ษڧձɺϫʔΫγϣοϓ • ςετڥ
ϋʔυΣΞͳਓͱग़ձ͍͍ͨʂ • WebͷਓͱΑ͘ձ͏͚ΕͲɺ͜͏͍͏͜ ͱ͍ͬͯΔਓͳ͔ͳ͔ग़ձΘͳ͍ • ͍ͨΒհͯ͠ཉ͍͠͠ɺ͋ͳ͕ͨͦ͏Ͱ ͋Ε༑ͩͪʹͳ͍ͬͯͩ͘͞
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
࣭ٙԠ ͕࣌ؒ༨ͬͨΒΔ༻
ແઢԽ
γϦΞϧΛແઢԽ • XBee/XBee WiFiͦͷଞແઢLANϞδϡʔϧ • γϦΞϧΛZigBeeWiFiʹมͰ͖Δ • ٕదʹҙ • ւ֎Ϟδϡʔϧి๏ͰҾ͔͔ͬΔͱ
͔͋Δ
RasPi Cam
Raspberry Piઐ༻Χϝϥ • খ͍͍ͦͦ҆͜͜͞͠(2000ԁ) • ͨͩ͠RasPiઐ༻ • RasPiΛϥΠϒΧϝϥͱ͔ʹग़དྷΔ • ϔϦͰ͍·ͨ͠ʢখ͍͞͠USB৯Θͳ͍