Ads 468x60px

##EasyReadMore##

05 10月, 2017

[yoctol] 使用 opkg 安裝 node-red

Opkg(Open PacKaGe Management) is a lightweight package management system. It is written in C and resembles apt/dpkg in operation. It is intended for use on embedded Linux devices and is used in this capacity in the OpenEmbedded and OpenWrt projects.

#OPKG REPO
大多數軟件包管理程序都有repo(或稱源)的概念,opkg的repo位於/etc/opkg/*.conf
原生系統裡只有iokit.conf裡有內容,裡面是mraa和upm(for GPIO)的源
當然我們可以添加自己的或別人的源
較流行的是 repo.opkg.net的源
因為 qurak 屬 i586 所以下面是針對 i586 增加的源:
echo "src i586-1 http://iotdk.intel.com/repos/3.5/iotdk/galileo/i586" > /etc/opkg/iot-cloud.conf
echo "src i586-2 http://iotdk.intel.com/repos/3.0/iotdk/i586" >> /etc/opkg/iot-cloud.conf
echo "src i586-3 http://iotdk.intel.com/repos/iot-cloud/iotdk/3.5/i586" >> /etc/opkg/iot-cloud.conf
echo "src i586-4 http://iotdk.intel.com/repos/iot-cloud-dev/iotdk/3.5/i586" >> /etc/opkg/iot-cloud.conf
echo "src i586-5 http://iotdk.intel.com/repos/1.5/iotdk/i586" >> /etc/opkg/iot-cloud.conf
echo "src i586-6 http://iotdk.intel.com/repos/1.1/iotdk/i586" >> /etc/opkg/iot-cloud.conf
echo "src i586-7 http://iotdk.intel.com/repos/1.0/iotdk/i586" >> /etc/opkg/iot-cloud.conf
其它平台 edison core2-32 … 可增加其它的源:
src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32
src all http://iotdk.intel.com/repos/2.0/iotdk/all
src core2-32 http://iotdk.intel.com/repos/2.0/iotdk/core2-32
src core2-32-intel-common http://iotdk.intel.com/repos/2.0/iotdk/core2-32-intel-common
src i586 http://iotdk.intel.com/repos/2.0/iotdk/i586
src quark http://iotdk.intel.com/repos/2.0/iotdk/quark
src x86 http://iotdk.intel.com/repos/2.0/iotdk/x86
src $隨便寫$URL
#這個url下有個Packages文件
#如果有Packages.gz的可以將src改成src/gz如上上個例子
#即Packages壓縮文件..可能會小一點
#以版號觀察來說,不同的版號會有不同的 package ,也就是說不定日後會有 4.0 之類的
所以有空可以去 http://iotdk.intel.com/repos 看有沒有新的版號出來
#該網址是否可加入來源可用當下目錄是否有 "Packages" 的檔案,該檔案記錄所有 package 的 detail
#加入來源時注意要把 https 改成 http ,否則會不支援
#為什麼要加這麼多版本的源,以3.0~3.5 來說 ,其源不包含 wget ,卻在 1.0 有 wget ,以把所有版本都加進去讓它自己選擇。
#OPKG怎麼用?
GNU/Linux用戶可能會對apt-get,aptitude,pacman,yum等比較熟悉,也會看出其相似之處.
opkg的用法和apt啊pac啊這些類似,從#opkg --help裡可以看出.
英文好的大觸可以用#opkg | less慢慢看
usage: opkg [options...] sub-command [arguments...]
OPKG常用指令:
#opkg update更新可用軟件列表,每次修改源或檢查更新時用的命令(類似apt-get update/pacman -Syy)
#opkg upgrade更新軟件包,據說時刻保持最新是好的..(類似apt-get upgrade/pacman -Su)
#opkg install <pkgs>安裝軟件包(類似apt-get install/pacman -S)
#opkg remove <pkgs>刪除軟件包(類似apt-get remove/pacman -R),這裡有個問題就是得自己手動刪除不需要的依賴包,有個--autoremove選項似乎可以自動刪除,沒測試過.
#opkg list列出可用的安裝包(包括遠端repo),可配合grep搜索想要的包.
example:
opkg upgrade
opkg install make
opkg install g++
opkg install npm
install node-red

opkg update

一定要先做 update  這樣才會把 pack list  下載下來

image
opkg install nodejs

image
opkg install node-red
image
看到這個畫面就代表完成安裝了
需要解安裝就下
opkg remove node-red

input device ip in browser:
http://localhost:1880http://(your-ip-address):1880
you will see result below:

image
上圖是 import → Clipboard 下面的 code 所產生的
[{"id":"246b7763.3bea58","type":"inject","z":"27de6191.6f8d9e","name":"","topic":"","payload":"hello ","payloadType":"str","repeat":"","crontab":"","once":false,"x":243.50001525878906,"y":143.39999389648438,"wires":[["776dd29.d78a22c","b2646984.91cf08"]]},{"id":"776dd29.d78a22c","type":"function","z":"27de6191.6f8d9e","name":"+ world","func":"msg.payload += ' world'\nreturn msg;","outputs":1,"noerr":0,"x":357.50001525878906,"y":232.40000915527344,"wires":[["77ad56dc.6ed438"]]},{"id":"77ad56dc.6ed438","type":"function","z":"27de6191.6f8d9e","name":"+ !","func":"msg.payload += '!';\nreturn msg;","outputs":1,"noerr":0,"x":428.49998474121094,"y":303.40000915527344,"wires":[["b2646984.91cf08"]]},{"id":"b2646984.91cf08","type":"debug","z":"27de6191.6f8d9e","name":"","active":true,"console":"false","complete":"false","x":541.4999847412109,"y":403.59999084472656,"wires":[]}]
import 後就可以在 msg.payload 先按右邊的鍵,再按 hello 左邊的鍵 ,就可以在右邊的 debug 視窗看到輸出的結果

opkg install nano

image

opkg install tcpdump

image

opkg install iftop

image

opkg install python-pip

Reference:
Google Code Archive - Long-term storage for Google Code Project Hosting. - https://goo.gl/zm6a7A
科學幫Intel Edison 系列教程OPKG REPO—Intel Edison論壇—DF創客社區 - https://goo.gl/vNw2QY
Node-Red 範例教學 – HTTP網路聊天室 | PillaKloud - https://goo.gl/i6FapD

0 意見:

張貼留言

 
Blogger Templates