since: 2016/01/15
update: 2016/01/15
reference:
A. in header file:
....
/* config file */
bool debug; // debug mode: to show more message or not
float checkTime_second;
/* record datetime to file */
ofBuffer readBuffer;
ofBuffer checkTimeBuffer;
string nowDateString;
-----------------------------------------------------------------------------------------------
B. in c++ file:
1. Read File:
....
// read config file
readBuffer = ofBufferFromFile("config.txt");
//cout << readBuffer.getText(); // let's see what it says
vector<string> lines = ofSplitString(readBuffer, "\n");
for( int i = 0; i < lines.size(); i++){
//cout << lines[i] << endl;
if(i == 1) {
debug = ofToBool(lines[i]);
if(debug) {
ofLog(OF_LOG_NOTICE, ">>>>> debug true");
}
else {
ofLog(OF_LOG_NOTICE, ">>>>> debug false");
}
}
else if(i == 4) {
checkTime_second = ofToFloat(lines[i]);
ofLogNotice(">>>>>>>>> checkTime_second") << checkTime_second;
}
2. Write File:
....
// inner some loop
if(ofGetElapsedTimef() >= checkTime_second) {
ofResetElapsedTimeCounter();
nowDateString = ofGetTimestampString("%Y%m%d%H%M%S");
checkTimeBuffer.set(nowDateString.c_str(), nowDateString.size());
if(ofBufferToFile("dateTime.txt", checkTimeBuffer)) {
ofLogNotice(">>>>>>>>> update checking dateTime") << nowDateString;
}
}
2016年1月15日 星期五
AppleScript: Repeat Checking App Status
since: 2016/01/15
update: 2016/01/15
A. 新增 AppleScript:
1. 開啟 Automator:
2. Automator > 檔案 > 新增 > 應用程式 > 選擇:
3. 工具程式 > 執行 AppleScript > 拖拉到右方
4. 預設程式碼:
on run {input, parameters}
(* Your script goes here *)
return input
end run
-----------------------------------------------------------------------------------------------
B. 修改 AppleScript:
on run {input, parameters}
#
# start: variables defined
#
# script repeat delay time (second)
set repeatDelayTime to 180
# dateTimeFile Path
# /Lanli/RD/project/openFrameworks/of_v0.9.0/apps/myApps/myFirstApp/bin/data/
set dateTimeFilePath to (("Lanli:RD:project:openFrameworks:of_v0.9.0:apps:myApps:myFirstApp:bin:data:") as text)
# dateTimeFile Name
set dateTimeFileName to "dateTime.txt"
# completed dateTimeFile
set dateTimeFile to dateTimeFilePath & dateTimeFileName
# allow time difference to sysDateTime & appUpdateTime (second)
set allowedSecondDiff to 120
# allowed min free memory (MB)
set allowedMinFreeMemory to 0
# my app name
set myAppName to "myFirstApp"
# reboot system or not
set reboot to false
#
# end: variables defined
#
##########################################################
#
# start script repeat
#
repeat
# delay 180 second
# delay 180
delay repeatDelayTime
# start: repeat task
##########################################################
#
# check 01: app update status
#
# Read lines from file.
set fileLines to paragraphs of (read file dateTimeFile as «class utf8»)
# Loop over lines read and copy each to the clipboard.
repeat with perLine in fileLines
set the clipboard to perLine
#display alert (the clipboard)
set appUpdateTime to (the clipboard) as integer
exit repeat # we just need read one line here
end repeat
# get sysDateTime
set sysDateTime to nowTimeFormat() as integer
# check time diff
if (appUpdateTime + allowedSecondDiff) ≥ sysDateTime then
# display dialog "you pass" with title "check app update status" buttons {"OK"} default button 1
else
# display dialog "reboot" with title "check app update status" buttons {"OK"} default button 1
set reboot to true
end if
#
# check 02: system memory free
#
# query memory free (MB)
set vmStats to (text 12 thru -2 of (do shell script "vm_stat | grep 'Pages free'")) * 4096 / 1024 / 1024
# show free Memory
#display dialog vmStats with title "Memory Free (MB)" buttons {"OK"} default button 1
# if vmStats <= 0 MB
if vmStats ≤ allowedMinFreeMemory then
set reboot to true
end if
# for test
#set reboot to false
#
# reboot system or not
#
if reboot is true then
#display dialog "reboot" with title "reboot system or not" buttons {"OK"} default button 1
#step 1: kill your app
tell application "System Events"
set ProcessList to name of every process
if myAppName is in ProcessList then
set ThePID to unix id of process myAppName
do shell script "kill -KILL " & ThePID
end if
end tell
#step 2: reboot system
tell application "Finder"
restart
end tell
else
#display dialog "pass" with title "reboot system or not" buttons {"OK"} default button 1
end if
# end: repeat task
##########################################################
# exit script repeat: for only once execute
#exit repeat
#
# end script repeat
#
end repeat
return input
end run
# nowTimeFormat
on nowTimeFormat()
set theDate to current date
set y to text -4 thru -1 of ("0000" & (year of theDate))
set m to text -2 thru -1 of ("00" & ((month of theDate) as integer))
set d to text -2 thru -1 of ("00" & (day of theDate))
set hh to text -2 thru -1 of ("00" & (hours of theDate))
set mm to text -2 thru -1 of ("00" & (minutes of theDate))
set ss to text -2 thru -1 of ("00" & (seconds of theDate))
# 2016-01-15-10-56-46
#return y & "-" & m & "-" & d & "-" & hh & "-" & mm & "-" & ss
# 20160115105646
return y & m & d & hh & mm & ss
end nowTimeFormat
update: 2016/01/15
A. 新增 AppleScript:
1. 開啟 Automator:
2. Automator > 檔案 > 新增 > 應用程式 > 選擇:
3. 工具程式 > 執行 AppleScript > 拖拉到右方
4. 預設程式碼:
on run {input, parameters}
(* Your script goes here *)
return input
end run
-----------------------------------------------------------------------------------------------
B. 修改 AppleScript:
on run {input, parameters}
#
# start: variables defined
#
# script repeat delay time (second)
set repeatDelayTime to 180
# dateTimeFile Path
# /Lanli/RD/project/openFrameworks/of_v0.9.0/apps/myApps/myFirstApp/bin/data/
set dateTimeFilePath to (("Lanli:RD:project:openFrameworks:of_v0.9.0:apps:myApps:myFirstApp:bin:data:") as text)
# dateTimeFile Name
set dateTimeFileName to "dateTime.txt"
# completed dateTimeFile
set dateTimeFile to dateTimeFilePath & dateTimeFileName
# allow time difference to sysDateTime & appUpdateTime (second)
set allowedSecondDiff to 120
# allowed min free memory (MB)
set allowedMinFreeMemory to 0
# my app name
set myAppName to "myFirstApp"
# reboot system or not
set reboot to false
#
# end: variables defined
#
##########################################################
#
# start script repeat
#
repeat
# delay 180 second
# delay 180
delay repeatDelayTime
# start: repeat task
##########################################################
#
# check 01: app update status
#
# Read lines from file.
set fileLines to paragraphs of (read file dateTimeFile as «class utf8»)
# Loop over lines read and copy each to the clipboard.
repeat with perLine in fileLines
set the clipboard to perLine
#display alert (the clipboard)
set appUpdateTime to (the clipboard) as integer
exit repeat # we just need read one line here
end repeat
# get sysDateTime
set sysDateTime to nowTimeFormat() as integer
# check time diff
if (appUpdateTime + allowedSecondDiff) ≥ sysDateTime then
# display dialog "you pass" with title "check app update status" buttons {"OK"} default button 1
else
# display dialog "reboot" with title "check app update status" buttons {"OK"} default button 1
set reboot to true
end if
#
# check 02: system memory free
#
# query memory free (MB)
set vmStats to (text 12 thru -2 of (do shell script "vm_stat | grep 'Pages free'")) * 4096 / 1024 / 1024
# show free Memory
#display dialog vmStats with title "Memory Free (MB)" buttons {"OK"} default button 1
# if vmStats <= 0 MB
if vmStats ≤ allowedMinFreeMemory then
set reboot to true
end if
# for test
#set reboot to false
#
# reboot system or not
#
if reboot is true then
#display dialog "reboot" with title "reboot system or not" buttons {"OK"} default button 1
#step 1: kill your app
tell application "System Events"
set ProcessList to name of every process
if myAppName is in ProcessList then
set ThePID to unix id of process myAppName
do shell script "kill -KILL " & ThePID
end if
end tell
#step 2: reboot system
tell application "Finder"
restart
end tell
else
#display dialog "pass" with title "reboot system or not" buttons {"OK"} default button 1
end if
# end: repeat task
##########################################################
# exit script repeat: for only once execute
#exit repeat
#
# end script repeat
#
end repeat
return input
end run
# nowTimeFormat
on nowTimeFormat()
set theDate to current date
set y to text -4 thru -1 of ("0000" & (year of theDate))
set m to text -2 thru -1 of ("00" & ((month of theDate) as integer))
set d to text -2 thru -1 of ("00" & (day of theDate))
set hh to text -2 thru -1 of ("00" & (hours of theDate))
set mm to text -2 thru -1 of ("00" & (minutes of theDate))
set ss to text -2 thru -1 of ("00" & (seconds of theDate))
# 2016-01-15-10-56-46
#return y & "-" & m & "-" & d & "-" & hh & "-" & mm & "-" & ss
# 20160115105646
return y & m & d & hh & mm & ss
end nowTimeFormat
標籤:
AppleScript,
Mac OS X
2015年12月29日 星期二
Raspberry Pi: Pi 2 with Pi Mapper update
since: 2015/12/29
update: 2016/02/18
reference:
1. PiMapper
2. openFrameworks
3. Raspberry Pi: Pi 2 with Pi Mapper ---- 1/3
4. Raspberry Pi: Pi 2 with Pi Mapper ---- 2/3
5. Raspberry Pi: Pi 2 with Pi Mapper ---- 3/3
A. 更新版本:
1. Raspberry Pi 2: Raspbian Jessie OS (Release date: 2015-11-21)
2. openFrameworks: v0.9.0 for linuxarmv7
-----------------------------------------------------------------------------------------------
B. 安裝作業系統影像檔:
1. 主要參考: Raspberry Pi: Pi 2 with Pi Mapper ---- 1/3
2. 更新部分:
a. 下載 Raspbian 映像檔, 版本為: Raspbian Jessie (Release date: 2015-11-21)
b. 安裝好 Pi 後, 登入系統預設為桌面環境.
c. 可以直接在 Pi 的組態設定中, 設定自動使用 pi 帳號登入文字模式.
$ sudo raspi-config
> 3 Boot Options
> B2 Console Autologin Text console, automatically logged in as 'pi' user
-----------------------------------------------------------------------------------------------
C. 安裝 openFrameworks
1. 主要參考: Raspberry Pi: Pi 2 with Pi Mapper ---- 2/3
2. 更新部分:
a. download openFrameworks 0.9.0 linuxarmv7 distribution
$ cd
$ curl -O http://www.openframeworks.cc/versions/v0.9.0/of_v0.9.0_linuxarmv7l_release.tar.gz
$ mkdir openFrameworks
$ tar vxfz of_v0.9.0_linuxarmv7l_release.tar.gz -C openFrameworks --strip-components 1
b. Install packages
$ cd /home/pi/openFrameworks/scripts/linux/debian
$ sudo ./install_dependencies.sh
c. compile openFrameworks
$ make Release -j4 -C /home/pi/openFrameworks/libs/openFrameworksCompiled/project
d. 不需要再額外增加 Raspberry Pi 2 makefiles
說明: makefiles 預設已經是 Pi 2 的了, 連結也移除了
e. 也不需要設定環境變數來告知編譯器使用 4 核與使用 armv7 來編譯
f. 編譯範例與執行:
$ cd /home/pi/openFrameworks/examples/graphics/polygonExample
$ make
$ make run
g. 在 Pi 上新增專案方式:
$ cp -R /home/pi/openFrameworks/examples/empty/emptyExample /home/pi/openFrameworks/apps/myApps/myRpiApp
$ cd /home/pi/openFrameworks/apps/myApps/myRpiApp
$ make
$ make run
-----------------------------------------------------------------------------------------------
D. 安裝 Pi Mapper
1. 主要參考: Raspberry Pi: Pi 2 with Pi Mapper ---- 3/3
2. 更新部分:
a. 下載軟體:
$ cd ~/openFrameworks/addons
$ git clone https://github.com/kr15h/ofxPiMapper.git
b. 安裝相依軟體:
$ git clone https://github.com/jvcleave/ofxOMXPlayer.git && git clone https://github.com/bakercp/ofxIO.git
c. 編譯與執行:
$ cd ~/openFrameworks/addons/ofxPiMapper/example
$ make
$ make run
d. create a symbolic link:
$ ln -s ~/openFrameworks/addons/ofxPiMapper ./PiMapper
-----------------------------------------------------------------------------------------------
E. 在 Mac 上安裝 Pi Mapper
1. 先安裝好 openframeworks
http://openframeworks.cc/download/
2. 安裝 Pi Mapper:
$ cd /Lanli/RD/project/openFrameworks/of_v0.9.0/addons
$ git clone https://github.com/jvcleave/ofxOMXPlayer.git
$ git clone https://github.com/bakercp/ofxIO.git
$ git clone https://github.com/kr15h/ofxPiMapper.git
-----------------------------------------------------------------------------------------------
F. 在 Mac 上建立你的 Pi Mapper 專案
1. 執行 projectGenerator app
.... of_v0.9.0/projectGenerator-osx/projectGenerator.app
2. 設定內容:
Project name: myPiMapper
Addons: ofxPiMapper, ofxIO, ofxXmlSettings, ofxGui
> Generate
說明: ofxOMXPlayer 只會在 Pi 上用到, 在此處不需要加入.
3. 新增成功後, 按下 "Close", 並關閉 projectGenerator app
4. 完成後, 可以在 of_v0.9.0/apps/myApps/ 目錄下看到:
myPiMapper 專案資料夾, 底下有二個接著會用到的檔案:
addons.make ---- 編譯時會 addons 的內容
myPiMapper.xcodeproj ---- Xcode 專案檔
5. 用文字編輯器開啟 addons.make 檔案, 於最後面增加 ofxOMXPlayer
說明: ofxOMXPlayer 為 Raspberry Pi 上 openFrameworks 的 video player
6. 開啟 myPiMapper.xcodeproj 專案檔:
a. 於 src 目錄下新增以下檔案:
CustomSource.h, CustomSource.cpp
CrossSource.h, CrossSource.cpp
b. 將 of_v0.9.0/addons/ofxPiMapper/example/src 下的所有程式原始碼,
覆蓋到 of_v0.9.0/apps/myApps/myPiMapper/src 下的所有程式原始碼.
7. 拷貝 of_v0.9.0/addons/ofxPiMapper/example/bin/data 下的所有檔案與資料夾:
defaultSurfaces.xml
sources
到 of_v0.9.0/apps/myApps/myPiMapper/bin/data 下
8. 確認在 Mac 上編譯與執行成功後, 即可將整個 myPiMapper 資料夾上傳到 Pi 的
~/openFrameworks/apps/myApps 目錄下
9. 建立 soft link 並編譯執行:
$ cd
$ ln -s ~/openFrameworks/apps/myApps/myPiMapper ./myPiMapper
$ cd myPiMapper
$ make
$ make run
-----------------------------------------------------------------------------------------------
G. openFrameworks 0.9.2
1. 參考:
a. http://openframeworks.cc/setup/raspberrypi/
b. http://openframeworks.cc/setup/raspberrypi/raspberry-pi-getting-started/
2. 說明:
On the Raspberry 2 although it's architecture is arm7 raspbian only supports arm6 by now
3. 安裝步驟:
$ curl -O http://openframeworks.cc/versions/v0.9.2/of_v0.9.2_linuxarmv6l_release.tar.gz
$ sudo chmod 777 of_v0.9.2_linuxarmv6l_release.tar.gz
$ mkdir of_v0.9.2
$ tar vxfz of_v0.9.2_linuxarmv6l_release.tar.gz -C of_v0.9.2 --strip-components 1
$ cd /home/pi/of_v0.9.2/scripts/linux/debian
$ sudo ./install_dependencies.sh
$ sudo ./install_codecs.sh
$ make Release -C /home/pi/of_v0.9.2/libs/openFrameworksCompiled/project
4. Install PiMapper
$ cd ~/of_v0.9.2/addons
$ git clone https://github.com/kr15h/ofxPiMapper.git
$ git clone https://github.com/jvcleave/ofxOMXPlayer.git && git clone https://github.com/bakercp/ofxIO.git
$ git clone https://github.com/jvcleave/ofxRPiCameraVideoGrabber
(for example-camera used)
5. 內建相機模組: fixed bug for example-camera: check addons.make file
ofxPiMapper
ofxIO
ofxXmlSettings
ofxGui
ofxRPiCameraVideoGrabber
ofxOMXPlayer
6. Reuse the example app by copying it to your apps directory
$ cd
$ cd
$ ln -s /home/pi/of_v0.9.2/apps/myApps/PiMapper ./PiMapper
$ cd PiMapper
$ make
$ make run
-----------------------------------------------------------------------------------------------
H. 備份與回復 Pi SD 卡資料:
1. 參考:
備份與回復樹莓派 Raspberry Pi 的 MicroSD 記憶卡 - G. T. Wang
2. 備份:
$ diskutil list ---> 查詢 SD 卡的磁碟代碼
ex: /dev/disk1
$ sudo dd if=/dev/rdisk1 of=~/Desktop/ofx_0.9.2_PiMapper.img bs=1m
3. 回復:
4. Windows 方式:
工具: Win32 Disk Imager
update: 2016/02/18
reference:
1. PiMapper
2. openFrameworks
3. Raspberry Pi: Pi 2 with Pi Mapper ---- 1/3
4. Raspberry Pi: Pi 2 with Pi Mapper ---- 2/3
5. Raspberry Pi: Pi 2 with Pi Mapper ---- 3/3
A. 更新版本:
1. Raspberry Pi 2: Raspbian Jessie OS (Release date: 2015-11-21)
2. openFrameworks: v0.9.0 for linuxarmv7
-----------------------------------------------------------------------------------------------
B. 安裝作業系統影像檔:
1. 主要參考: Raspberry Pi: Pi 2 with Pi Mapper ---- 1/3
2. 更新部分:
a. 下載 Raspbian 映像檔, 版本為: Raspbian Jessie (Release date: 2015-11-21)
b. 安裝好 Pi 後, 登入系統預設為桌面環境.
c. 可以直接在 Pi 的組態設定中, 設定自動使用 pi 帳號登入文字模式.
$ sudo raspi-config
> 3 Boot Options
C. 安裝 openFrameworks
1. 主要參考: Raspberry Pi: Pi 2 with Pi Mapper ---- 2/3
2. 更新部分:
a. download openFrameworks 0.9.0 linuxarmv7 distribution
$ cd
$ curl -O http://www.openframeworks.cc/versions/v0.9.0/of_v0.9.0_linuxarmv7l_release.tar.gz
$ mkdir openFrameworks
$ tar vxfz of_v0.9.0_linuxarmv7l_release.tar.gz -C openFrameworks --strip-components 1
b. Install packages
$ cd /home/pi/openFrameworks/scripts/linux/debian
$ sudo ./install_dependencies.sh
c. compile openFrameworks
$ make Release -j4 -C /home/pi/openFrameworks/libs/openFrameworksCompiled/project
d. 不需要再額外增加 Raspberry Pi 2 makefiles
說明: makefiles 預設已經是 Pi 2 的了, 連結也移除了
e. 也不需要設定環境變數來告知編譯器使用 4 核與使用 armv7 來編譯
f. 編譯範例與執行:
$ cd /home/pi/openFrameworks/examples/graphics/polygonExample
$ make
$ make run
g. 在 Pi 上新增專案方式:
$ cp -R /home/pi/openFrameworks/examples/empty/emptyExample /home/pi/openFrameworks/apps/myApps/myRpiApp
$ cd /home/pi/openFrameworks/apps/myApps/myRpiApp
$ make
$ make run
-----------------------------------------------------------------------------------------------
D. 安裝 Pi Mapper
1. 主要參考: Raspberry Pi: Pi 2 with Pi Mapper ---- 3/3
2. 更新部分:
a. 下載軟體:
$ cd ~/openFrameworks/addons
$ git clone https://github.com/kr15h/ofxPiMapper.git
b. 安裝相依軟體:
$ git clone https://github.com/jvcleave/ofxOMXPlayer.git && git clone https://github.com/bakercp/ofxIO.git
c. 編譯與執行:
$ cd ~/openFrameworks/addons/ofxPiMapper/example
$ make
$ make run
d. create a symbolic link:
$ ln -s ~/openFrameworks/addons/ofxPiMapper ./PiMapper
-----------------------------------------------------------------------------------------------
E. 在 Mac 上安裝 Pi Mapper
1. 先安裝好 openframeworks
http://openframeworks.cc/download/
2. 安裝 Pi Mapper:
$ cd /Lanli/RD/project/openFrameworks/of_v0.9.0/addons
$ git clone https://github.com/jvcleave/ofxOMXPlayer.git
$ git clone https://github.com/bakercp/ofxIO.git
$ git clone https://github.com/kr15h/ofxPiMapper.git
-----------------------------------------------------------------------------------------------
F. 在 Mac 上建立你的 Pi Mapper 專案
1. 執行 projectGenerator app
.... of_v0.9.0/projectGenerator-osx/projectGenerator.app
Project name: myPiMapper
Addons: ofxPiMapper, ofxIO, ofxXmlSettings, ofxGui
> Generate
說明: ofxOMXPlayer 只會在 Pi 上用到, 在此處不需要加入.
myPiMapper 專案資料夾, 底下有二個接著會用到的檔案:
addons.make ---- 編譯時會 addons 的內容
myPiMapper.xcodeproj ---- Xcode 專案檔
說明: ofxOMXPlayer 為 Raspberry Pi 上 openFrameworks 的 video player
a. 於 src 目錄下新增以下檔案:
CustomSource.h, CustomSource.cpp
CrossSource.h, CrossSource.cpp
b. 將 of_v0.9.0/addons/ofxPiMapper/example/src 下的所有程式原始碼,
覆蓋到 of_v0.9.0/apps/myApps/myPiMapper/src 下的所有程式原始碼.
7. 拷貝 of_v0.9.0/addons/ofxPiMapper/example/bin/data 下的所有檔案與資料夾:
defaultSurfaces.xml
sources
到 of_v0.9.0/apps/myApps/myPiMapper/bin/data 下
8. 確認在 Mac 上編譯與執行成功後, 即可將整個 myPiMapper 資料夾上傳到 Pi 的
~/openFrameworks/apps/myApps 目錄下
9. 建立 soft link 並編譯執行:
$ cd
$ ln -s ~/openFrameworks/apps/myApps/myPiMapper ./myPiMapper
$ cd myPiMapper
$ make
$ make run
-----------------------------------------------------------------------------------------------
G. openFrameworks 0.9.2
1. 參考:
a. http://openframeworks.cc/setup/raspberrypi/
b. http://openframeworks.cc/setup/raspberrypi/raspberry-pi-getting-started/
2. 說明:
On the Raspberry 2 although it's architecture is arm7 raspbian only supports arm6 by now
3. 安裝步驟:
$ curl -O http://openframeworks.cc/versions/v0.9.2/of_v0.9.2_linuxarmv6l_release.tar.gz
$ sudo chmod 777 of_v0.9.2_linuxarmv6l_release.tar.gz
$ mkdir of_v0.9.2
$ tar vxfz of_v0.9.2_linuxarmv6l_release.tar.gz -C of_v0.9.2 --strip-components 1
$ cd /home/pi/of_v0.9.2/scripts/linux/debian
$ sudo ./install_dependencies.sh
$ sudo ./install_codecs.sh
$ make Release -C /home/pi/of_v0.9.2/libs/openFrameworksCompiled/project
4. Install PiMapper
$ cd ~/of_v0.9.2/addons
$ git clone https://github.com/kr15h/ofxPiMapper.git
$ git clone https://github.com/jvcleave/ofxOMXPlayer.git && git clone https://github.com/bakercp/ofxIO.git
$ git clone https://github.com/jvcleave/ofxRPiCameraVideoGrabber
(for example-camera used)
5. 內建相機模組: fixed bug for example-camera: check addons.make file
ofxPiMapper
ofxIO
ofxXmlSettings
ofxGui
ofxRPiCameraVideoGrabber
ofxOMXPlayer
6. Reuse the example app by copying it to your apps directory
$ cd
$ cp -R of_v0.9.2/addons/ofxPiMapper/example of_v0.9.2/apps/myApps/ $ cd of_v0.9.2/apps/myApps$ mv example PiMapper
$ cd
$ ln -s /home/pi/of_v0.9.2/apps/myApps/PiMapper ./PiMapper
$ cd PiMapper
$ make
$ make run
-----------------------------------------------------------------------------------------------
H. 備份與回復 Pi SD 卡資料:
1. 參考:
備份與回復樹莓派 Raspberry Pi 的 MicroSD 記憶卡 - G. T. Wang
2. 備份:
$ diskutil list ---> 查詢 SD 卡的磁碟代碼
ex: /dev/disk1
3. 回復:
$ sudo dd if=~/Desktop/ofx_0.9.2_PiMapper.img of=/dev/rdisk1 bs=1m
4. Windows 方式:
工具: Win32 Disk Imager
2015年12月23日 星期三
openFrameworks: Kinect For Windows V2
since: 2015/12/23
update: 2015/12/23
reference:
1. Setting up Kinect 2 for OpenFrameworks | rbarraza.com
2. elliotwoods/ofxKinectForWindows2 at 0.8.4
A. 系統需求:
1. A Kinect for Windows v2 Device (K4W2)
2. 64bit computer with a dedicated USB 3.0
3. Windows 10, 8, 8.1
4. Update your latest video card driver
5. Install DirectX 11
備註:
a. How to Check Direct X Version in Windows:
(1). Click “Start” > “Run” or hold down the “Windows Key” and press “R“.
(2). Type “dxdiag“, then click “OK“.
(3). The version of DirectX you are currently running will be displayed on your screen.
b. check your system: run the Kinect Configuration Verifier tool
-----------------------------------------------------------------------------------------------
B. 安裝軟體:
1. Kinect SDK v2
2. Visual Studio Express 2012
3. openframeworks v0.8.4
4. ofxKinectForWindows2 addon
-----------------------------------------------------------------------------------------------
C. 執行範例專案:
1. 開啟範例專案
.... openFrameworks\of_v0.8.4\addons\ofxKinectForWindows2\
example\example.sln
2. 設定為啟始專案:
3. 調整 example 與 ofxKinect4Windows2Lib 專案的 "平台工具組":
分別對 example 與 ofxKinect4Windows2Lib 專案作以下的調整:
"點選該專案" > 屬性:
所有組態 > 一般 > 平台工具組 > Visual Studio 2012 (v110)
example:
ofxKinect4Windows2Lib:
4. 建置方案與除錯:
a. 建置 > 建置方案
檢視 > 錯誤清單
b. 將紅線框內的三行程式碼作註解
5. 啟動程式:
建置 > 建置方案 > (啟動)本機 Winows 偵錯工具
-----------------------------------------------------------------------------------------------
D. 建立新的 ofxKinect For Windows2 專案:
1. 使用 OpenFrameworks 的 Project Generator 來產生新的專案:
.... openFrameworks\of_v0.8.4\projectGenerator\projectGenerator.exe
2. 設定專案名稱與要使用的 Addons:
專案名稱: KinectTest
Addons: ofxKinectForWindows2
> CREATE PROJECT
2. 開啟剛剛建立的方案:
.... openFrameworks\of_v0.8.4\apps\myApps\
KinectTest\KinectTest.sln
3. 加入 addons 的 ofxKinectForWindows2 專案:
a. 方案 > 加入 > 現有專案...
b. 瀏覽選取 ....
> ....openFrameworks\of_v0.8.4\addons\ofxKinectForWindows2
\ofxKinectForWindows2Lib\ofxKinectForWindows2Lib.vcxproj
c. 完成後, 可以看到多出了一個新的專案:
ofxKinectForWindows2Lib
4. 幫專案新增 ofxKinectForWindows2.props 屬性工作表:
a. 檢視 > 屬性管理員
b. 加入現有屬性工作表
c. 瀏覽選取屬性工作表:
.... openFrameworks\of_v0.8.4\addons\
ofxKinectForWindows2\ofxKinectForWindows2.props
d. 儲存:
-----------------------------------------------------------------------------------------------
E. 調整專案配置
KinectTest 專案 > 屬性:
1. 所有組態 > 組態屬性 > VC++ 目錄 > Include 目錄 >
加入: $(KINECTSDK20_DIR)\inc
2. 所有組態 > 組態屬性 > VC++ 目錄 > 程式庫目錄 >
加入: $(KINECTSDK20_DIR)\lib\x86
3. 所有組態 > 組態屬性 > 連結器 > 一般 > 其他程式庫目錄 >
加入: $(KINECTSDK20_DIR)\Lib\x86
4. 所有組態 > 組態屬性 > 連結器 > 輸入> 其他相依性 >
加入: $(KINECTSDK20_DIR)\Lib\x86\Kinect20.lib
-----------------------------------------------------------------------------------------------
F. 撰寫程式:
1. 開啟 ofApp.h 程式, 修改如下:
#pragma once
#include "ofMain.h"
#include "ofxKinectForWindows2.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxKFW2::Device kinect;
};
2. 開啟 ofApp.cpp 程式, 修改如下:
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
kinect.open();
kinect.initBodyIndexSource();
kinect.initColorSource();
}
//--------------------------------------------------------------
void ofApp::update(){
this->kinect.update();
}
//--------------------------------------------------------------
void ofApp::draw(){
this->kinect.getBodyIndexSource()->draw(0,0,512,424)
this->kinect.getColorSource()->draw(532,0,640,360);
}
....
-----------------------------------------------------------------------------------------------
G. 建置與執行: (只取部份畫面)
update: 2015/12/23
reference:
1. Setting up Kinect 2 for OpenFrameworks | rbarraza.com
2. elliotwoods/ofxKinectForWindows2 at 0.8.4
A. 系統需求:
1. A Kinect for Windows v2 Device (K4W2)
2. 64bit computer with a dedicated USB 3.0
3. Windows 10, 8, 8.1
4. Update your latest video card driver
5. Install DirectX 11
備註:
a. How to Check Direct X Version in Windows:
(1). Click “Start” > “Run” or hold down the “Windows Key” and press “R“.
(2). Type “dxdiag“, then click “OK“.
(3). The version of DirectX you are currently running will be displayed on your screen.
b. check your system: run the Kinect Configuration Verifier tool
-----------------------------------------------------------------------------------------------
B. 安裝軟體:
1. Kinect SDK v2
2. Visual Studio Express 2012
3. openframeworks v0.8.4
4. ofxKinectForWindows2 addon
-----------------------------------------------------------------------------------------------
C. 執行範例專案:
1. 開啟範例專案
.... openFrameworks\of_v0.8.4\addons\ofxKinectForWindows2\
example\example.sln
分別對 example 與 ofxKinect4Windows2Lib 專案作以下的調整:
"點選該專案" > 屬性:
所有組態 > 一般 > 平台工具組 > Visual Studio 2012 (v110)
example:
a. 建置 > 建置方案
檢視 > 錯誤清單
5. 啟動程式:
建置 > 建置方案 > (啟動)本機 Winows 偵錯工具
D. 建立新的 ofxKinect For Windows2 專案:
1. 使用 OpenFrameworks 的 Project Generator 來產生新的專案:
.... openFrameworks\of_v0.8.4\projectGenerator\projectGenerator.exe
專案名稱: KinectTest
Addons: ofxKinectForWindows2
> CREATE PROJECT
.... openFrameworks\of_v0.8.4\apps\myApps\
KinectTest\KinectTest.sln
a. 方案 > 加入 > 現有專案...
b. 瀏覽選取 ....
> ....openFrameworks\of_v0.8.4\addons\ofxKinectForWindows2
\ofxKinectForWindows2Lib\ofxKinectForWindows2Lib.vcxproj
ofxKinectForWindows2Lib
a. 檢視 > 屬性管理員
b. 加入現有屬性工作表
c. 瀏覽選取屬性工作表:
.... openFrameworks\of_v0.8.4\addons\
ofxKinectForWindows2\ofxKinectForWindows2.props
E. 調整專案配置
KinectTest 專案 > 屬性:
1. 所有組態 > 組態屬性 > VC++ 目錄 > Include 目錄 >
加入: $(KINECTSDK20_DIR)\inc
加入: $(KINECTSDK20_DIR)\lib\x86
加入: $(KINECTSDK20_DIR)\Lib\x86
加入: $(KINECTSDK20_DIR)\Lib\x86\Kinect20.lib
F. 撰寫程式:
1. 開啟 ofApp.h 程式, 修改如下:
#pragma once
#include "ofMain.h"
#include "ofxKinectForWindows2.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxKFW2::Device kinect;
};
2. 開啟 ofApp.cpp 程式, 修改如下:
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
kinect.open();
kinect.initBodyIndexSource();
kinect.initColorSource();
}
//--------------------------------------------------------------
void ofApp::update(){
this->kinect.update();
}
//--------------------------------------------------------------
void ofApp::draw(){
this->kinect.getBodyIndexSource()->draw(0,0,512,424)
this->kinect.getColorSource()->draw(532,0,640,360);
}
....
-----------------------------------------------------------------------------------------------
G. 建置與執行: (只取部份畫面)
標籤:
Kinect,
openFrameworks,
Windows
2015年12月21日 星期一
Processing 3: Kinect for Windows v2
since: 2015/12/21
update: 2015/12/21
reference:
1. ThomasLengeling/KinectPV2
A. 系統需求:
1. A Kinect for Windows v2 Device (K4W2)
2. 64bit computer with a dedicated USB 3.0
3. Windows 10, 8, 8.1
4. Update your latest video card driver
5. Install DirectX 11
備註:
a. How to Check Direct X Version in Windows:
(1). Click “Start” > “Run” or hold down the “Windows Key” and press “R“.
(2). Type “dxdiag“, then click “OK“.
(3). The version of DirectX you are currently running will be displayed on your screen.
b. check your system: run the Kinect Configuration Verifier tool
-----------------------------------------------------------------------------------------------
B. 安裝軟體:
1. Kinect SDK v2
2. Processing 3.0
-----------------------------------------------------------------------------------------------
C. 安裝 Kinect v2 for Processing Library
1. Sketch > Import Library... > Add Library...
2. find: Kinect v2 for Processing > Install
-----------------------------------------------------------------------------------------------
D. 執行範例程式:
1. File > Examples... > Contributed Libraries > Kinect v2 for Processing
> DepthTest > Run
2. 執行結果:
update: 2015/12/21
reference:
1. ThomasLengeling/KinectPV2
A. 系統需求:
1. A Kinect for Windows v2 Device (K4W2)
2. 64bit computer with a dedicated USB 3.0
3. Windows 10, 8, 8.1
4. Update your latest video card driver
5. Install DirectX 11
備註:
a. How to Check Direct X Version in Windows:
(1). Click “Start” > “Run” or hold down the “Windows Key” and press “R“.
(2). Type “dxdiag“, then click “OK“.
(3). The version of DirectX you are currently running will be displayed on your screen.
b. check your system: run the Kinect Configuration Verifier tool
-----------------------------------------------------------------------------------------------
B. 安裝軟體:
1. Kinect SDK v2
2. Processing 3.0
-----------------------------------------------------------------------------------------------
C. 安裝 Kinect v2 for Processing Library
1. Sketch > Import Library... > Add Library...
D. 執行範例程式:
1. File > Examples... > Contributed Libraries > Kinect v2 for Processing
> DepthTest > Run
標籤:
Kinect,
Processing,
Windows
2015年12月20日 星期日
How to Enable TRIM on Third Party SSDs in Mac OS X
since: 2015/12/20
update: 2015/12/20
reference:
1. How to Enable TRIM on Third Party SSDs in Mac OS X with trimforce
A. 檢查目前 Mac 上 SSD 的 TRIM 支援情況:
-----------------------------------------------------------------------------------------------
B. 開啟終端機, 輸入以下的指令:
$ sudo trimforce enable
....
Are you sure you wish to proceed (y/N)? y
....
Your system will immediately reboot when this is complete.
Is this OK (y/N)? y
-----------------------------------------------------------------------------------------------
C. 開機後, 再次檢查目前 Mac 上 SSD 的 TRIM 支援情況:
update: 2015/12/20
reference:
1. How to Enable TRIM on Third Party SSDs in Mac OS X with trimforce
A. 檢查目前 Mac 上 SSD 的 TRIM 支援情況:
B. 開啟終端機, 輸入以下的指令:
$ sudo trimforce enable
....
Are you sure you wish to proceed (y/N)? y
....
Your system will immediately reboot when this is complete.
Is this OK (y/N)? y
C. 開機後, 再次檢查目前 Mac 上 SSD 的 TRIM 支援情況:
2015年12月5日 星期六
Raspberry Pi: 校時, 開機自動執行, 特定重開機, 排程
since: 2015/12/05
update: 2015/12/05
A. 手動校時: $ date
$ date --help | more
// date MMDDhhmm
$ sudo date 11201458
-----------------------------------------------------------------------------------------------
B. 開機後自動執行 python 程式:
1. 撰寫執行 python 的 shell script:
/home/pi/project/run_my_job.sh
#!/bin/sh
cd /home/pi/project
python main_script.py
2. 開機後自動登入 pi 帳號:
$ sudo nano /etc/inittab
....
#1:2345:respawn:/sbin/getty --noclear 38400 tty1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
3. 設定排程:(關機與啟動程式)
$ sudo crontab -e
....
# m h dom mon dow command
00 17 * * * /sbin/shutdown -h now
@reboot /home/pi/project/run_my_job.sh
-----------------------------------------------------------------------------------------------
C. 這次開機, 距離上次開機時間超過 60 秒, 會再重新開機一次
1. 記錄時間的檔案:
/home/pi/project/check_time.txt
檔案內容:(格式: YYYYMMDDhhmmss 每次開機後會被覆寫以更新時間)
20151120115130
2. 檢查的程式:
/home/pi/project/check_reboot.sh
程式內容:
#!/bin/bash
nowtime=`date +%Y%m%d%H%M%S`
lasttime=$(</home/pi/project/check_time.txt)
echo "lasttime: $lasttime"
echo "nowtime: $nowtime"
echo $nowtime > /home/pi/project/check_time.txt
difftime=$(echo $(( nowtime - lasttime )))
echo "difftime: $difftime"
if [ $difftime -gt 60 ]; then
echo "reboot"
sudo reboot
fi
說明: -gt: greater then ; -st: smaller then
3. 加入排程:
$ sudo crontab -e
....
# m h dom mon dow command
00 17 * * * /sbin/shutdown -h now
@reboot /home/pi/project/run_my_job.sh
@reboot /home/pi/project/check_reboot.sh
update: 2015/12/05
A. 手動校時: $ date
$ date --help | more
// date MMDDhhmm
$ sudo date 11201458
-----------------------------------------------------------------------------------------------
B. 開機後自動執行 python 程式:
1. 撰寫執行 python 的 shell script:
/home/pi/project/run_my_job.sh
#!/bin/sh
cd /home/pi/project
python main_script.py
2. 開機後自動登入 pi 帳號:
$ sudo nano /etc/inittab
....
#1:2345:respawn:/sbin/getty --noclear 38400 tty1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1
3. 設定排程:(關機與啟動程式)
$ sudo crontab -e
....
# m h dom mon dow command
00 17 * * * /sbin/shutdown -h now
@reboot /home/pi/project/run_my_job.sh
-----------------------------------------------------------------------------------------------
C. 這次開機, 距離上次開機時間超過 60 秒, 會再重新開機一次
1. 記錄時間的檔案:
/home/pi/project/check_time.txt
檔案內容:(格式: YYYYMMDDhhmmss 每次開機後會被覆寫以更新時間)
20151120115130
2. 檢查的程式:
/home/pi/project/check_reboot.sh
程式內容:
#!/bin/bash
nowtime=`date +%Y%m%d%H%M%S`
lasttime=$(</home/pi/project/check_time.txt)
echo "lasttime: $lasttime"
echo "nowtime: $nowtime"
echo $nowtime > /home/pi/project/check_time.txt
difftime=$(echo $(( nowtime - lasttime )))
echo "difftime: $difftime"
if [ $difftime -gt 60 ]; then
echo "reboot"
sudo reboot
fi
說明: -gt: greater then ; -st: smaller then
3. 加入排程:
$ sudo crontab -e
....
# m h dom mon dow command
00 17 * * * /sbin/shutdown -h now
@reboot /home/pi/project/run_my_job.sh
@reboot /home/pi/project/check_reboot.sh
標籤:
Raspberry Pi
訂閱:
文章 (Atom)