Cov txheej txheem:

Beaglebone Black Web Tswj Siv WebPy: 6 Cov Kauj Ruam
Beaglebone Black Web Tswj Siv WebPy: 6 Cov Kauj Ruam

Video: Beaglebone Black Web Tswj Siv WebPy: 6 Cov Kauj Ruam

Video: Beaglebone Black Web Tswj Siv WebPy: 6 Cov Kauj Ruam
Video: beaglebone black Web Server 2024, Hlis ntuj nqeg
Anonim
Beaglebone Dub Web Tswj Siv WebPy
Beaglebone Dub Web Tswj Siv WebPy
Beaglebone Dub Web Tswj Siv WebPy
Beaglebone Dub Web Tswj Siv WebPy

Puas xav tsim txoj hauv kev los tswj koj lub qhov rooj qhov rooj siv koj lub xov tooj tej zaum sau cov ntaub ntawv thiab saib nws los ntawm koj lub laptop. Muaj ib lub koos pij tawj hu ua Beaglebone Black uas yog lub cuab yeej muaj zog heev uas tso cai rau koj los tswj nws cov GPIO pins txhawm rau cuam tshuam nrog cov khoom hauv ntiaj teb tiag tiag xws li lub cav, LED's, Teeb, thiab lwm yam. Beaglebone zoo ib yam li raspberry pi board tab sis ntau zog dua. Beaglebone zej zog tsis loj npaum li raspberry pi's yog li ceeb toom rau qhov tsis muaj kev qhia.

Raws li kuv tau tshawb nrhiav hauv is taws nem rau kev daws teeb meem los tswj kuv Beaglebone Dub los ntawm kuv lub khoos phis tawj siv lub vev xaib, ntau qhov kev qhia tau tshwm sim siv Beaglebone lub tsev qiv ntawv pob txha thiab lub socket.io tsev qiv ntawv siv huab 9 lub tswv yim. Raws li kuv ua raws cov lus qhia thiab saib cov neeg cov cai Kuv tau ntxhov siab vim qhov tseeb tias huab 9 lub tswv yim khaws cia poob, kuv tsis nkag siab txog javascript thiab tseem tsis muaj qhov hloov pauv ntawm txhua qhov kev qhia (txhua qhov kev qhia yuam koj kom siv tus lej ua ntej PIB). Kuv tau paub txog nab hab sej thiab kuv tus phooj ywg qhia kuv rau web.py uas yog lub vev xaib zoo siv los tsim web apps. Kuv kuj siv Adafruit's Beaglebone Black GPIO lub tsev qiv ntawv los tswj tus kheej tus pin ntawm Beaglebone Dub.

Koj yuav xav tau dab tsi:

  • Ib lub computer
  • SSH lub davhlau ya nyob twg xws li PuTTY lossis siv SSH ntawm lub davhlau ya nyob twg (Rau Mac's thiab Linux, Windows tsis tau ua hauv SSH)
  • Beaglebone Dub txuas nrog lub khoos phis tawj ntawm USB
  • Kev siv internet txuas rau Beaglebone Dub
  • (xaiv tau) Tus neeg siv SFTP

Kauj Ruam 1: Nruab Qhov Yuav Tsum Muaj Python Libraries

Peb yuav tsum teeb tsa ob lub tsev qiv ntawv uas tsis yog tus qauv txheej txheem hauv nab nab 2.7. Cov tsev qiv ntawv yog Adafruit BBIO thiab WebPy cov tsev qiv ntawv. Peb yuav tsum nkag mus rau Beaglebone siv SSH. Kuv txiav txim siab siv PuTTy lub davhlau ya nyob twg thiab nkag mus siv nws tus IP chaw nyob ntawm beaglebone, kuv li yog 192.168.7.2 koj li tuaj yeem pom ntawm beaglebone start.html. Yog tias koj siv Angstrom hom hauv:

  • opkg hloov tshiab && opkg nruab sej-pip sej-setuptools python-smbus
  • pip nruab Adafruit_BBIO
  • pip nruab web.py

Yog tias koj siv Debian lossis Ubuntu:

  • sudo apt-tau hloov tshiab
  • sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus -y
  • pip nruab Adafruit_BBIO
  • pip nruab web.py

Txhawm rau sim yog tias cov tsev qiv ntawv raug teeb tsa kom raug ntaus hauv:

  • nab hab sej
  • ntshuam web
  • ntshuam Adafruit_BBIO. GPIO

Yog tias tsis muaj qhov yuam kev tshwm sim ntawm tus nab hab sej console koj tau teeb tsa lub tsev qiv ntawv kom raug thiab peb tau npaj rau qhov chaws.

Kauj ruam 2: Tus nab npawb Code

Python Code
Python Code

Tus nab npawb nab npawb yog qhov yooj yim nkag siab yog tias koj paub siv nab nab, yog tias koj yog tus pib ua haujlwm rau lub program koj yuav muaj qee qhov teeb meem nkag siab ib feem ntawm txoj cai.

Cov ntaub ntawv ntawm 2 lub tsev qiv ntawv tuaj yeem pom ntawm no:

  • Web.py ua
  • Adafruit GPIO Lub Tsev Qiv Ntawv

Kuv tau sau cov cai thiab tawm tswv yim nws kom koj nkag siab thiab tinker nrog nws.

Kauj Ruam 3: Tsim Lub Vev Xaib

Tsim Web Page
Tsim Web Page

Yog tias koj tus nab npawb nab nab kuv txuas, koj tuaj yeem pom kuv tham txog GET thov. GET thov yog ib txoj hauv kev rau lub vev xaib sib tham nrog tus neeg rau zaub mov. Txhawm rau ntxiv, rho tawm thiab hloov cov txiaj ntsig peb tau siv Jquery ua qee qhov yooj yim tau txais kev thov. Kuv tau txuas ib nplooj ntawv html uas tsuas yog qhov ntawd thiab kuv kuj tau hais tawm cov cai rau koj kom yooj yim.

Cov ntaub ntawv tswj.html nyob ntawm no saib-qhov chaw:

Kauj Ruam 4: Hloov Cov Ntaub Ntawv Python rau Koj Beaglebone

Hloov pauv Python Cov Ntaub Ntawv rau Koj Beaglebone
Hloov pauv Python Cov Ntaub Ntawv rau Koj Beaglebone

Koj tuaj yeem hloov cov ntaub ntawv main.py ntawm kab hais kom ua tab sis hloov cov ntaub ntawv yooj yim Kuv yuav siv WinSCP (koj tuaj yeem siv ib tus neeg siv sftp) uas koj tuaj yeem rub tawm ntawm no. Muaj Cyberduck rau cov neeg siv mac tab sis txij li thaum kuv yog tus siv PC Kuv tsis paub qhov twg yog qhov zoo tshaj yog li koj yuav tsum google nws. Cov txheej txheem yog yooj yim tsuas yog rub cov ntawv main.py hauv Desktop lossis lwm cov npe uas koj xaiv.

Kauj ruam 5: Khiav Server

Khiav tus neeg rau zaub mov
Khiav tus neeg rau zaub mov

Khiav tus neeg rau zaub mov yog yooj yim tsuas yog siv SSH siv PuTTY lossis koj lub davhlau ya nyob twg thiab hloov koj phau ntawv teev npe mus rau cov npe loj.py. Hom hauv:

nab hab sej main.py 1234

Tam sim no yam peb nyuam qhuav tau ua yog nug nab nab los khiav cov ntaub ntawv main.py ntawm chaw nres nkoj 1234

Kauj Ruam 6: Koj Muaj Kev Tswj

Koj Muaj Kev Tswj!
Koj Muaj Kev Tswj!
Koj Muaj Kev Tswj!
Koj Muaj Kev Tswj!
Koj Muaj Kev Tswj!
Koj Muaj Kev Tswj!

Tam sim no mus rau cov ntawv tswj.html thiab qhib nrog google chrome lossis lwm lub browser uas koj siv, koj yuav muaj nplooj ntawv web page nrog 2 lub thawv ntawv thiab 3 khawm. Tus lej tus lej tus lej lub npov nug tus lej tus lej zoo li P8_10 lossis P8_29, thiab lwm yam. Tam sim no koj muaj kev tswj hwm lub vev xaib koj tuaj yeem siv qhov piv txwv no txhawm rau tsim lub vaj huam sib luag zoo dua. Tej zaum siv cov peev txheej peev txheej los siv koj Beaglebone Dub ua cov ntaub ntawv nkag lossis siv nws rau kev siv tshuab hauv tsev, qhov muaj peev xwm muaj qhov kawg. Yog tias koj nyiam cov lus qhia no thov thov pov npav rau txoj haujlwm no ntawm kev sib tw tsim cov npe thiab tseem nyiam txoj haujlwm no. Ua tsaug rau kev nyeem phau ntawv qhia no thiab ua rau hacking!:)

Pom zoo: