2019/12/24

使用 docker 執行 openmvide

docker run -it --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev openmv/v2
build openmvide from source https://github.com/openmv/openmv-ide
sudo apt-get install libqt5serialport5-dev qtdeclarative5-dev qtbase5-private-dev qttools5-dev-tools chrpath p7zip-full
make.py fail
Everything is Ok
python -u /data/openmv-ide/qt-creator/scripts/packageIfw.py -i "None" -v 2.2.0 -a "/data/openmv-ide/build/openmv-ide-linux-x86_64-2.2.0-installer-archive.7z" openmv-ide-linux-x86_64-2.2.0 && python -u /data/openmv-ide/qt-creator/scripts/sign.py "openmv-ide-linux-x86_64-2.2.0.run"
Cleaning up...
Done.
Traceback (most recent call last):
  File "/data/openmv-ide/qt-creator/scripts/packageIfw.py", line 155, in 
    main()
  File "/data/openmv-ide/qt-creator/scripts/packageIfw.py", line 147, in main
    subprocess.check_call(ifw_call, stderr=subprocess.STDOUT)
  File "/usr/lib/python2.7/subprocess.py", line 536, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 523, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
Makefile:335: recipe for target 'installer' failed
make: *** [installer] Error 1
Make Failed...
make.py 其中 make() 的 linux 部份:
       # Build...
        if os.system("cd " + builddir +
        " && qmake ../qt-creator/qtcreator.pro -r -spec linux-g++" +
        " && make -r -w -j" + str(cpus) +
        " && make installer INSTALL_ROOT="+installdir + " IFW_PATH="+str(ifdir)):
            sys.exit("Make Failed...")
        installer = glob.glob(os.path.join(builddir, "openmv-ide-*.run"))[0]
找一下 click connect 的 source code..
$grep -r 'No OpenMV Cams found' *
openmv/openmvplugin.cpp:                    tr("No OpenMV Cams found!"));
qtserialport 的 souces : https://stackoverflow.com/questions/34758196/trouble-using-qserialport-in-ubuntu

修改 openmvplugin.cpp,加上 debug message, 有關 portName() QtString 轉 c string, ref:https://stackoverflow.com/questions/5505221/converting-qstring-to-char
就可以用 printf()印debug message。
發現tty serial 都有正確找到,但是 VID 都是 No VID,
最後..在 container 內..
udevadm trigger
啟動 docker command 變成:
docker run -it --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev -v ~/ddata:/data -v /etc/udev:/etc/udev -v /sys:/sys openmv/v2:packageok

重新做一次:

docker run -it --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev -v ~/ddata:/data   ubuntu:18.04
然後adduser..
adduser uid=1000 charles-chang
安裝 package..
apt-get update
apt-get install sudo vim
然後修改 /etc/group,把 charles-chang 加到 sudo group 中.. su - charles-chang 換到 charles-chang
接著要裝 run openmvide 的 package,先install add ppa 需要的 command,加入arm embedded , update..
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
安裝需要的 packages..
sudo apt-get install gcc-arm-embedded libc6-i386 python2.7 python-dev python-pip libusb-1.0-0 libusb-1.0-0-dev python-gtksourceview2 git  make
用 pip install python modules
sudo pip install numpy pyserial==2.7 pyusb==1.0.0b2 Pillow
安裝openmvide 要的 pakcages..
sudo apt install imagemagick libqt5widgets5 libqt5gui5 libqt5core5a qt5-default qt5-qmake wget g++ libgl1-mesa-dev
download openmvide install file to .. mapped volume.. /data

chmod +x, run, 出現 dialog,安裝目錄改 /data,出現authorization required sudo,輸入 密碼。OK
dialog 出現..disk space 0.0..



結果是要手動啟動 /lib/systemd/systemd-udevd
加上 & run as daemon,之後 usb 的 in/out 才會 update....

然後還要執行 udevadm trigger,這樣 commit 的 image 啟動後 sytemd-udev 才會繼續有動作。(不然又要手動啟動 systemd-udevd)

所以...安裝 systemd-udevd
apt-get install udev
這樣才有 systemd-udevd 和 udevadm

另外..

必須要 mapping(-v) /sys 進 container 後,以 user (不是root)的身份啟動 systemd-udevd 和 udevadm trigger 之後, commit 的 image ,之後 run 起來才會自動發揮作用,不用手動再啟動 systemd-udevd...
--- 猜是經由 /sys 使用 host 的 udevd 動作..



final..

用下面命令啟動 docker..
docker run -it --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev:/dev -v ~/ddata:/data  -v /sys:/sys ubuntu
host 的 .X11-unix 有 檢查user permission,所以在 container 中也要鍵一格 uid/gid 一樣的 user

裝完所有 package,讓 openmvide 能正常啟動後..
sudo apt-get install udev
sudo /lib/systemd/systemd-udevd &
sudo udevadm trigger
可以測試一下 openmvide 是不是可以正常偵測 openmv. OK 的話, exit container,之後就可以 commit 這個 image..
以後就用 上面的 run command 啟動這個 image 就可以了, 啟動後不用再叫起 systemd-udev

啟動 openmvide 之前,要 su 成剛剛create 的 user,因為uid,gid 要跟 host 的 user 一樣。
只要 su,不要切換環境,不然 DISPLAY 變數也要重新 export

2019/12/10

unzip 簡體檔名亂碼

因為是 GBK 的關係,要轉成對應的 utf8 才能正常顯示。

最後是用 這一篇 的方法...
LANG=C 7za x your-zip-file.zip
convmv -f GBK -t utf8 --notest -r .
試過,用 unzip 的話,LANG=C 沒效。

同理,中文的話 GBK改 BIG5

2019/12/5

! The argument `showcommands` is no longer supported.
! Instead, the verbose log is always written to a compressed file in the output dir:
!
!   gzip -cd out/verbose.log.gz | less -R
!