2018/12/28

STM32 Boot Mode

STM32 Boot mode 很有趣,經由 Boot0/1 pin 可以選擇由內部 flash 或是內部 boot rom 開機。
----------------------------------
| BOOT1  | BOOT0 |  Boot Mode    |
----------------------------------
|   x    |   0   | Main Flash    |
----------------------------------
|   0    |   1   | System Memory |
----------------------------------
|   1    |   1   | Embedded SRAM |
----------------------------------
若是選擇由 boot rom 開機,有一個 default download channel 流程,依序檢查下列download path 是否有動作..
  • UART1.3
  • CAN
  • USB
所以不需要額外的 download channel config pin

對應 USB download的 pc tool 是 dfu-tools


STM32F4 Discovery Board

要進入 dfu mode 的話。因為 板子 boot1 , boot0 都是 pull-low
所以要是想進入dfu mode (System Memory) 的話,就要把 BOOT0 設為 High
在 discovery board 上,boot0 的 pin 腳剛好在 VDD 旁邊。
所以只要用 JMP 把這兩個 pin ( BOOT0, VDD) 短路就可以了。

2018/12/27

stm32f4 discovery board, test run in debian.

stlink 沒有 package,要從 source code build
build 文件參考 Compiling

大概就是...需要 build-essential, cmake, libusb-1.0-0-dev , libgtk-3-dev(if stlink-gui)

ref:
發現 debian 有..stlink-tools,package 頁面,列出的主頁面就是texane/stlink
所以大概是一樣的。

所以就 apt-get install slink-tools 就可以

cross-compile 用 gcc-arm-none-eabi 這個 package 就可以。
debian 的 arm-none-eabi-gdb 在 gdb-arm-none-eabi 這個 package 中。

所以合起來,toolchain and download utility 就是.
  • stlink-tools
  • gcc-arm-none-eabi
  • gdb-arm-none-eabi

Test build and run.

libopencm3 的 example 來測試就可以,
git clone https://gitub.com/libopencm3/libopencm3-examples.git
cd libopencm3-examples
git submodule init
git submodule update
然後就可以直接 make..


ref:how to compile and burn the code to stm32 chip on linux ubuntu

很奇怪的是,用 package 的版本,TrueStudio 沒辦法正確invoke。
follow github 版本 make, install 之後,TrueStudio 就可以正卻進入 debug mode..
git clone git@github.com:texane/stlink.git
cd stlink
make release
cd build/Release
然後 sudo make install
log:
[ 23%] Built target stlink-static
[ 46%] Built target stlink
[ 53%] Built target st-info
[ 63%] Built target st-flash
[ 76%] Built target st-util
[ 86%] Built target flash
[ 93%] Built target sg
[100%] Built target usb
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libstlink.so.1.5.1
-- Installing: /usr/local/lib/libstlink.so.1
-- Installing: /usr/local/lib/libstlink.so
-- Installing: /usr/local/lib/libstlink.a
-- Installing: /usr/local/bin/st-flash
-- Set runtime path of "/usr/local/bin/st-flash" to ""
-- Installing: /usr/local/bin/st-info
-- Set runtime path of "/usr/local/bin/st-info" to ""
-- Installing: /etc/modprobe.d/stlink_v1.conf
-- Installing: /etc/udev/rules.d/49-stlinkv1.rules
-- Installing: /etc/udev/rules.d/49-stlinkv2-1.rules
-- Installing: /etc/udev/rules.d/49-stlinkv2.rules
-- Installing: /etc/udev/rules.d/49-stlinkv3.rules
-- Installing: /usr/local/bin/st-util
-- Set runtime path of "/usr/local/bin/st-util" to ""
-- Installing: /usr/local/lib/pkgconfig/stlink.pc
-- Installing: /usr/local/include/stlink.h
-- Installing: /usr/local/include/stlink/backend.h
-- Installing: /usr/local/include/stlink/chipid.h
-- Installing: /usr/local/include/stlink/commands.h
-- Installing: /usr/local/include/stlink/flash_loader.h
-- Installing: /usr/local/include/stlink/logging.h
-- Installing: /usr/local/include/stlink/mmap.h
-- Installing: /usr/local/include/stlink/reg.h
-- Installing: /usr/local/include/stlink/sg.h
-- Installing: /usr/local/include/stlink/usb.h
-- Installing: /usr/local/include/stlink/version.h
-- Installing: /usr/local/share/man/man1/st-util.1
-- Installing: /usr/local/share/man/man1/st-flash.1
-- Installing: /usr/local/share/man/man1/st-info.1
因為 rules 有改變,所以如果不要重新開機,要叫 udev reload:
#udevadm control --reload-rules
#udevadm trigger

TrueStudio 的 Debug Configuration 選 :
  • Debug Probe: ST-LINK
  • Audostart local GDB server
  • Hostname or IP adress : localhost
  • Port Number: 61234
-- all are the default value of 'ST-LINK' option

2018/12/26

build openmv from source

參考 build openMV from source
結果,toolchain 部份就 fail
PPA 只有給 ubuntu 用。debian 是不行的。
結果,在 developer.arm.com 的 cross tool release page 中,連到 ppa 去..其中有..
The tools can be downloaded from any one of the following links:
* https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
* https://launchpad.net/~team-gcc-arm-embedded/+archive/ubuntu/ppa
所以 team-gcc-arm-embedded 的 crosstool 應該就是 developer.arm.com 的 cross tool

wiki 只有說明clone 下來,用Qtcreator 開 project,... 然後 build (?)
沒裝 QtCreator,直接到 src 下 make...
failed:
img/lsd.c:811:18: error: 'new_image_int_ini' defined but not used [-Werror=unused-function]
 static image_int new_image_int_ini( unsigned int xsize, unsigned int ysize,
找 Makefile,把 -Werror 刪掉。
build success!

東西都在 Makefile 裡..
default build target 是 OPENMV3,
果然 firmware/OPENMV3 下的 file 都是新的..所以應該是真的都 open source 無誤。


所以... cross toolchain 好像也沒有一定要是 ppa 的...(not sure, 要 download and run 後才能確認)
整個 build 動作就..
  • clone --recursive
  • cd src, modify Makefile, remove -Werror
  • make

Debian : Create Package From PPA..

竟然有一篇專門講Create Package From PPA

大概就是 ...
  • 一樣把 ppa 加到 repository 中
  • 修改 sources.d 中ppa 的 list,把他改成只能 install source
  • apt-get update, 然後安裝 package source
  • 自己用 debian build tool 把 download 下來的 source build 成 package

實際上,光是 add-apt-repository 時,就會出現 Error:
key D1FAA6ECF64D33B0:
3 signatures not checked due to missing keys
gpg: /tmp/tmpps7zy6_5/trustdb.gpg: trustdb created
gpg: key D1FAA6ECF64D33B0: public key "Launchpad PPA for GCC ARM Embedded Maintainers" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no valid OpenPGP data found.
Exception in thread Thread-1:
.....
FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.browser'

說是 debian 不認識 ubuntu server,所以
~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys  C2518248EEA14886
Executing: /tmp/apt-key-gpghome.tbG3r8NPkE/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys C2518248EEA14886
key C2518248EEA14886:
14 signatures not checked due to missing keys
gpg: key C2518248EEA14886: public key "Launchpad VLC" imported
gpg: Total number processed: 1
gpg:               imported: 1
再..
實際參考 這一篇,但是 package 要改成自己的。
加入自己要 add 的 KEY (D1FAA6ECF64....)
然後還要參考 這一篇修改 ppa list,把 disco 改成ubuntu 的 release name
再做 apt-get update..才會 OK

然後..
~$ apt source --build gcc-arm-embedded
Reading package lists... Done
Need to get 176 MB of source archives.
Get:1 http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu xenial/main gcc-arm-none-eabi 8-2018q4-1~xenial1 (tar) [176 MB]
然後會抱怨有 Unmet build depencies..
把抱怨的 apt-get install 補上..
繼續..
出現..
make[1]: Leaving directory '/home/charles-chang/gcc-arm-none-eabi-8-2018q4/build-native/gcc-first/libiberty'
debian/rules:24: recipe for target 'build-stamp' failed
make: *** [build-stamp] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2
E: Build command 'cd gcc-arm-none-eabi-8-2018q4 && dpkg-buildpackage -b -uc' failed.
..

重新做一次,記下 log, 搜尋結果..
checking whether gcc supports -fno-rtti... yes
configure: error: C++ compiler missing or inoperational
if [ x"-fpic" != x ]; then \
          gcc -c -DHAVE_CONFIG_H -g -O2  -I. -I/home/charles-chang/gcc-arm-none-eabi-8-2018q4/src/gcc/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  -D_GNU_SOURCE -fpic /home/charles-chang/gcc-arm-none-eabi-8-2018q4/src/gcc/libiberty/rust-demangle.c -o pic/rust-demangle.o; \
        else true; fi
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"zlib\" -DVERSION=\"1.1.4\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_MEMCPY=1 -DHAVE_STRERROR=1 -DHAVE_UNISTD_H=1 -I. -I/home/charles-chang/gcc-arm-none-eabi-8-2018q4/src/gcc/zlib      -g -O2 -c -o libz_a-inflate.o `test -f 'inflate.c' || echo '/home/charles-chang/gcc-arm-none-eabi-8-2018q4/src/gcc/zlib/'`inflate.c
make: *** [configure-libcpp] Error 1
make: *** Waiting for unfinished jobs....

2018/12/7

IR High/Low ...

IR 就是用一連串的 high low來傳遞 1, 0 資料。
IR 有各家(NEC, SONY, PANASONIC)的規定。

以 NEC 來說,歸定了...
command

2018/12/3

anbox -- run android in linux container

在 linux containter 中 run android x86 (android 7.1)
並且把 hardware io 改為與 host linux 的 IPC。
所以可以跟 linux host "無縫" 接軌。

只 support ubuntu (好像是因為要改 kernel)

可惜,desktop 沒版法 run ubuntu installer,所以 沒辦法試...

2018/11/26

linux distro for atom ...

Linux-Lite 64bit.

linux-lite-4.1-64bit.iso
光是安裝..感覺就慢了..黑色畫面停留好久...游標才出來...,然後還要好久...title bar 出現..安裝時間好像快 2 hrs...
安裝好就可以用了,要是按下 update 的話.... update 時間比安裝時間更長...
  • browser 是 firefox, youtube 可以播放 480p OK, 720 不行,指示啟動很慢
  • video 用 vlc,可以正常播放 1080p 的 mp4
  • wifi OK, usb auto mount OK
  • apt source 是 ubuntu bionic
開機超慢,要 5 min...

suspend, hibernat 都失敗,會自己起來。
UI 操作還好,大概是因為 xfce,所以mount click 等都不會頓。


Porteus

Porteus-XFCE-v4.0-x86_64.iso
--iso 無法開機。


antiX

antiX-17.2_x64-base.iso
這個USA site 下載比台灣快。
安裝是開機進入 liveCD 後,在桌面有一個 install CD icon,再啟動安裝...

  • browser 是 firefox 跟 dillo, youtube 一樣播放 480p,感覺比 linux-lite 還卡
  • video 用 gnome mpv, 可以播放 1080p沒問題
  • wifi, ethernet 要用 console mode config program - ceni,不知道要怎麼關 wifi (目前是用 ifconfig)
  • apt source 是 debian stretch
  • usb mount OK
開機比較快,少於 1 min
做 apt-get update, upgrade 也是一堆問題要回答..

裝上 nginx,修改 /etcc/nginx/site-available/default,內容只有:
server {
    listen 12345 default_server;
    root /media;
    autoindex on;
    charset utf-8;
}

因為 usb driver c會自動 mount 在 /media/ 下...
但是 mount permission 是 700,只有 user 可以用。nginx 還是不能 access

AntiX 用 udevil,所以修改 /etc/udevil/udevil.conf
其中 ..
diff --git a/udevil.conf b/udevil.conf
index 75a4c0d..166020a 100644
--- a/udevil.conf
+++ b/udevil.conf
@@ -221,7 +221,7 @@ default_options_file      = nosuid, noexec, nodev, noatime, uid=$UID, gid=$GID,
 default_options_iso9660   = nosuid, noexec, nodev, noatime, uid=$UID, gid=$GID, ro, utf8
 default_options_udf       = nosuid, noexec, nodev, noatime, uid=$UID, gid=$GID
 default_options_vfat      = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID, utf8
-default_options_exfat     = nosuid, noexec, nodev, noatime, umask=0077, uid=$UID, gid=$GID, iocharset=utf8, namecase=0, nonempty
+default_options_exfat     = nosuid, noexec, nodev, noatime, umask=0000, uid=$UID, gid=$GID, iocharset=utf8, namecase=0, nonempty
 default_options_msdos     = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID
 default_options_umsdos    = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID
 default_options_ntfs      = nosuid, noexec, nodev, noatime, fmask=0133, uid=$UID, gid=$GID, utf8
@@ -252,7 +252,7 @@ allowed_options_smbfs     = nosuid, noexec, nodev, ro, rw, remount, port=*, user
 allowed_options_sshfs     = nosuid, noexec, nodev, noatime, ro, rw, uid=$UID, gid=$GID, nonempty, allow_other, idmap=user, BatchMode=yes, port=*
 allowed_options_curlftpfs = nosuid, noexec, nodev, noatime, ro, rw, uid=$UID, gid=$GID, nonempty, allow_other, user=*
 allowed_options_ftpfs     = nosuid, noexec, nodev, noatime, ro, rw, port=*, user=*, pass=*, root=*, uid=$UID, gid=$GID
-allowed_options_exfat     = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID, umask=0077, namecase=*, ro, rw, sync, flush, iocharset=*, remount, nonempty
+allowed_options_exfat     = nosuid, noexec, nodev, noatime, fmask=0133, dmask=0022, uid=$UID, gid=$GID, umask=0000, namecase=*, ro, rw, sync, flush, iocharset=*, remount, nonempty
.. 就是修改 umask,由 0077 改 0000
這樣mount permission 就會是 777 了。
--- 其實拿掉 dmask, fmask, umask 等 option 就可以了。

2018/11/6

VS code + python + vim

裝完 VS code 後,安裝 python plugin (當然,也要裝 python)。
然後因為習慣 vi,所以裝 vim edit extension,就可以用 vi 的 command

然後就可以開始寫 python code。

VS Code 可以作到 set break pointer, step 等 debugging 動作。
vscode 會把需要的設定放在 .vscode folder 中,
所以要用到這些 config,source code 就要有獨立的 folder。
-- 類似 project folder 的概念。

open folder -- new 一個。
new file -- save as *.py
開始寫 python code...
左邊 panel 有一個 bug 的 icon,按下去就進入 debug mode。
toolbar 會出現 run, debug 等icon。
在code 左邊邊條就可以按下,會出現紅點,就是 break point。
設完break point 再 run, 就會中斷,然後variablees window 就可以看 local variable.
同樣,上面的 icon 可以做 step , 單布執行。

輸出會在 debug console..


配合 conda

VSCode 的 python extension 會認得 home 中的 conda env
用 Ctrl-Shift-P 叫出設定,輸入 Python:Select,就會出現所有 conda env,選你要用的那個就可以。

2018/11/5

opencv : show hough space diagram

opencv 的 HoughLine( ) 只會給Line data,沒有給轉換成 hough space 的結果(二維陣列)。
所以沒辦法看出轉成 hough space 的樣子。

要作到要用 opencv_contrib 中 ximgproc::FastHoughTransform( )

這個 function有附 example:fast_hough_transform.cpp
如果在安裝opencv 時,build example 的 option 有打開,就會 build。
執行檔是: build/bin/example_ximgproc_fast_hough_transform

實際執行時,default read source : building.jpg 的相對位置好像有問題。
所以要加一層目錄,copy 到下一層目錄去..才能執行起來。

要加在自己的 source code 中,看看 hough space 的結果,要加的function ..
#include <opencv2/ximgproc.hpp>


void rescale(Mat const &src, Mat &dst, int const maxHeight=500, int const maxWidth=1000)
{
       double scale = min(min( static_cast<double>(maxWidth) /src.cols,
                                                       static_cast<double>(maxHeight)/src.rows), 1.0);
       resize(src,dst, Size(),scale,scale,INTER_LINEAR_EXACT);
}

void showhough(Mat const &fht)
{
       double minv(0),maxv(0);
       minMaxLoc(fht,&minv,&maxv);
       Mat ucharFht;
       fht.convertTo(ucharFht,CV_MAKETYPE(CV_8U,fht.channels()), 255.0/(maxv+minv), minv/(maxv+minv));

       rescale(ucharFht,ucharFht);
       imshow("fast hough transform", ucharFht);
}
然後才能在主程式 call FastHoughTransform..
       Mat hough;
       ximgproc::FastHoughTransform(dst,hough, CV_32S,6,2,1); // dst is source image
       showhough(hough);
       waitKey(0);


Example : building.jpg 做出來的 hough space image 是..



另外有一個人自己寫了 hough transform ,有提供 hough space 輸出:
hough transform c++ implementation
source code 在 github: https://github.com/brunokeymolen/hough

2018/10/26

opencv3.4.1/opencv4 , ubuntu 18.04

install opencv4 on ubuntu18.04

follow 這一篇,修改一下 CMakeCache.txt,因為,我的cuda安裝在/usr/loca/cuda/,所以要改..
CUDA_HOST_COMPILER:FILEPATH=/usr/local/cuda/bin/gcc
NVCC 也一樣,用 /usr/local/cuda/bin/nvcc

然後,參考這一篇,加上:
CUDA_NVCC_FLAGS:STRING=--expt-relaxed-constexpr
最後他會說example link cuda error,參考 ..
把 WITH_TBB 改 OFF

... 好麻煩,,, disable CUDA 好了.. 修改 WITH_CUDA=OFF



單獨抽出 opencv build & install
clone opencv & opencv_contrib
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=~/opencv/3.4.1 -D INSTALL_C_EXAMPLE=ON -D WITH_TBB=OFF -D WITH_CUDA=OFF -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D BUILD_EXAMPLES=ON ..

opencv4.0.0 的話,看 CMakeList:
OCV_OPTION(OPENCV_GENERATE_PKGCONFIG  "Generate .pc file for pkg-config build tool (deprecated)" OFF )
default 是不會產生pkgconfig 的。
要的話,要自己打開。
測試在 cmake 時 define ON,結果沒有校。
要手動修改 CMakeList 的這個 option,改成 ON,然後再 cmake .....
再 make install 之後,會在 install 目錄的 lib 下有 pkgconfig folder,其中
~/opencv4inst/lib/pkgconfig$ cat opencv4.pc 
# Package Information for pkg-config

prefix=/home/charles-chang/opencv4inst
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv4/opencv
includedir_new=${prefix}/include/opencv4

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 4.0.0
Libs: -L${exec_prefix}/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_photo -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_flann -lopencv_xphoto -lopencv_imgproc -lopencv_core
Libs.private: -ldl -lm -lpthread -lrt
Cflags: -I${includedir_old} -I${includedir_new}

2018/10/15

n450 netbook debian

install debian 9.5 stretch (amd64)
安裝選 Debian Desktop Environment
裝完就有 GUI 了。

wifi 是 RT3090 (ralink)
開啟 wifi panel,出現 "firmware missing"
在 apt/source.list 中,加non-free
apt-get update 後,search ralink,結果是 firmware-ralink
這個屬於 firmware-misc-nonfree
裝完就可以在 GUI 上開啟 wifi 了。

自動 login
是用 gdm3 (/etc/gmd3),所以開啟 daemon.conf
Enable Automatic login
..

感覺很頓,反應很慢...
改 32 bit 試試看 (i386)

一樣,裝完之後,加入non-free,安裝 firmware-ralink
chrome 因為沒有 32bit 版本,只好裝 chromium

-- 反應似乎比amd64 快一點...

另外試過 lubuntu amd64 版本,反應也不太好..
UI 字體安排很不習慣,但是是一裝好,wifi, bt, videocam 都 ready 就是。

接著安裝lenny i386 看看...

2018/10/8

follow https://wiki.libsdl.org/Installation#Linux.2FUnix 但是 用 https://github.com/SDL-mirror/SDL

裝在自己 local 的目錄:~/imageprogram/SDL:
cd SDL
mkdir build && cd build
../configure --prefix=/home/charles-chang/imageprogram/SDL
make 
make install
姊果救會裝在 --prefix 指定的 path

基本的 make options
gcc -o myprogram myprogram.c `sdl2-config --cflags --libs`

2018/10/2

windows 7, git push hang....

在windows 7 上,開啟cmd,用 git command line tool, push to remote,會hang 住。
ref:Git protocol hangs indefinitely
要加上這個設定:
git config --global sendpack.sideband false
之後就可以了。

這一篇 有詳細說明。
是 msys 的 git 有 bug,所以拿source code 來改,重 build 一次就 OK
但是他用edit hex code (exe file) 的方法...

windows 7, python 3.7 , IDLE subsubprocess cannot connect...

google 結果的確是有一堆人有這個 Error,但是大多是 python source 與 library 衝突的關係。
解法大多是把 python install 的根目錄下所有 *.py 刪除後,重新開機就可以。
但是我的python 安裝根目錄沒有 .py。

ref: 這一篇
用command line :
C:\python -m idlelib
O:\.idlerc
 Check path and permission
Exiting!
原來我得原因是 login home folder 錯誤...

開啟 cmd,用 set 命令列出所有環境變數,其中有:
HOMEDRIVE=O:

參考這一篇,環境變數可以用 SET 命令變更。
所以,開啟 command line,輸入:
C:\> SET HOMEDRIVE=C:\Users\myusername
之後再run python libidle 就正常了。

但是這樣只對那個 cmd 內的program 有效。

2018/8/22

get back from grub console

ref:
grub>ls
(hd0) (hd1) (hd1,gpt2) (hd1,gpt1)
grub>set root=(hd1,gpt2)
set root 完,就可以用 ls / 看 foler..
grub>ls /
./ ../ lost+found/ boot/ swapfile/ etc/ media/ var/ bin/ dev/ home/ lib/ lib64/
..
看一下 /boot,裡面有boot kernel image..
grub>ls /boot
./ ../ efi/ grub/ 
abi-4.15.0-32-generic
config-4.15.0-32-generic
vmlinuz-4.15.0-32-generic
initrd.img-4.15.0-32-generic
System.map-4.15.0-32-generic
retpoline-4.15.0-32-generic
..
只 , kernel 和 root image..
grub> linux /boot/vmlinuz-4.15.0-32-generic
要能正常進入 grub gui boot,要 run normal command。
在此之前,要 load normal.mod。
所以要找一下 normal.mod 在哪裡。
一般會在 /boot/grub/x86_64/ 下。
然後設好 prefix 變數 (就是 grub.config 所在 path)。
之後就可以用 normal command 啟動。

正常啟動 之後,用 grub-update 根據現況更新 grub.config …然後用 grub-install block-device (/dev/sda2. e.g) 就可以把正常grub.conf 安裝到正確目錄。

2018/7/24

ubuntu 18.04 - 回到以往 task-switch 的方式,不要 groupe same app

ubuntu 的 task-switch 很討驗,會把相通的 application 放在一起,所以用 alt-tab 切換 application 時,沒辦法 go through all application。
follow 這一篇: How to prevent Gnome-shell's Alt+Tab from grouping windows from similar apps?:
From the comment by 'xaeth' on this Ergo Project blog post, I have learned that Alt+Esc will cycle through all windows without grouping by application.
This was the simplest solution for me, and I'm glad it saved me from having to install other programs.

If testing with Alt+Esc turns out favorably for you,
then you can go to System Settings > Keyboard > Shortcuts > Navigation and reassign Alt+Tab to perform the navigation task that was previously assigned to Alt+Esc.
In my settings this task is named 'Switch windows directly'.

2018/7/23

把自己upload 到 google play books 的書 download 下來..

如果是從 google play book store 買的書,都會附有一個 download link。
如果是自己 upload 的,就只有一個 delete button。
要 download 的話,就要用 google takeout。

2018/7/16

Run X client program remotely

在ssh 連線時,使用 "Y" 選項就可以。
   -Y      Enables trusted X11 forwarding.  Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.
這樣,在這個連線 termainal(session) 中 run 起來的 X client,都會通過這個 ssh 連線向這端提出 x request

2018/7/2

Linux - add network printer

想不到現在linux 要增加 網路列表機已經這麼方便了。
需要 cups (這個應該desktop version 都會預裝)。
UI 的 tool 就是 system-config-printer,用 apt-get 安裝。
裝完會在 System - Administration 出現,或是在 Controler Setting 中。

開啟後,用 "Add" 來新增。
接著選 "Network Printer",在 Enter Device URI 或是 search 的dialog 輸入你知道的列表機 ip address。
接著就會列出在這個 address 找到的 printer (protocol and service, port)。
選你知道的,或是try 一下。以這邊的例子,試選 jetdirect。
driver 要是不知道就選 Generic Postscript。

2018/6/28

caffe, more -- trainning

follow 這一篇Building a Cat/Dog Classifier using a Convolutional Neural Network 做一次。

用的 dataset 是 Kaggle Cats vs Gogs,到 dataset page,中間有個file browser 框,上面有一下下載icon,就可以download。
-- 需要login, 可以用google 帳號 sign in.

要 run create_imdb.py 時,要改一下,因為裡面的 image. db path 都是寫死的
create_lmdb.py 需要 opencv-python, lmdb 和指定 PATHONPATH
export PYTHONPATH=~/caffe/python:$PYTHONPATH
sudo pip install lmdb opencv-python
其中 ~/caffe 是當初 download and build caffe source 的位置。

train ...
結果遇到:F0629 19:34:17.674513 17917 syncedmem.cpp:71] Check failed: error == cudaSuccess (2 vs. 0) out of memory

nfs server. export option : secure insecure

同事 A 先生Virtualbox VM mount nfs fail,說是server 權限不符。
查一下 nfs server 的 auth.log,出現 mount.rpc port XXXXX 不符合問題。
後來 A 先生改 nfs server 的 exports 檔,把 export path option 中 secure 改 insecure 後 OK 了。

用另一台 server nat 測試。不會有這個問題。
所以猜我們用 iptable 開啟nat 和 virtualbox vm nat 的 port 轉換範圍應該不一樣。

2018/6/27

caffe, test ..

follow Training LeNet on MNIST with Caffe
GPU: (1050i)
real 1m25.823s
user 1m10.579s
sys 0m19.228s
CPU:
real 11m25.795s
user 11m28.551s
sys 0m0.444s

git clone caffe 下來,在 example folder 有 mnist。

先 download data:
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh
開始 run train in..
./examples/mnist/train_lenet.sh
run 完,結果會是在 example/mnist 下..lenet_iter_*

修改 example/mnist/lenet_solver.prototxt,最後一行 solver_mode: GPU 改 CPU,就可以強至用 CPU training

caffe 附的一些 tool,可以用來看 training 的 trainning error ..
把 train 時的 log 紀錄到一個 file:
./examples/mnist/train_lenet.sh 2>&1 | tee -a lenet
然後用 parse_log.py 整理一下...
./tools/extra/parse_log.py lenet .
會產生 lenet.test, lenet.train

寫 plotcmd,教給 gnuplot 執行...
set datafile separator ','
set term x11 0
plot './lenet.train' using 1:4 with line,\
     './lenet.test' using 1:5 with line
用 gnuplot 畫出來..
gnuplot -persist plotcmd




使用 GTX-950M:
real 2m32.821s
user 1m53.398s
sys  0m43.228s

2018/6/25

caffe , cuda

follow caffe installation guide, ubuntu (>17.04)
sudo apt-get install caffe-cuda

這好像只有 install binary & libary。其他部份好像還是要 build from source。
利用 apt src 的 build-dep 自動把 build caffe-cuda 需要的 package 安裝起來:
這個command 須要先把sources.list 中 deb-src un-comment 掉..
他會安裝 gcc6
sudo apt build-dep caffe-cuda
然後就可以 git clone https://github.com/BVLC/caffe.git
然後依照 說明。 copy Makefile.config.example Makefile.config 來修改。
如果是用 cuda + cpu,就都不用改。
cp Makefile.config.example Makefile.config
# Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)
make all
make test
make runtest
但是依照這一篇,要un comment USE_PKG_CONFIG := 1

然後 make all 就出現問題: Unsupported gpu architecture 'compute_20'
參考這一篇
After more research I found that the newest cuda version (9.0) doesn't support compute_20 anymore. 
This means that you have two options, disable the compute_20 target or install cuda version 8.0. 
If your GPU supports newer compute architectures you should use the newest cuda version and disable compute_20.
果然,在 Makefile.config 中有...
# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
# For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
                -gencode arch=compute_20,code=sm_21 \
                -gencode arch=compute_30,code=sm_30 \
                -gencode arch=compute_35,code=sm_35 \
                -gencode arch=compute_50,code=sm_50 \
                -gencode arch=compute_52,code=sm_52 \
                -gencode arch=compute_60,code=sm_60 \
                -gencode arch=compute_61,code=sm_61 \
                -gencode arch=compute_61,code=compute_61

接著是 hdf5.h : No such file or directory Error。
參考這一篇,有一些 make caffe 的問題解決方法。
修改 Makefile.config:
--- INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
+++ INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

之後是 cannot find -lhdf5_hl, -lhdf5 Error..
一樣,剛剛的link 說..修改 Makefile
--- LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
+++ LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
OK

接著就要看 A step by step guide to Caffe Training LeNet on MNIST with Caffe

出現 opencv error:
.build_release/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)
但是又真的有裝 libopencv 的話。
可以改一下 ..Make.config,
 # Uncomment to use `pkg-config` to specify OpenCV library paths.
 # (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
-# USE_PKG_CONFIG := 1
+USE_PKG_CONFIG := 1

如果要 run python/ 下的 tool 的話,還要安裝一些 python module,寫在 python/requirement.txt:
sudo pip install -r requirement.txt


在 make runtest 時出現錯誤:
Check failed: error == cudaSuccess (35 vs. 0) CUDA driver version is insufficient for CUDA runtime version
發現是因為 /usr/share/cuda link 到 cuda-10.1,但是 nvidia-smi 顯示的 cuda 版本卻是 10.0
代表 driver 和 library 不match (大概是apt 更新的)。
所以重新把 /usr/share/cuda link 到 cuda-10.0 之後就沒問題了。

2018/6/22

cuda9.0 + cunn 7.05 on ubuntu 18.04

tensorflow 官網使用 cuda Toolkit 9.0, 如果在 ubuntu 18.04 上 build 的話,要改用就版本的 gcc (ubuntu 18.04 的 gcc 太新)。

這一篇 5 月的文,好像有 2018 的 patch,安裝好像沒提到要重新 build。直接用 17.10 的 deb + patch 就可以了。

使用 cuda 9.2 的話,package 好像還沒完成,所有相依的 package 都要自己 build 過一次。(雖然github 上已經有 build 完成的 script)
所以,為求簡單,還是依照 cuda toolkit 9.0 有支援的版本 (16.04, 17.10) 選一個。(16.04 是 LTS, support 到2021)。

然後 nvidia cuda toolkit 網站download link 是 9.2, 9.0 要到 archive 去找。
所以不能 follow nvidia cuda toolkit 的 link download


真的,跟這個 說明的一樣。可以直接在 18.04 上安裝cuda-9.0 和 cudnn 7.05,不會有 gcc 版本過新的問題。

然後 pip install tensorflow 時出現 exception .... MemoryError,有一個 link 說,加上 --no-cache-dir 就可以。
然後 follow 說明.. 開啟 python..try:
>>from tensorflow.python.client import device_lib
>>device_lib.list_local_devices()
2018-06-25 10:45:58.955248: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-06-25 10:45:59.256407: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-06-25 10:45:59.257329: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1356] Found device 0 with properties: 
name: GeForce GTX 1050 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
pciBusID: 0000:01:00.0
totalMemory: 3.95GiB freeMemory: 3.56GiB
2018-06-25 10:45:59.257385: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 0
2018-06-25 10:46:04.408233: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-06-25 10:46:04.408308: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929]      0 
2018-06-25 10:46:04.408330: I tensorflow/core/common_runtime/gpu/gpu_device.cc:942] 0:   N 
2018-06-25 10:46:04.425190: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/device:GPU:0 with 3290 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 1869392221051952077
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 3450404864
locality {
  bus_id: 1
  links {
  }
}
incarnation: 8818617857580197841
physical_device_desc: "device: 0, name: GeForce GTX 1050 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1"
]



想要 follow 這一篇, test build cuda sample 得話。會出現 gcc 版本太新問題。
所以,遵照這一篇,裝完m gcc-6, g++6 (好像已經裝好),
然後手動建 gcc-6 link 到 /usr/local/cuda/bin/gcc, g++ 也一樣。
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
就可以 make OK 了。


200823 更新:
ubuntu 18.04. CUDA 10.2
libgflags-dev libgoogle-glog-dev liblmdb-dev libboost-all-dev libprotobuf-dev protobuf-compiler libhdf5-dev libleveldb-dev libsnappy-dev libopencv-dev libatlas-base-dev python-numpy
cmake 3.10 一樣會在link 的時候找不到 cublas.要用 3.14 以上版本。可以自己build一個版本

使用 cuda10.2 之後,系統就只有 cmake 的問題,其他都不用修改了。
上面的 package install 完,改 cmake 3.14 之後..
mkdir build && cd build
cmake ..
make
make install
這樣就可以了。

install path 是 caffe/build/install

lenovo legion Y520 -- ibus-chewing

輸入法要在 Settings-- Region and Language -- Input Sources 中選到才算數。
所以在 input Sources 下面那個 + 號,Chinese(Chewing) 要有出現才行。

但是現在18.04 好像有一個bug : How can I use chewing input method
所以,要手動切一下 locale..
:~$ sudo locale-gen zh_TW.UTF-8
然後再選 + 才會出現。
-- 好像還要 logout ..

還有 Language Support -- keyboard input methog system 選的是 ibus。

lenovo legion Y520 -- nvidia and cuda toolkit

趁特價買了。
接 usb3.0 HD,安裝 Linux

先試 ubuntu 18.04 (因為也是 LTS)。
用迴紋針按一下左邊側面的小洞,開機進入 bios。disable security boot。
用拇指疊開機,install 到另一個 usb hd
安裝一個 ESP partition 和一個 ext4。
開機按 F12 進入 boot 選單,會自動列出有開機能力的 partition (device)。
裝完也可以正常開機,但是 lspci 找不到 nvidia。
還有開一陣子system hang.. touch/keyboard 沒反應。

拆開,換上 8G ram 了。
猜開有點難,用指甲一點一點化開,但是 RJ45 那邊很緊,只好從後面開過來。
DDR 用一個鐵蓋子蓋起來。

follow 這一篇,他說 18.04 已經內建 cuda toolkit。所以用 apt 安裝就可以..
sudo apt install nvidia-cuda-toolkit 
sudo apt-add-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-driver-396
重新開機。用 command 看..
~$ nvidia-smi
Fri Jun 22 16:40:36 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.24.02              Driver Version: 396.24.02                 |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 105...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   36C    P8    N/A /  N/A |    515MiB /  4042MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      8154      G   /usr/lib/xorg/Xorg                            28MiB |
|    0      8245      G   /usr/bin/gnome-shell                          58MiB |
|    0     15542      G   /usr/lib/xorg/Xorg                           203MiB |
|    0     15711      G   /usr/bin/gnome-shell                          91MiB |
|    0     17581      G   ...-token=B5E610D3E9F21DF705985515A610A2E7   132MiB |
+-----------------------------------------------------------------------------+


~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85


~$ sudo apt-get install clinfo
~$ clinfo
Number of platforms                               1
  Platform Name                                   NVIDIA CUDA
  Platform Vendor                                 NVIDIA Corporation
  Platform Version                                OpenCL 1.2 CUDA 9.2.127
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts cl_nv_create_buffer
  Platform Extensions function suffix             NV

  Platform Name                                   NVIDIA CUDA
Number of devices                                 1
  Device Name                                     GeForce GTX 1050 Ti
  Device Vendor                                   NVIDIA Corporation
  Device Vendor ID                                0x10de
  Device Version                                  OpenCL 1.2 CUDA
  Driver Version                                  396.24.02
  Device OpenCL C Version                         OpenCL C 1.2 
  Device Type                                     GPU
  Device Topology (NV)                            PCI-E, 01:00.0
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               6
  Max clock frequency                             1620MHz
  Compute Capability (NV)                         6.1
  Device Partition                                (core)
    Max number of sub-devices                     1
    Supported partition types                     None
  Max work item dimensions                        3
  Max work item sizes                             1024x1024x64
  Max work group size                             1024
  Preferred work group size multiple              32
  Warp size (NV)                                  32
  Preferred / native vector sizes                 
    char                                                 1 / 1       
    short                                                1 / 1       
    int                                                  1 / 1       
    long                                                 1 / 1       
    half                                                 0 / 0        (n/a)
    float                                                1 / 1       
    double                                               1 / 1        (cl_khr_fp64)
  Half-precision Floating-point support           (n/a)
  Single-precision Floating-point support         (core)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  Yes
  Double-precision Floating-point support         (cl_khr_fp64)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Address bits                                    64, Little-Endian
  Global memory size                              4238737408 (3.948GiB)
  Error Correction support                        No
  Max memory allocation                           1059684352 (1011MiB)
  Unified memory for Host and Device              No
  Integrated memory (NV)                          No
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       4096 bits (512 bytes)
  Global Memory cache type                        Read/Write
  Global Memory cache size                        98304 (96KiB)
  Global Memory cache line size                   128 bytes
  Image support                                   Yes
    Max number of samplers per kernel             32
    Max size for 1D images from buffer            134217728 pixels
    Max 1D or 2D image array size                 2048 images
    Max 2D image size                             16384x32768 pixels
    Max 3D image size                             16384x16384x16384 pixels
    Max number of read image args                 256
    Max number of write image args                16
  Local memory type                               Local
  Local memory size                               49152 (48KiB)
  Registers per block (NV)                        65536
  Max number of constant args                     9
  Max constant buffer size                        65536 (64KiB)
  Max size of kernel argument                     4352 (4.25KiB)
  Queue properties                                
    Out-of-order execution                        Yes
    Profiling                                     Yes
  Prefer user sync for interop                    No
  Profiling timer resolution                      1000ns
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            No
    Kernel execution timeout (NV)                 Yes
  Concurrent copy and kernel execution (NV)       Yes
    Number of async copy engines                  2
  printf() buffer size                            1048576 (1024KiB)
  Built-in kernels                                
  Device Extensions                               cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts cl_nv_create_buffer

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  NVIDIA CUDA
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [NV]
  clCreateContext(NULL, ...) [default]            Success [NV]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  No platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  Invalid device type for platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  No platform

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.2.11
  ICD loader Profile                              OpenCL 2.1


好像更新完 nvidia driver 之後,就不會 hang 住了。

2018/6/14

[30518.225322] usb 3-1.2: new full-speed USB device number 5 using xhci_hcd
[30518.375490] usb 3-1.2: New USB device found, idVendor=0a12, idProduct=0001
[30518.375492] usb 3-1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[30518.375493] usb 3-1.2: Product: CSR8510 A10

dbus an simple service example in python

ref: Register a “Hello World” DBus service, object and method using Python

service 的 source code 就是..
import gobject
import dbus
import dbus.service

from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)


OPATH = "/com/example/HelloHell"
IFACE = "com.example.HelloHell"
BUS_NAME = "com.example.HelloHell"


class Example(dbus.service.Object):
        def __init__(self):
                bus = dbus.SessionBus()
                bus.request_name(BUS_NAME)
                bus_name = dbus.service.BusName(BUS_NAME, bus=bus)
                dbus.service.Object.__init__(self, bus_name, OPATH)

        @dbus.service.method(dbus_interface=IFACE + ".SayHello",
                        in_signature="", out_signature="")
        def SayHello(self):
                print "hello, world"


if __name__ == "__main__":
        a = Example()
        loop = gobject.MainLoop()
        loop.run()
用 python run 起來後,用 dbus-send 送message 給'他',就會print Hello 出來..
dbus-send --session --print-reply --type=method_call --dest=com.example.HelloHell /com/example/HelloHell com.example.HelloHell.SayHello.SayHello

2018/6/11

raspberry pi 3 and bluez

follow 這一篇 其中 update bluez 的部份。
把 bluez 由 5.43 升級到 5.49,這樣 bluetoothconf 的 error message 就消失了。

另外這一篇 也有更新到 5.48 的步驟

這一篇 的回答有 dbus-send 的用法。

這一篇用 pi 3 做 ibeacon

2018/6/8

bookmark : nordic build with gcc on linux

官方文件 雖然寫的是 eclipse,但是也包含一些 command line 的操作方式。
大概是:

先到arm 下載安裝ㄤ arm gcc croos toolchain
apt-get install build-essential checkinstall
nordic developer site 下載 SDK.zip,解開。
修改 components/toolchain/gcc/Makefile.posix
依照你的 arm gcc cross tool 安裝途徑,版本修改..,我的是..
GNU_INSTALL_ROOT ?= /usr/bin/
GNU_VERSION ?= 5.4.1
GNU_PREFIX ?= arm-none-eabi
然後就可以到 examples/peripheral/<board name>/blank/armgcc/ 下 make 了。
make 完會在這個目錄下create _buil 目錄。

接著就是燒錄...

另一篇 也是一樣的步驟。
而且是在
EVB 是 nRF52840-DK,上面做jlink debugger 的是 PCA10056
有關linux 開發環境的文件: nRF52840-PCA10056
至於一般的 board user guide,在 download 的 SDK 解開後的 document 目錄:index.html

2018/6/7

BLE GATT Example for Android 6

Android 6 之後,BLE Scan 需要得到 Location 權限。
所以以前的 example 就要修改了,否則 scan 不出東西,logcat 還會出現 need permission COARSE_LOCATION or FINE_LOCATION

文章參考"BLE Scan Not Working"這裡

我也修改了一下,最少修改。放在: android-BluetoothLEGatt,branch : fixAndroid6
大概就是..
diff --git a/Application/src/main/AndroidManifest.xml b/Application/src/main/AndroidManifest.xml
index d3cf257..7979018 100644
--- a/Application/src/main/AndroidManifest.xml
+++ b/Application/src/main/AndroidManifest.xml
@@ -32,6 +32,7 @@
 
     <uses-permission android:name="android.permission.BLUETOOTH"/>
     <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 
     <application android:label="@string/app_name"
         android:icon="@drawable/ic_launcher"
diff --git a/Application/src/main/java/com/example/android/bluetoothlegatt/DeviceScanActivity.java b/Application/src/main/java/com/example/android/bluetoothlegatt/DeviceScanActivity.java
index 9b86f7a..7c654dc 100644
--- a/Application/src/main/java/com/example/android/bluetoothlegatt/DeviceScanActivity.java
+++ b/Application/src/main/java/com/example/android/bluetoothlegatt/DeviceScanActivity.java
@@ -16,6 +16,7 @@
 
 package com.example.android.bluetoothlegatt;
 
+import android.Manifest;
 import android.app.Activity;
 import android.app.ListActivity;
 import android.bluetooth.BluetoothAdapter;
@@ -46,6 +47,7 @@ public class DeviceScanActivity extends ListActivity {
     private BluetoothAdapter mBluetoothAdapter;
     private boolean mScanning;
     private Handler mHandler;
+    private static final int PERMISSION_REQUEST_CORASE_LOCATION = 7788;
 
     private static final int REQUEST_ENABLE_BT = 1;
     // Stops scanning after 10 seconds.
@@ -64,6 +66,8 @@ public class DeviceScanActivity extends ListActivity {
             finish();
         }
 
+        requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},PERMISSION_REQUEST_CORASE_LOCATION);
+
         // Initializes a Bluetooth adapter.  For API level 18 and above, get a reference to
         // BluetoothAdapter through BluetoothManager.
         final BluetoothManager bluetoothManager =

2018/6/6

Nordic nRFToolbox build from source

這是 Nordic 的 app,用來跟Nordic 的 EVB 連線用的。
原始source code 放在 Nordic 的 github repo :Android-nRF-Toolbox
但是因為 build 起來有問題,要加一些修改才 build 得起來。
所以只好 fork 一份到自己的 github

說明一下 build 的方法...

這個 需要 Android BLE Library,而且有規定位置 (在 Settings.gradle)。
Android-BLE-Library 跟 Android-nRF-Toolbox 要放在同一層。
toolbox 的 settings.gradle 是這樣寫的..
project(':ble').projectDir = file('../Android-BLE-Library/ble')


也就是說..
$ git clone https://github.com/checko/Android-BLE-Library.git
$ git clone https://github.com/checko/Android-nRF-Toolbox.git
$ cd Android-nRF-Toolox
$ git checkout fixRequstClassNotFound
我是先 import Android-BLE-Library, build 好,再 import Android-nRF-Toolbox, build apk

2018/6/4

svn diff with vi

就是跟 git diff 一樣,用 vim 來開,並且 edit code
ref:dirdiff compare two folders 其中 svn diff 的section

2018/5/31

opencv library build from source.

opencv 的 install instruction 很隱晦。
到 document 去 search install,然後選 install_Linux 部份...
tutorial_linux_install

以下照做..
..git clone, cmake, make, make install.. 過然就 OK 了.
-- 為了避免跟 distribution 安裝的opencv library 衝突,所以改INSTALL_PATH 到 ~/opencvlib 下。

source code 的 samples/cpp/example_cmake 下有一個 Makefile 可以作為 build app 的標準 Makefile
CXX ?= g++

CXXFLAGS += -c -Wall $(shell pkg-config --cflags opencv)
LDFLAGS += $(shell pkg-config --libs --static opencv)

all: opencv_example

opencv_example: example.o; $(CXX) $< -o $@ $(LDFLAGS)

%.o: %.cpp; $(CXX) $< -o $@ $(CXXFLAGS)

clean: ; rm -f example.o opencv_example
build Z 的 sample 結果出現 xfeature2d.hpp 找不到,這是在 opencv_contrib 裡...
所以,git clone https://github.com/opencv/opencv_contrib.git

build contrib module 的 option 有在說明的後面...
重新安排一次..
mkdir opencv && cd opencv
git clone https://github.com/opencv/opencv
git clone https://github.com/opencv/opencv_contrib
create 安裝的 folder:
mkdir opencvlib
cd opencv
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=release -D CMAKE_INSTALL_PREFIX=/home/charles-chang/opencv/opencvlib -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ ..

另外,如果是gcc 6.X 配上 opencv3.1.0,還要加上 -DENABLE_PRECOMPILED_HEADERS=OFF 這個 option,否則會出現 stdlib.h not found 的 error。(ref)
還要配上hdf5.h not found 增加定義..
這樣 make OK,但是 build 自己的 code 的時候,會出現 libippicv 找步道,就要照這一篇,再增加定義....
最後,cmake 的 command option 是...
cmake -D CMAKE_BUILD_TYPE=release -D CMAKE_INSTALL_PREFIX=/home/charles-chang/opencv/lib3.1.0 -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ -D ENABLE_PRECOMPILED_HEADERS=OFF -D WITH_IPP=ON -D INSTALL_CREATE_DISTRIB=ON ..
這樣 build 出來的 opencv 已經可以正常 build application 了。
但是因為是 local install。所以執行 build 好的 application 時,會出現 so 找不到的錯誤。
就要設 LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/charles-chang/opencv/lib3.1.0/lib/
之後再 run 就 OK 了。


build opencv static library
build static library

2018/5/29

phabricator / Differential -- "Context not available." in diff view

在 review code時,只會顯示出 diff 的部份,原來會顯示 "full line" 的 option 的地方,只有出現 "Context not available."。

根據這一篇所說。
這是因為 windows 版 svn 不支援 -U99999 這個option 的關係。
所以解決方法就是用 gnu svn,然後寫一個 batch file 加上 -u9999 這個 option,取代原來得svn diff

2018/5/28

phabricator : working with svn

phabricator 跟 svn 工作的說明好像很少。
先照這一篇 試試看。
從 repository 開始...

一般會使用subversion 大概是因為舊專案。所以 repo 應該都是 monitor type。

新版只有 new repo 三種可以選, import 的 icon 結果是說明。
所以 new 一個 svn repo。
然後修改 uri,再 active 。
因為要做 monitor 用。所以 new uri,指向真正的 repo https://subversion.my.com/svn/AI/testproj/phabrisvn
選 observe。
出現 error,說有一個 uri 是 read/write,所以沒辦法設這個 uri 是 observe。
所以去外面把 原來那個自己生成的 uri disable。
然後設定這格 uri 的 Credential (這個是設定https://subversion.my.com/svn/AI/testproj/phabrisvn 的 username/password)。

因為 出現 error, 在 repo mananger 的 sync fail:
Error updating working copy: Command failed with error #1!
COMMAND
svn --non-interactive --no-auth-cache --trust-server-cert --username '********' --password '********' 
info --xml 'https://subversion.my.com/svn/AI/testproj/phabrisvn'

STDOUT




STDERR
svn: E170013: Unable to connect to a repository at URL 'https://subversion.my.com/svn/AI/testproj/phabrisvn'
svn: E230001: Server SSL certificate verification failed: certificate issued for a different hostname, issuer is not trusted
sudo su www-data -s /bin/bash
轉換身份 www-data 執行看看..
出現..
...
svn: E000002: Unable to open auth file for writing
svn: E000002: Can't create temporary file from template '/var/www/.subversion/auth/svn.ssl.server/svn-XXXXXX': No such file or directory

改 /var/www 的 owner 為 www-data,結果 su www-data 後 co OK。但是 phabricator update 還是 fail

依照說明,用
sudo /opt/phabricator/bin/repository update --trace R13
手動 update repo 'R13'。
結過還是錯。

所以用 root 來做..
sudo su - root 後, co 這個 svn repo,輸入 username/password, 並且接受 cert , server 後,
phabricator update 這格 error 消失,換出現另一個 error...

Error updating working copy: Repository "R13" does not have a correctly configured remote URI. 
The remote URI for a Subversion repository MUST point at the repository root. 
The root for this repository is "https://subversion.my.com/svn/AI", but 
the configured URI is "https://subversion.my.com/svn/AI/testproj/phabrisvn". 
To resolve this error, set the remote URI to point at the repository root. 
If you want to import only part of a Subversion repository, use the "Import Only" option.
遵照指示,在 manage repo 頁面,左邊有 subversion 這一個選項,這個選項可以輸入 目錄。
所以把 uri 改成 https://subversion.my.com/svn/AI,然後在這個 subversion 項目, 輸入 testproj/phabrisvn。
這樣 update 就沒問題了。


checkout and conduct a review

先 checkout svn repo
svn co https://subversion.my.com/svn/AI/testproj/phabrisvn
然後測試一下,arc diff..
$ arc diff
Usage Exception: This command requires arc to connect to a Phabricator install, but no
Phabricator installation is configured. To configure a Phabricator URI:

  - set a default location with `arc set-config default `; or
  - specify `--conduit-uri=uri` explicitly; or
  - run `arc` in a working copy with an '.arcconfig'.

第一次使用 arc,遵照這一篇,設定好 default phabricator server 位置
arc set-config default http://192.168.144.171
之後..arc diff 說,需要 run arc install-certificate ..
$ arc install-certificate
 CONNECT  Connecting to "http://192.168.144.171/api/"...
LOGIN TO PHABRICATOR
Open this page in your browser and login to Phabricator if necessary:

http://192.168.144.171/conduit/login/

Then paste the API Token on that page below.

    Paste API Token from that page: 
follow 這個 說明,開啟 頁面,會叫你 login,然後顯示你login user 對應的 API token 字串。
把那個字串 copy 到 command 的 ':' 後面..
接著出現:
Writing ~/.arcrc...
 SUCCESS!  API Token installed.
上面這兩個是寫在 ~/.arcrc 裡..
n$ cat ../.arcrc 
{
  "config": {
    "default": "http://192.168.144.171/"
  },
  "hosts": {
    "http://192.168.144.171/api/": {
      "token": "cli-txwsqp26sv3urka3t364xxxxxyhy"
    }
  }
}
OK,開始測試...參考這一頁subversion 的部份
修改檔案...
arc diff 提起 review ...會自動開啟 editor..
windows 10 的話,要先用..
arc set-config editor "C:\Program Files\Notepad++\notepad++.exe"
才會自動開啟 notepad++。
然後寫好 Reviewers, save退出。
reviewer 會收到通知。確認後。
arc list 列出目前狀態, OK 的話,就可以用..
arc commit 結束(commit 到 svn)


svn branch and merge

arc 沒有支援 subversion 的 branch/merge 動作。
所以都要自己做。
branch 就自己 svn cp. svn switch。
branch 也可以用 arc diff要求 review,只是 arc commit 是 commit 到 branch,main trunk 沒有影響。
merge 動作就要手動 svn merge XXOO。
然後 先用 arc diff 要求 review 後再 arc commit 把 merge 完的 code commit

2018/5/25

筆記: arcanist on windows 10

希望作到在 windows 10 上使用 arcanist + svn
ref: Arcanist User Guide:Windows

用git clone 的方式..
安裝 git
git for windows download and install git
然後只選 Use git from windows command prompt
不選 gui extension
Use OpenSSL library
Checkout Windows Style, commit Unix Style
Git bash terminal use MinTTY

裝完之後,開啟 cmd,輸入 git 已經可以找到command

安裝 php

ref:arcanist on windows 環境安裝
到 windows.php.net/download 下載 7.2 VC15 x64 non thread safe

unzip to C:\php

rename php.ini-development to php.ini
修改 php.ini,un-comment extension_dir,並且指向正確的地方:
externsion_dir="C:\php\ext"
還要打開 php_curl.dll 這個 extension,一樣,修改 php.ini。
在新版設定,變成 un-comment
extension=curl
設定 path..
用 find 找 "系統內容" 出來,進階 tab,最下面有 "環境變數"。新增一個 path: "C:\php\"。
設好開啟 cmd,輸入 php -i 看看有沒有東西...

安裝 arcanist

裝在 C:\phabri
C:\> md phabri
C:\> cd phabri
C:\phabri> git clone https://github.com/phacility/libphutil.git
C:\phabri> git clone https://github.com/phacility/arcanist.git
follow 剛剛的方法,在 path 加上 C:\phabri\arcanist\bin\

測試:開啟cmd.exe,輸入 arc help 有輸出東西..

subversion command line
裝 TortoiseSVN 1.10,安裝時記得要 check command line client tool


config arc

第一次用 arc提交 review 一定要先設定 uri, certifictaion, 和 editor。
arc set-config default uri http://xxoo
然後follow..
arc install-certification
的說明,把 api-key copy 過來。
最後再用
arc set-config editor "C:\Program Files\Nodepad++\nodepad++"
設定好 editor。

linux 會把 arcrc 放在 ~/ 下。
windows 10 我就不知到會放到哪裡。
所以要修改只有用 arc set-config 重設一次。
或用 arc get-config 來看。

2018/5/23

影像辨識 縮寫詞

其他:

原來車牌辨識有一個特定的名稱:ANPR (Automatic number plate recognition)。
google 起來有很多,像 這個 (openalpr) 就是一個放在 github 的實做。

2018/5/22

phabrictor : repo 操作

上一篇 已經把 phabricator 裝好了。
這裡做 phabricator 管 repo 的設定。一樣,是抄 rarguelloF 的 script

建立repo 要用的目錄,並且設定owner www-data
mkdir -p /var/repo
chown www-data:www-data /var/repo

mailadaptor 就安裝 sendmail
apt-get install sendmail
裝完沒有設什麼...



接著就是登入設定。第一個create 的 user 是 administrator,因為有限制最少password 字數,所以最後加上 123。
設定進入後...
上面的驚嘆號出現 15個...
  • Disable PHP always_populate_raw_post_data
  • Small MYSQL "max_allowed_packet"
  • MySQL_ONLY_FULL_GROUP_BY Mode Set
  • MySQL May Run Slowly
  • Server Timezone Not Configured
  • Alternate File Domain Not Configured
  • Install Pygment to Improve Syntax Hightlighting
  • Large File Storage Not Configured
  • PHP post_max_size Not Configured
  • OPcache Not Configured for Production
  • Base URI Not Configured
  • Not Authentication Providers Configured
  • Phabricator Daemon Are Not Running

貼一下 phabricator 自己的提示..
Disable PHP always_populate_raw_post_data

The "always_populate_raw_post_data" key is set to some value other than "-1" in your PHP configuration. 
This can cause PHP to raise deprecation warnings during process startup. Set this option to "-1" to prevent these warnings from appearing.
The current PHP configuration has this value:

always_populate_raw_post_data "0"
To update this value, edit your PHP configuration file, located here:

/etc/php/5.6/fpm/php.ini
You can find more information about PHP configuration values in the PHP Documentation.

After editing the PHP configuration, restart Phabricator for the changes to take effect. 
For help with restarting Phabricator, see Restarting Phabricator in the documentation.


PHP post_max_size Not Configured

Adjust post_max_size in your PHP configuration to at least 32MB. When set to smaller value, large file uploads may not work properly.
The current PHP configuration has this value:

post_max_size "8M"
To update this value, edit your PHP configuration file, located here:

/etc/php/5.6/fpm/php.ini
You can find more information about PHP configuration values in the PHP Documentation.

After editing the PHP configuration, restart Phabricator for the changes to take effect. 
For help with restarting Phabricator, see Restarting Phabricator in the documentation.


Small MySQL "max_allowed_packet"

On host "localhost", MySQL is configured with a small "max_allowed_packet" (16777216), 
which may cause some large writes to fail. The recommended minimum value for this setting is "33554432".
The current MySQL configuration has this value:

max_allowed_packet "16777216"
If you are using Amazon RDS, some of the instructions above may not apply to you. See User Guide: Amazon RDS for discussion of Amazon RDS.
這格要修改/etc/mysql/mysql.conf.d/mysqld.cnf

Install Pygments to Improve Syntax Highlighting

Phabricator can highlight a few languages by default, but installing and enabling Pygments (a third-party highlighting tool) 
will add syntax highlighting for many more languages. 

For instructions on installing and enabling Pygments, see the pygments.enabled configuration option.

If you do not want to install Pygments, you can ignore this issue.
The current Phabricator configuration has this value:

pygments.enabled false


就...installl..
apt-get install python-pygments
裝完以後,可以看看/設定 phabricator 的設置:
~$ sudo /opt/phabricator/bin/config get pygments.enabled
[sudo] password for charles-chang: 
{
  "config": [
    {
      "key": "pygments.enabled",
      "source": "local",
      "value": null,
      "status": "unset",
      "errorInfo": null
    },
    {
      "key": "pygments.enabled",
      "source": "database",
      "value": null,
      "status": "unset",
      "errorInfo": null
    }
  ]
}

也可以用 phabricator 的 web interface 設定: Config -- Config -- Syntax Highlighting -- pygments.enabled

2018/5/21

rarguelloF 的 phabricator install script 說明

沒寫過一次完整的,這次試試..
-- 是用 virtualbox , ubuntu 16.04 LTS server 版測試的。

這一篇: install intruction for phabricator in ubuntu 16.04 LTS

apt-get install git nginx mysql
and set mysql root password

接著..
add-apt-repository ppa:ondrej/php

 Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.

Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa

You can get more information about the packages at https://deb.sury.org

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see 
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
 More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or ctrl-c to cancel adding it

--- ENTER

gpg: keyring `/tmp/tmp6tm792u4/secring.gpg' created
gpg: keyring `/tmp/tmp6tm792u4/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp6tm792u4/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

然後再 apt-get update 一次。 就可以裝 php5.6..
apt-get install php5.6 php5.6-fpm php5.6-mbstring php5.6-common php5.6-mysql php5.6-curl php5.6-json php5.6-gd php-apcu php-pear

指定php 使用 php5.6
update-alternatives --set "php" /usr/bin/php5.6

安裝 phabricator (就是 clone git...)
安裝到 /opt
cd /opt
it clone https://github.com/phacility/libphutil.git
git clone https://github.com/phacility/arcanist.
git clone https://github.com/phacility/phabricator.git
然後change ower to nginx (www-data)

設置Nginx

新曾一個 site config file: /etc/nginx/site-available/phabricator
server {
  #server_name phabricator.example.com;
  root        /opt/phabricator/webroot;

  location / {
    index index.php;
    rewrite ^/(.*)$ /index.php?__path__=/$1 last;
  }

  location /index.php {
    fastcgi_pass   localhost:9000;
    fastcgi_index   index.php;

    #required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;

    #variables to make the $_SERVER populate in PHP
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;

    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

    fastcgi_param  REMOTE_ADDR        $remote_addr;
  }
}
server_name 改成這個 vm 的 ip..或是不要寫
-- nginx 設定的 server_name 是virtualhost 用的,參考 Nginx Virtual Host 設定教學
nginx 會依照 server_name 決定使用site-enabled/ 下的那一個 server config 檔,而不是單純依照 ip address
所以在lan 內沒有適當 dns,必須要用 ip 來服務,或是用 vm nat 測試,必須要經由 port forwarding 提供服務 (ip address 會變)。name_server舊部要寫

然後建立 site-enable/default 的 link 好啟動他..
ln -sf /etc/nginx/sites-available/phabricator /etc/nginx/sites-enabled/phabricator
一樣的名子就可以,不必用 "default",因為 nginx 是看所有sites-enabled/ 下的檔案,比照其中的 server_name..

增加一個 file : /etc/php/5.6/fpm/poo.d/phabricator.conf,同時把原來的 www.conf :
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[phabricator]

; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = -1

; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
listen.allowed_clients = 127.0.0.1

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0666
; listen.owner = www-data
; listen.group = www-data
; listen.mode = 0600

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = www-data
group = www-data

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives:
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is greater than this
;                                    number then some children will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 6

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 3

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 3

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 5

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
;   accepted conn        - the number of request accepted by the pool;
;   pool                 - the name of the pool;
;   process manager      - static or dynamic;
;   idle processes       - the number of idle processes;
;   active processes     - the number of active processes;
;   total processes      - the number of idle + active processes.
;   max children reached - number of times, the process limit has been reached,
;                          when pm tries to start more children (works only for
;                          pm 'dynamic')
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
;   accepted conn:        12073
;   pool:                 www
;   process manager:      static
;   idle processes:       35
;   active processes:     65
;   total processes:      100
;   max children reached: 1
; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output
; syntax. Example:
;   http://www.foo.bar/status
;   http://www.foo.bar/status?json
;   http://www.foo.bar/status?html
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
pm.status_path = /fpm-status-zwei

; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
ping.path = /ping-zwei

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_terminate_timeout = 120s

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
request_slowlog_timeout = 5s

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
slowlog = /var/log/$pool.log.slow

; Set open file descriptor rlimit.
; Default Value: system defined value
rlimit_files = 4096

; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
rlimit_core = 0

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =

; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = /var/opt

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
catch_workers_output = yes

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'.
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr)

; Default Value: nothing is defined by default except the values in php.ini and
;                specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

--- 這部份不清楚,不知道 fpm 怎麼處理 pool.d...

MySQL
設定 mysql root acccount and password,給予權限都
user/password: phabri/phabripass
$mysql -u root -p
ENTER password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE USER 'phabri'@'localhost' IDENTIFIED BY 'phabripass';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'phabri'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql>\q

設定 phabricator 中的 mysql 資訊

就是告知 phabricator 剛剛設定有關 mysql 的 user/password 資訊。讓 phabricator 可以正確操作 mysql
cd /opt/phabricator
sudo ./bin/config set mysql.host localhost
sudo ./bin/config set mysql.user phabri
sudo ./bin/config set mysql.pass phabripass
sudo ./bin/storage upgrade --force
...
...
有問題的話,可以用
\$ sudo ./bin/config get mysql.pass
{
  "config": [
    {
      "key": "mysql.pass",
      "source": "local",
      "value": "phabripass",
      "status": "set",
      "errorInfo": null
    },
    {
      "key": "mysql.pass",
      "source": "database",
      "value": null,
      "status": "unset",
      "errorInfo": null
    }
  ]
}
查一下有沒有設對。
最後 storage upgrade 是建立 mysql database

作到這裡之後,就可以用 browser 看一下...會出現phabricator首次服務的登入畫面..

2018/5/8

reset virtualbox vm root password

就跟一般的機器一樣。
用 sysrescue CD 開機。
把 virtualbox 的 root partition mount 進來到 /hd。
這個 vm 是 centos5,root partition 是 /dev/mapper/VolGroup00-LogVol00
chroot 到 root partition ..
chroot /hd /bin/bash
這樣就可以用 passwd 設定新 root password 了。

設完poweroff,再將 VM 開機,root password 就改成 新的了。

2018/4/27

opencv build error stdlib.h

cmake: fixing gcc6.x c++/stdlib.h include issue

cmake/OpenCVUtils.cmake
@@ -122,7 +122,11 @@ function(ocv_include_directories)

        OR (OPENCV_EXTRA_MODULES_PATH AND "${__abs_dir}" MATCHES "^${OPENCV_EXTRA_MODULES_PATH}"))
       list(APPEND __add_before "${dir}")
     else()
-      include_directories(AFTER SYSTEM "${dir}")
+      if (gcc_compiler_version VERSION_LESS "6.0.0")
+        include_directories(AFTER SYSTEM "${dir}")
+      else()
+        include_directories(AFTER "${dir}")
+      endif()
     endif()
   endforeach()
   include_directories(BEFORE ${__add_before})
去 https://github.com/opencv/opencv.git checkout, blame 找到 fix commit:
~/github/opencv$ git show 21d9412c93
commit 21d9412c93d0fea7c087c2cca3b232b9f8ab9d69
Author: Alexander Alekhin 
Date:   Mon Oct 3 19:38:19 2016 +0300

    cmake: fix for GCC 6.x

diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake
index aafda61ab..89a0bd578 100644
--- a/cmake/OpenCVPCHSupport.cmake
+++ b/cmake/OpenCVPCHSupport.cmake
@@ -14,12 +14,7 @@
 
 IF(CMAKE_COMPILER_IS_GNUCXX)
 
-    EXEC_PROGRAM(
-        ${CMAKE_CXX_COMPILER}
-        ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
-        OUTPUT_VARIABLE gcc_compiler_version)
-    #MESSAGE("GCC Version: ${gcc_compiler_version}")
-    IF(gcc_compiler_version VERSION_GREATER "4.2.-1" AND gcc_compiler_version VERSION_LESS "6.0.0")
+    IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.2.0")
         SET(PCHSupport_FOUND TRUE)
     ENDIF()
 
diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake
index 8d7c98b3e..82d82262a 100644
--- a/cmake/OpenCVUtils.cmake
+++ b/cmake/OpenCVUtils.cmake
@@ -121,6 +121,9 @@ function(ocv_include_directories)
         OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}"
         OR (OPENCV_EXTRA_MODULES_PATH AND "${__abs_dir}" MATCHES "^${OPENCV_EXTRA_MODULES_PATH}"))
       list(APPEND __add_before "${dir}")
+    elseif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
+           dir MATCHES "/usr/include$")
+      # workaround for GCC 6.x bug
     else()
       include_directories(AFTER SYSTEM "${dir}")
     endif()
@@ -142,6 +145,10 @@ endfunction()
 function(ocv_target_include_directories target)
   _ocv_fix_target(target)
   set(__params "")
+  if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
+      ";${ARGN};" MATCHES "/usr/include;")
+    return() # workaround for GCC 6.x bug
+  endif()
   foreach(dir ${ARGN})
     get_filename_component(__abs_dir "${dir}" ABSOLUTE)
     if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}"


2018/4/20

Wifi http storage server

大概就是用 raspberry 做一個會將 usb 儲存裝置透過 http server export 出來的 image。
另外要是 Wifi ap mode。

開機後,插上 usb 儲存裝置後。
手機或是NB 連上這個 wifi ap 後,就可以用 browser 開啟 usb 裝置的根目錄。

所以需求是:
  • Wifi AP Mode
  • USB auto mount
  • http server

USB auto mount
apt-get install usbmount
然後,用 stretch 的話,要改一下..
USB Auto mount - Raspbian Stretch Lite [Solved]
就是去改 /lib/systemd/system/systemd-udevd.service:
MountFlags=shared   #private
還要注意中文檔名問題,要再 mount 時加上 option charset=utf8
usbmount utf support
修改 /etc/usbmount/usbmount.conf:
FS_MOUNTOPTIONS="-fstype=vfat,iocharset=utf8"
指定 mount vfat 時要用 這個 option。
重開機,就可以了。

Wifi ap

ref:setting up raspberry pi as a wifi access point

因為沒有要做 interface gateway,只是單純的要把 usb driver 經由 nginx export 出來,
所以只要做前面的部份:
  • set wlan0 as static ip
  • set dnsmasq , give wlan0 a ip range
  • set wlan0 as access point
要設定 wlan0 用 static ip 好像有兩種作法,這個 是另一種 (disable dhcpcd, 用 network/interface 設定)
這裡用的是,利用 dhcpcd 指定 wlan0 ip-address。
修改 /etc/dhcpcd.conf,把下面加到檔案最後..
interface wlan0
    static ip_address=172.16.130.1/24
和 改 network/interface 不一樣的是,這樣改完後,restart dhcpcd,用 ifconfig 看,wlan0 一樣沒 ip。

修改 /etc/dnsmasq.conf,一樣,加入這兩行
interface=wlan0      
  dhcp-range=172.16.130.2,172.16.130.4,255.255.255.0,24h

hostapd 則是要新增 /etc/hostapd/hostapd.conf 這個file..
interface=wlan0
driver=nl80211
ssid=NameOfNetwork
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=AardvarkBadgerHedgehog
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
然後修改 /etc/default/hostapd,叫他用這個 conf
DAEMON_CONF="/etc/hostapd/hostapd.conf"

nginx

就參考上一篇

2018/4/12

http file server - python , node.js and nginx (static page)

原來所有的 http server 都有這種 list directory 跟 file GET/POST 功能。
所以沒有一個類似Windows 上的 HTTP File Server 這種 package (因為就是 http server)。

用 Apache 或 Nginx 都可以作到。
但是如果只是要測試 run 一下,可以用 Python 的 SimpleHTTPServer 或是 node.js 的 htttp-server


Python 的 SimpleHTTPServer 很簡單。
就是在要 export 的 folder root..
python -m SimpleHTTPServer 8123
這樣就會在 port 8123 上提供 http 服務。

用 node.js 的 http-server 的話,也一樣。
sudo npm install http-server -g
安裝。
然後到要 export 的 folder 下..
http-server -p 8123
就會在 port 8123 提供 http 服務。


實際使用上 node.js 的 http server 比較好,錯誤比較少。python 的 SimpleHTTPServer 問題較多。

最完整的應該是用 nginx,就是安裝 nginx ,然後修改 site-available/default:
server {
   listen 8123 default_server;
   
   root /home/myname;
   autoindex on;
   charset utf-8;
   ...
這樣就可以了,會在 port 8123 上提供 /home/myname 的 file listing 服務。
* charset 這個 option 是指定使用 utf-8 encoding,避免中文檔名產生亂碼。

要注意 root path,必須要整路都是 nginx 可存取的,不然就會有 404, 403 error。
保險起見,可以 mount 到 /usb

2018/3/30

openwebos , test build

大概就是一些 source site 倒了,換到 github。
還有因為 使用的 openembedded 版本太舊,所以build image 時會有權限問題。要用 sudo make
但是 sanity check 又會檔...所以comment 掉 check..
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index e3444d1..1447a56 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -387,9 +387,6 @@ def check_sanity(sanity_data):
         print "Foo %s" % minversion
         return
 
-    if 0 == os.getuid():
-        raise_sanity_error("Do not use Bitbake as root.", sanity_data)
-
     messages = ""
 
     # Check the Python version, we now use Python 2.6 features in
因為 用 ctrl-C 中斷,所以 bitbakc.lock 沒刪除。
ref:bitbake/lib/bb/cooker.py

ERROR: Only one copy of bitbake should be run against a build directory


還是失敗,do_rootfs..
Collected errors:
 * preinst_configure: Aborting installation of connman.
 * opkg_install_cmd: Cannot install package packagegroup-webos-extended.
ERROR: Function failed: do_rootfs (see /home/charles-chang/mywebos/build-webos/BUILD/work/qemux86-webos-linux/webos-image/1.0-r2/temp/log.do_rootfs.1636 for further information)

2018/3/22

vnc player 中文方塊字

ref: vnc subtitles

內建字幕的影片播出來是方塊字。
vnc 2.2.8

是 Subtitiles/OSD 中 Encoding 和 Font 設定的關係。
Default Encoding 是Window 123 什麼的。
把他感改成 Traditional Chinese (Big5)
Font 我選了AR PL UKai TW
設完以後,關掉重開,就可以正常顯示了。

2018/3/21

使用 rename 來rename filename ..

ref:using sed to mass rename files

結果是用 rename 這個 command..
例子是想把filename 中,4個 0 改成 3 個 00
rename s/0000/000/ F0000*
還有用這一篇:
先用 -v 看看:
rename -n -v  's/^(.{5})//' *
OK 的話,就省掉 -v:
rename 's/^(.{5})//' *

2018/3/19

build 舊版 fdisk.. 2.17..

因為新版 (2.29.2) 和bsp script 用的版本(2.17.1) 語法參數不一樣。
所以拿2.17.1來 build..

fdisk 是在kernel org, util-linux-ng 這個 project。
download 後, run .configure, make fdisk 就可以了。

fdisk 目錄下的 fdisk 只是一個 wrapper,要call fdisk/.lib/fdisk 。
所以 .lib 下的才是本體,

vpn 到中國網路

差異好像越來越大,所以...
要測試app在中國的行為,就裝 Transocks 比較快。
不用設vpn 什麼的..
iOS 版本也有喔。

console mode markdown reader

像github 的 readm 是 md 格式 (README.md)。
在 console mode 的 reader..

mdr

是用 nodejs 寫得。所以用 npm install -g mdr 就可以安裝。

使用就是
mdr  README.md



另一個是grip
一樣是console mode,但是會叫 lynx 打開。

install node.js in debian 9 - stretch

ref:How to install nodejs on debian 9 (stretch)

他說 stretch 的 nodejs package 用的 nodejs 版本太舊,不建議使用。
建議自己安裝。

文章的方法是 run deb.nordesource.com 的 script,他會邦你加入 nodejs 的 source repository,
之後就可以用 apt 安裝。

## Confirming "stretch" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_6.x/dists/stretch/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK

## Creating apt sources list file for the NodeSource Node.js v6.x LTS Boron repo...

+ echo 'deb https://deb.nodesource.com/node_6.x stretch main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_6.x stretch main' >> /etc/apt/sources.list.d/nodesource.list

...
...

## Run `apt-get install nodejs` (as root) to install Node.js v6.x LTS Boron and npm

然後 run apt-get install nodejs 就會安裝這個版本的 node.


附上其他distribution 的方法(其實一樣):nodejs package manager
在 trusty 上 run setup_6.x 的 log 中..
## Confirming "trusty" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_6.x/dists/trusty/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK

## Creating apt sources list file for the NodeSource Node.js v6.x LTS Boron repo...

+ echo 'deb https://deb.nodesource.com/node_6.x trusty main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_6.x trusty main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...
就是上面手動做的..

SoftEtnerVPN 安裝

沒有 package,所以要從 source..
git clone https://github.com/SoftEtherVPN/SoftEtherVPN.git
cd SoftEtherVPN
./configure
---------------------------------------------------------------------
SoftEther VPN for Unix

Copyright (c) SoftEther VPN Project at University of Tsukuba, Japan.
Copyright (c) Daiyuu Nobori. All Rights Reserved.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.

Read and understand README.TXT, LICENSE.TXT and WARNING.TXT before use.
---------------------------------------------------------------------

Welcome to the corner-cutting configure script !

The Makefile is generated. Run 'make' to build SoftEther VPN.

看一下 Makefile...
安裝位置..
INSTALL_BINDIR=/usr/bin/
INSTALL_VPNSERVER_DIR=/usr/vpnserver/
INSTALL_VPNBRIDGE_DIR=/usr/vpnbridge/
INSTALL_VPNCLIENT_DIR=/usr/vpnclient/
INSTALL_VPNCMD_DIR=/usr/vpncmd/