2018年2月26日 星期一

[Tips] 線上去背

有幾套很神奇,但都要收費,如果偶而用一下真不想付錢 QQ

這服務免費而且有教學
http://www.online-image-editor.com/
http://www.online-image-editor.com/help/transparency

[Python] python setup.py install反安裝

沒有 python setup.py uninstall 這麼好的事,需要自己手動將建立出來的檔案幹掉,所以安裝的時候要先紀錄長出什麼檔案
$ python setup.py install --record files.txt
$ cat files.txt | xargs rm -rf
reference:
https://stackoverflow.com/questions/1550226/python-setup-py-uninstall


順便紀錄這個錯誤訊息 python Exception AttributeError: "'Serial' object has no attribute 'is_open'" 是來自於 pyserial 的版本太舊,要安裝 3.0 以上才行

reference:
https://stackoverflow.com/questions/41987168/serial-object-has-no-attribute-is-open

2018年2月25日 星期日

[Ubuntu] 在 Ubuntu16 裝 .NET Framework 4.0

要使用 winetricks
wget 'https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks'
chmod +x winetricks
env WINEARCH=win32 WINEPREFIX=~/.wine32 winetricks dotnet40
reference:
https://appdb.winehq.org/objectManager.php?sClass=version&iId=17886
https://superuser.com/questions/476872/installing-net-4-0-framework-on-wine-using-winetricks

[Tips] wireshark在ubuntu16看不到網路裝置

sudo adduser $USER wireshark 參考這篇的,但還沒重開機和登出,不知道是否有效? https://self.jxtsai.info/2016/10/wireshark-for-ubuntu.html

[RF] Labs 1 - 5 in GRC

投影片蠻清楚的 https://files.ettus.com/tutorials/

2018年2月24日 星期六

[LoRa]

pip install PyBOMBS sudo apt-get install doxygen fftw-dev liblog4cpp5-dev swig libcppunit-dev libvolk1-dev https://github.com/rpp0/gr-lora

錯誤訊息
PyBOMBS - INFO - PyBOMBS Version 2.3.2
PyBOMBS.Packager.apt - INFO - Install python-apt to speed up apt processing.
PyBOMBS.install_manager - INFO - Phase 1: Creating install tree and installing binary packages:
Traceback (most recent call last):
  File "/usr/local/bin/pybombs", line 9, in 
    load_entry_point('PyBOMBS==2.3.2', 'console_scripts', 'pybombs')()
  File "/usr/local/lib/python2.7/dist-packages/pybombs/main.py", line 32, in main
    return dispatch() or 0
  File "/usr/local/lib/python2.7/dist-packages/pybombs/commands/base.py", line 194, in dispatch
    return get_cmd_dict(cmd_list)[args.command](cmd=args.command, args=args).run()
  File "/usr/local/lib/python2.7/dist-packages/pybombs/commands/install.py", line 122, in run
    static=getattr(self.args, 'static', False),
  File "/usr/local/lib/python2.7/dist-packages/pybombs/install_manager.py", line 112, in install
    lambda pkg: _cached_check_if_pkg_goes_into_tree(pkg, _check_if_pkg_goes_into_tree)
  File "/usr/local/lib/python2.7/dist-packages/pybombs/dep_manager.py", line 53, in make_dep_tree
    pkg_set = set([pkg for pkg in pkg_list if filter_callback(pkg)])
  File "/usr/local/lib/python2.7/dist-packages/pybombs/install_manager.py", line 112, in 
    lambda pkg: _cached_check_if_pkg_goes_into_tree(pkg, _check_if_pkg_goes_into_tree)
  File "/usr/local/lib/python2.7/dist-packages/pybombs/install_manager.py", line 97, in _cached_check_if_pkg_goes_into_tree
    ret_val = check_callback(pkg)
  File "/usr/local/lib/python2.7/dist-packages/pybombs/install_manager.py", line 63, in _check_if_pkg_goes_into_tree
    if not self.pm.exists(pkg):
  File "/usr/local/lib/python2.7/dist-packages/pybombs/package_manager.py", line 134, in exists
    pkg_version = pkgr.exists(r)
AttributeError: 'NoneType' object has no attribute 'exists'
sudo ldconfig
就可以解決

* https://github.com/rpp0/gr-lora/issues/42
wiki一定要看
* https://github.com/rpp0/gr-lora/wiki/Capturing-LoRa-signals-using-an-RTL-SDR-device
* https://github.com/rpp0/gr-lora/issues/7
* https://github.com/rpp0/gr-lora/issues/34

2018年2月23日 星期五

[Python] Python Strings in 3.0: Unicode and Binary Data

http://learning-python.com/strings30.html

2018年2月21日 星期三

[電子學] Filter

https://www.electronics-tutorials.ws/filter/filter_2.html

2018年2月20日 星期二

[Python] AES加解密

https://eli.thegreenplace.net/2010/06/25/aes-encryption-of-files-in-python-with-pycrypto

[Arduino] PlatformIO

看起來不錯,要一統江湖了嗎?

安裝
pip install -U platformio
http://docs.platformio.org/en/latest/installation.html

文件
https://readthedocs.org/projects/platformio/downloads/pdf/latest/

執行上傳程式以後,會先安裝 toolchain
pio run -t upload && pio device monitor
********************************************************************************
Obsolete PIO Core v3.5.1 is used (previous was 3.5.2b5)
Please remove multiple PIO Cores from a system:
http://docs.platformio.org/page/faq.html#multiple-pio-cores-in-a-system
********************************************************************************
[Tue Feb 20 16:40:30 2018] Processing uno (platform: atmelavr; board: uno; framework: arduino)
--------------------------------------------------------------------------------
PlatformManager: Installing atmelavr
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
atmelavr @ 1.8.1 has been successfully installed!
The platform 'atmelavr' has been successfully installed!
The rest of packages will be installed automatically depending on your build environment.
PackageManager: Installing toolchain-atmelavr @ ~1.40902.0
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
PackageManager: Installing framework-arduinoavr @ ~1.10620.2
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%
PackageManager: Installing tool-avrdude @ ~1.60300.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
CorePackageManager: Installing tool-scons @ ~3.20501.2
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
tool-scons @ 3.20501.2 has been successfully installed!
Verbose mode can be enabled via `-v, --verbose` option
Collected 24 compatible libraries
Scanning dependencies...
Library Dependency Graph ( http://bit.ly/configure-pio-ldf )
|--  v1.0
|--  v1.0
Compiling .pioenvs/uno/src/Seeed_BME280.o
Compiling .pioenvs/uno/src/aes/ideetron/AES-128_V10.o
Compiling .pioenvs/uno/src/aes/lmic.o
Compiling .pioenvs/uno/src/aes/other.o
src/aes/ideetron/AES-128_V10.cpp:81:13: warning: 'Send_State()' declared 'static' but never defined [-Wunused-function]
static void Send_State();
^
Compiling .pioenvs/uno/src/hal/hal.o
Compiling .pioenvs/uno/src/lmic/lmic.o
Compiling .pioenvs/uno/src/lmic/oslmic.o
Compiling .pioenvs/uno/src/lmic/radio.o
src/lmic/lmic.c: In function 'decodeFrame':
src/lmic/lmic.c:1040:17: warning: unused variable 'window' [-Wunused-variable]
const char *window = (LMIC.txrxFlags & TXRX_DNW1) ? "RX1" : ((LMIC.txrxFlags & TXRX_DNW2) ? "RX2" : "Other");
^
src/lmic/lmic.c: In function 'processJoinAccept':
src/lmic/lmic.c:1467:10: warning: unused variable 'mic' [-Wunused-variable]
u4_t mic  = os_rlsbf4(&LMIC.frame[dlen-4]); // safe before modified by encrypt!
^
src/lmic/oslmic.c: In function 'os_clearCallback':
src/lmic/oslmic.c:44:10: warning: unused variable 'res' [-Wunused-variable]
u1_t res = unlinkjob(&OS.scheduledjobs, job) || unlinkjob(&OS.runnablejobs, job);
^
Compiling .pioenvs/uno/src/main.o
Archiving .pioenvs/uno/libFrameworkArduinoVariant.a
Indexing .pioenvs/uno/libFrameworkArduinoVariant.a
Compiling .pioenvs/uno/FrameworkArduino/CDC.o
Compiling .pioenvs/uno/FrameworkArduino/HardwareSerial.o
Compiling .pioenvs/uno/FrameworkArduino/HardwareSerial0.o
Compiling .pioenvs/uno/FrameworkArduino/HardwareSerial1.o
Compiling .pioenvs/uno/FrameworkArduino/HardwareSerial2.o
Compiling .pioenvs/uno/FrameworkArduino/HardwareSerial3.o
Compiling .pioenvs/uno/FrameworkArduino/IPAddress.o
Compiling .pioenvs/uno/FrameworkArduino/PluggableUSB.o
Compiling .pioenvs/uno/FrameworkArduino/Print.o
Compiling .pioenvs/uno/FrameworkArduino/Stream.o
Compiling .pioenvs/uno/FrameworkArduino/Tone.o
Compiling .pioenvs/uno/FrameworkArduino/USBCore.o
Compiling .pioenvs/uno/FrameworkArduino/WInterrupts.o
Compiling .pioenvs/uno/FrameworkArduino/WMath.o
Compiling .pioenvs/uno/FrameworkArduino/WString.o
Compiling .pioenvs/uno/FrameworkArduino/_wiring_pulse.o
Compiling .pioenvs/uno/FrameworkArduino/abi.o
Compiling .pioenvs/uno/FrameworkArduino/hooks.o
Compiling .pioenvs/uno/FrameworkArduino/main.o
Compiling .pioenvs/uno/FrameworkArduino/new.o
Compiling .pioenvs/uno/FrameworkArduino/wiring.o
Compiling .pioenvs/uno/FrameworkArduino/wiring_analog.o
Compiling .pioenvs/uno/FrameworkArduino/wiring_digital.o
Compiling .pioenvs/uno/FrameworkArduino/wiring_pulse.o
Compiling .pioenvs/uno/FrameworkArduino/wiring_shift.o
Compiling .pioenvs/uno/lib3f3/SPI/SPI.o
Compiling .pioenvs/uno/libfa9/Wire/Wire.o
Compiling .pioenvs/uno/libfa9/Wire/utility/twi.o
Archiving .pioenvs/uno/libFrameworkArduino.a
Indexing .pioenvs/uno/libFrameworkArduino.a
Archiving .pioenvs/uno/lib3f3/libSPI.a
Indexing .pioenvs/uno/lib3f3/libSPI.a
Archiving .pioenvs/uno/libfa9/libWire.a
Indexing .pioenvs/uno/libfa9/libWire.a
Linking .pioenvs/uno/firmware.elf
Checking program size
text    data     bss     dec     hex filename
25628     138     898   26664    6828 .pioenvs/uno/firmware.elf
Building .pioenvs/uno/firmware.hex
Looking for upload port...

Warning! Please install `99-platformio-udev.rules` and check that your board's PID and VID are listed in the rules.
https://raw.githubusercontent.com/platformio/platformio/develop/scripts/99-platformio-udev.rules
Auto-detected: /dev/ttyACM0
Uploading .pioenvs/uno/firmware.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file ".pioenvs/uno/firmware.hex"
avrdude: writing flash (25766 bytes):

Writing | ################################################## | 100% 4.14s

avrdude: 25766 bytes of flash written
avrdude: verifying flash memory against .pioenvs/uno/firmware.hex:
avrdude: load data flash data from input file .pioenvs/uno/firmware.hex:
avrdude: input file .pioenvs/uno/firmware.hex contains 25766 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.31s

avrdude: verifying ...
avrdude: 25766 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

===================================================================== [SUCCESS] Took 40.60 seconds =====================================================================
************************************************************************************************************************************************************************
Obsolete PIO Core v3.5.1 is used (previous was 3.5.2b5)
Please remove multiple PIO Cores from a system:
http://docs.platformio.org/page/faq.html#multiple-pio-cores-in-a-system
************************************************************************************************************************************************************************
--- Miniterm on /dev/ttyACM0  9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

2018年2月18日 星期日

[Python] Bytes, Bytearray

https://www.dotnetperls.com/bytes-python 有空看看這篇吧 https://blog.ernest.me/post/python-setdefaultencoding-unicode-bytes

2018年2月17日 星期六

[RPi] 使用 serial

使用 serial,改天寫一篇清楚的吧
https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/

2018年2月11日 星期日

[RPi] 5G 網卡

EW-7811 AC6000 還不錯,不過要安裝驅動有點麻煩
https://edimax.freshdesk.com/support/solutions/articles/14000032146-how-to-install-ew-7811-ac600-series-adapter-on-raspberry-pi

再看看 RT5572 吧

[Audio] ReSpeaker 2-MIC HAT .asoundrc 設定

原本是寫這樣
pcm.!default {
 type hw
 card 1
}
ctl.!default {
  type hw
  card 1
}

改成這樣就可以了
pcm.!default {
        type asym
        playback.pcm {
            type plug
            slave.pcm "hw:1,0"
        }
        capture.pcm {
            type plug
            slave.pcm "hw:1,0"
        }
}

ctl.!default {
        type hw
        card 0
}
殺豬公阿:https://github.com/wzpan/dingdang-robot/wiki/respeaker-2-mics-pi-hat

但是使用以後會發現 google assistant 講話速度過快,這是因為
pcm.!default {
        type plug
        slave.pcm {
                type hw
                card 1
                format S16_LE
                rate 16000
        }
}

ctl.!default {
        type hw
        card 1
}

所以最後參考官方提供的範例就可以了
https://www.seeed.cc/topic_detail.html?id=12221


最近發現如果要使用喇叭單體的話,要這樣接和設定

pcm.!default {
  type asym
  capture.pcm "mic"
  playback.pcm "speaker"
}
pcm.mic {
  type plug
  slave {
    pcm "hw:1,0"
  }
}
pcm.speaker {
  type plug
  slave {
    pcm "hw:1,0"
  }
}
https://qiita.com/mayfair/items/ea7343068952911e30ef


2018年2月7日 星期三

[Ubuntu] 在Ubuntu 16.04安裝Arduino

第一種就是 sudo apt-get install arduino

第二種就是下載 source 以後安裝

如果是 1.8.2 需要修改 install.sh

將 RESOURCE_NAME=cc.arduino.arduinoide

改為 RESOURCE_NAME=arduino-arduinoide

然後執行 arduino 會報一個很奇怪的錯誤

./arduino: line 35: /home/user/arduino-1.8.2/java/bin/java: No such file or directory

結果竟然是沒安裝 libc6-i386 但是安裝後換下一個錯誤
Picked up JAVA_TOOL_OPTIONS:
java.lang.UnsatisfiedLinkError: /home/user/arduino-1.8.2/java/lib/i386/libsplashscreen.so: libX11.so.6: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at java.awt.SplashScreen$1.run(SplashScreen.java:124)
    at java.awt.SplashScreen$1.run(SplashScreen.java:122)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.SplashScreen.getSplashScreen(SplashScreen.java:121)
    at processing.app.Base.(Base.java:211)
    at processing.app.Base.main(Base.java:140)




改了一堆,把路徑加入 /etc/ld.so.conf 以後重新讀取還是不行
$ sudo ldconfig
$ ldconfig -p



發現是少裝了這個套件
$ sudo apt-get install libx11-6:i386

又發現還有其他套件沒裝,最後最後終於知道,如果是 64bit 機器請乖乖安裝 64 位元的版本吧,馬上順利開啟!

[Linux] 安裝 Java 在 Ubuntu 16.04


Installing the Default JRE/JDK
$ sudo apt-get update
$ sudo apt-get install default-jre
$ sudo apt-get install default-jdk

Installing the Oracle JDK



$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer

Managing Java
$ sudo update-alternatives --config java

Setting the JAVA_HOME Environment Variable
$ sudo update-alternatives --config java

$ vim ~/.bashrc
JAVA_HOME="/usr/lib/jvm/java-8-oracle"


參考這篇:
https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04