2015年6月28日 星期日

QEMU VFIO實作

實作VFIO首先要先確定你的硬體是否有支援
  • Intel的CPU要有支援VT-D
  • AMD的CPU要有支援AMD-VI
  • 主機板也是要選用有支援VT-D/AMD-VI功能,才可以使用VFIO功能
我的電腦是Intel的E3-1230V2,以下用Intel的CPU為例
直接去Intel官網查CPU型號,找到以下技術且為YES就表示你的CPU有支援VT-D


 
接下來就要看主機板有沒有支援VT-D/AMD-VI,以國內4家華碩、微星、技嘉、華擎來說
依我使用的是Z77/H77晶片為例
  • 華碩:BIOS完全沒有支援VT-D功能,要X79、X99等級以上才有
  • 微星:BIOS大部份都有支援VT-D
  • 華擎:BIOS大部份都有支援VT-D
  • 技嘉:BIOS少部份支援,如UD5H、D3H等,剩下也是要X79、X99等級以上才有
以上主機板是我從網路找出來稍微整理的,所以除非你要買到伺服器級的主機板
不然BIOS想要有VT-D功能建議買微星或華擎的

#確定你硬體都有支援後在開始實作VFIO功能

########################################################

1. 把核心有關VFIO的都編譯起來之後重開機

2. 在/etc/modules加入以下模組

pci_stub
vfio
vfio_iommu_type1
vfio_pci
kvm
kvm_intel

3. 在/etc/default/grub加入以下參數
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on vfio_iommu_type1.allow_unsafe_interrupts=1"

4. 執行以下指令
# update-grub

5. 重新開機
# shutdown -r now

接下來要設定給QEMU使用的顯卡

1. 使用 lspci -nn 觀察你所安裝的顯卡
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation G98 [GeForce 8400 GS Rev. 2] [10de:06e4] (rev a1) <-- HOSTGPU: 8400GS
02:00.0 VGA compatible controller [0300]: NVIDIA Corporation Device [10de:13c2] (rev a1) <-- GUESTGPU: GTX 970
02:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:0fbb] (rev a1) <-- GTX 970 aduio

2. 在/etc/initramfs-tools/modules加入QEMU要用的GPU,如下指令
pci_stub ids=10de:13c2,10de:0fbb

3. 再執行以下指令
# update-initramfs -u

4. 重新開機
# shutdown -r now

5. 輸入 dmesg | grep pci-stub 指令後,會看到底下訊息
[    1.834707] pci-stub: add 10DE:13C2 sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[    1.834715] pci-stub 0000:02:00.0: claimed by stub
[    1.834720] pci-stub: add 10DE:0FBB sub=FFFFFFFF:FFFFFFFF cls=00000000/00000000
[    1.834724] pci-stub 0000:02:00.1: claimed by stub

6. /etc/vfio-pci.cfg 建立這檔案,並加入在上面使用 lspci -nn 查到的顯卡
0000:02:00.0
0000:02:00.1

7. 接下來建立啟動虛擬機的script檔,我的script檔叫vm1
#!/bin/bash

configfile=/etc/vfio-pci.cfg
MEMORY=4096
HDA=win8.img
MAC="DE:AD:BE:CF:EC:B9"
BRIDGE=br10
VGA=02:00.0


vfiobind() {
    dev="$1"
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id


 }

modprobe vfio-pci

cat $configfile | while read line;do
    echo $line | grep ^# >/dev/null 2>&1 && continue
        vfiobind $line
done

qemu-system-x86_64 -enable-kvm -m $MEMORY -cpu host,kvm=off \
-smp 4,sockets=1,cores=4,threads=1 \
-vga none  \
-boot c \
-device vfio-pci,host=$VGA,x-vga=on \
-device vfio-pci,host=02:00.1
-drive file=win8.img,format=raw \
-net nic,macaddr=$MAC -net nic,model=e1000 -net bridge,br=$BRIDGE

8. 把vm1權限改成755
# chmod 755 vm1

9. 這樣就可以直接執行vm1
# ./vm1

程式設計概論0628

# 上上週課程複習
# 輸入窗
import javax.swing.*;
// input is String
        BufferedReader buf;
        String str1;
        buf=new BufferedReader(new InputStreamReader(System.in));
        str1=JOptionPane.showInputDialog("Input Integer Num. :");
// str1 to integer(a)
        int a;
        a=Integer.parseInt(str1);
// show dialog
JOptionPane.showMessageDialog(null,"Input Error, range 0~100");

# 邏輯運算子
# && and 所有為真即為真
# || or 只要有一個真就是真

A && B  T || F
T    T  F    T

# 0 以下;100 以上
# 50~59 之間要補考
a < 0 || a > 100
a < 60 && a > 49

# 結樣設計
循序性
由上至下

開始
 |
敘述1
 |
敘述2
....|
敘述n

# 選擇性結構
根據判斷條件成立與否,決定程式該執行哪一個敘述。
if_else
switch_case

# 重複性結構
根據判斷條件成立與否,決求程式執行的次數。
for
while
do-while

# 條件運算子 ?:
# 此為 if-else 的簡潔版
傳回值 = (判斷式)?true:false;

# for 迴圈
for (設定初值;判斷條件;設定增減量)
{
        程式敘述;
}

# while 迴圈
設定初值;
while(判斷條件){
        程式敘述;
        設定增減量;
}

# do-while 迴圈
設定初值;
do
{
        程式敘述;
        設定增減量:
}while(判斷條件);

# break 敘述,跳離迴圈外
for(.....){
        程式敘述;
        ...
        break;
        ...
        程式敘述(不會執行);
}

# continue 敘述,跳至迴圈初始
for(.....){
        程式敘述;
        ...
        continue;
        ...
        程式敘述(不會執行);
}

# switch_case
switch(運算式)
{
        case1:
        敘述;
        break;

        case2:
        敘述2;
        break;

        ...

        default;
}

# 陣列
存放相同資料型態的資料。

# 陣列宣告:
資料型態 陣列名稱[] = new 資料型態[個數]

 (1) 宣告陣列名稱。
 (2) 利用 new 配置記憶體區塊。
 (3) 下面三種位置都能宣告,但不能在 int 前面。
int arr[];
int[] arr;
int []arr;

# 陣列初值設定
# 假設有間旅館 arr,有五個房間,房間編號 0,1,2,3,4,分別五個客人{1,2,3,4,5}
int arr[]={1,2,3,4,5};

# 也可以先設定好陣列數,但不放資料。
int arr[]=new int[5];
arr[0]=3;
arr[1]=7;
arr[2]=8;
# 沒宣告初值的陣列會自動補資料 0,所以 arr[3]=arr[4]=0

# 陣列長度
陣列名稱.length;

2015年6月27日 星期六

Bluetooth 藍芽配對連接

Debug 在置底。

---------------------------------------------------------------------
說明:筆者使用於筆電之內建藍芽與藍芽機械式鍵盤進行配對 。

*** 規格 ***
系統: Debian Jessie 8.0
核心:3.16.7
筆電:Acer v3-772g
鍵盤:ZIPPY BW7050
---------------------------------------------------------------------
查看無線驅動:
lspci -k|grep -iA2 Network
0d:00.0 Network controller: Qualcomm Atheros AR9462 Wireless Network Adapter (rev 01)
Subsystem: Foxconn International, Inc. Device e052
Kernel driver in use: ath9k
---------------------------------------------------------------------
檢查驅動:
lsmod |grep ath9k
lsmod |grep bluetooth
---------------------------------------------------------------------
安裝 bluetooth 套件:
apt-get update
apt-get install bluetooth bluez
apt-get upgrade -y
---------------------------------------------------------------------
啟動服務:
systemctl enable bluetooth.service
systemctl start bluetooth.service
systemctl status bluetooth.service
---------------------------------------------------------------------
設定檔:vi /etc/default/bluetooth
# Defaults for bluez-utils

# This file supersedes /etc/default/bluez-pan. If
# that exists on your system, you should use this
# file instead and remove the old one. Until you
# do so, the contents of this file will be ignored.

# start bluetooth on boot?
# compatibility note: If this variable is not found bluetooth will
# start
BLUETOOTH_ENABLED=1

# This setting will switch HID devices (e.g mouse/keyboad) to HCI mode, that is
# you will have bluetooth functionality from your dongle instead of only HID.
# Note that not every bluetooth dongle is capable of switching back to HID
# mode, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=355497
HID2HCI_ENABLED=1
HID2HCI_UNDO=1
---------------------------------------------------------------------
常用指令:
hciconfig: 顯示本機藍芽裝置
hciconfig -a: 顯示本機藍芽裝置詳細資訊
hciconfig hci0 up/down: 啟用 / 關閉第一個藍芽裝置 ( hci0 )
hcitool dev: 顯示本機所有藍芽裝置address
hcitool scan: 搜尋周邊欄芽裝置
---------------------------------------------------------------------
無線裝置軟/硬體開關 (blocked:no 為裝置開啟):
sudo rfkill list
0: acer-wireless: Wireless LAN
Soft blocked: yes
Hard blocked: no
1: acer-bluetooth: Bluetooth
Soft blocked: no
Hard blocked: no
2: phy0: Wireless LAN
Soft blocked: yes
Hard blocked: yes
3: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
sudo rfkill block all -----------> 關閉全部無線裝置
rfkill unblock bluetooth--------> 只開啟 bluetooth
---------------------------------------------------------------------
使用 bluetoothctl 指令配對連線:
bluetoothctl -----------> 進入 bleutoothctl 指令模式 exit 或 quit 可離開

以下為 [bluetooth]# 下的指令:
help
version
power on -------------> 開啟藍芽
list --------------------> 查看本機 Bluetooth
discoverable off -------> 筆電藍芽不開放給別人看到
pairable off ------------> 筆電藍芽不開放給別人配對
scan on ----------------> 開啟掃描,此時會抓到我的鍵盤 BT address
[NEW] Device AB:CD:EF:00:11:22 我的鍵盤 BT Address

開始連線 ( [bluetooth]# 下):
info AB:CD:EF:00:11:22 -----> 查看鍵盤藍芽裝置
pair AB:CD:EF:00:11:22 -----> 配對
trust AB:CD:EF:00:11:22 -----> 加到信任
unblock AB:CD:EF:00:11:22 -> 不阻擋
connect AB:CD:EF:00:11:22 -> 連線

此時沒意外話,可以連上鍵盤了。
---------------------------------------------------------------------
Debug

善用幾個指令 debug 看系統訊息,方便至 google 爬文。
dmesg | grep -i bluetooth
sudo grep bluetooth /var/log/syslog
systemctl status bluetooth
---------------------------------------------------------------------
Debug1

核心驅動問題
cd /usr/src/linux
make menuconfig

進入 -*- Networking support  ---> <M>   Bluetooth subsystem support  --->
--- Bluetooth subsystem support
  │ │    [ ]   Bluetooth 6LoWPAN support
  │ │       RFCOMM protocol support
  │ │    [*]     RFCOMM TTY support
  │ │       BNEP protocol support
  │ │    [*]     Multicast filter support
  │ │    [*]     Protocol filter support
  │ │       CMTP protocol support
  │ │       HIDP protocol support
  │ │          Bluetooth device drivers  --->

進入 -*- Networking support  ---> <M>   Bluetooth subsystem support  ---> Bluetooth device drivers  -->
 HCI USB driver 
  │ │     HCI SDIO driver
  │ │     HCI UART driver
  │ │    [*]   UART (H4) protocol support
  │ │    [*]   BCSP protocol support
  │ │    [*]   Atheros AR300x serial support
  │ │    [*]   HCILL protocol support
  │ │    [*]   Three-wire UART (H5) protocol support
  │ │     HCI BCM203x USB driver
  │ │     HCI BPA10x USB driver
  │ │     HCI BlueFRITZ! USB driver
  │ │     HCI DTL1 (PC Card) driver
  │ │     HCI BT3C (PC Card) driver
  │ │     HCI BlueCard (PC Card) driver
  │ │     HCI UART (PC Card) device driver
  │ │     HCI VHCI (Virtual HCI device) driver
  │ │     Marvell Bluetooth driver support
  │ │       Marvell BT-over-SDIO driver
  │ │     Atheros firmware download driver

save ---> exit
time make-kpkg --initrd --revision=$version kernel_image -j $CORE
dpkg -i linux-image-$version_amd64.deb
reboot
.
.
.
其他驅動問題,參考 http://ubuntuforums.org/showthread.php?t=2251009

至 http://drvbp1.linux-foundation.org/~mcgrof/rel-html/backports/ 下載對應核心之 backport 檔,接著做:
cd Desktop/backports-3.18-rc1-1
make defconfig-ath9k
make
sudo make install
sudo reboot
---------------------------------------------------------------------
Debut 2

hciconfig ------> 無輸出
hcitool dev ----> 無裝置
hcitool scan ---> 無輸出

查看無線 WiFi/Bluetooth 卡是不是 Atheros 的?
lspci -k |grep -i network

參考 http://unix.stackexchange.com/questions/146097/bluetooth-device-not-working-debian-wheezy
可以試試安裝
apt-get install firmware-atheros
---------------------------------------------------------------------
Debug 3

因本人在編譯其他軔體時,不小心誤將 Bluetooth 的其中一個 firmware 刪除或覆蓋,因此在開機的時候,就顯示如下圖:



使用以下指令也可以看到此錯誤訊息:
dmesg | grep -i bluetooth

使用下列指令去尋找 ar3k 這個資料夾:
find / -name ar3k

確實裏面找不到 ramps_0x11020100_40.dfu 這個檔案

可以到以下網址去下載:
http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/ar3k

將所缺失的檔案載入,就ok了。

然後在 reboot 。
---------------------------------------------------------------------



Reference:
https://wiki.debian.org/BluetoothUser




2015年6月15日 星期一

設定指令優先權(Java 安裝為例)



update-alternatives --install <連結> <名稱> <路徑> <優先權>
update-alternatives --config <指令>



範例來說明:
當我們想裝最新版本的 Java,但又本身電腦裝有舊版時,
但想要兩者皆保留,而目前需要使用的是最新版本。

1. 查看目前版本,下面 "1.7.0_79" 是舊版:
java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

2. 下載最新版本:
Java SE Development Kit 8u45

這邊我是選擇下載 jdk-8u45-linux-x64.tar.gz

3. 解壓縮
sudo tar xfva jdk-8u45-linux-x64.tar.gz -C /opt

4. 設定 PATH (一般USER)
cd ~
vi .bashrc
PATH=$PATH:/opt/jdk1.8.0_45/bin
source .bashrc

5. 新增優先權選項
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.8.0_45/bin/java" 1

6. 設定 /urs/bin/java 這指令優先權
sudo update-alternatives --config java
  選項       路徑                                          優先權  狀態
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      自動模式
  1            /opt/jdk1.8.0_45/bin/java                        0         手動模式
  2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      手動模式
選擇 1 ; enter

7. 檢查版本,要可以看到最新版
java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)




Beamer 範本2:專題研討課程 PPT


檢視:USB_Joystick.pdf
下載:USB_Joystick.tex

編譯方式 (若有 .bib 檔可能需要先 rm 刪除掉):
xelatex USB_Joystick
bibtex USB_Joystick
xelatex USB_Joystick
xelatex USB_Joystick

evince USB_Joystick.pdf

% Latex Beamer - USB Joystick 
% 2015/06/17
%===============================================================
% LaTeX Beamer environment setting
\documentclass[xetex,mathserif,serif,xcolor=dvipsnames]{beamer}

% 解決 XeTeX 中文的斷行問題
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt

\usepackage{color, colortbl}
\usepackage{caption}
\usepackage{url, hyperref}
\captionsetup{skip=0pt,belowskip=0pt}
%===============================================================
%% 字型 Fonts Setting
%% Reference: http://hyperrate.com/thread.php?tid=23544
% 預設英文字體
\usepackage{arevmath}
\usepackage[no-math]{fontspec}
\setmainfont[Scale=0.9]{DejaVuSansMono}

% 預設中文字體
\usepackage[CJKchecksingle, normalindentfirst, SlantFont, BoldFont]{xeCJK}
\setCJKmainfont{金梅新中楷國際碼}

% 自定義字體切換指令
% 中文
\newfontfamily{\J}{金梅新中楷國際碼}
\newfontfamily{\B}{華康中黑體}

% 英文
\newfontfamily{\D}[Scale=0.9]{DejaVuSansMono}
\newfontfamily{\T}{Times New Roman}
\newfontfamily{\A}{Arial}

% 粗體字
% \textbf{內容}
%===============================================================
%% Theme 設定主題樣式
\usetheme{Madrid}
%===============================================================
%% Color Theme設定投影片顏色
\usecolortheme{beaver}
%===============================================================
% 設定列表樣式
% 可以選擇:ball, circle, rectangle, default
\setbeamertemplate{items}[ball]
\setbeamertemplate{caption}[numbered]
%===============================================================
%隱藏 beamer 底部小工具列
\setbeamertemplate{navigation symbols}{}
%====================================================================
% 重設 frametitle 的預設為置中,上方的 usetheme 要改為 [height=0]
\setbeamertemplate{frametitle}[default][center]
%==============================================================================
%% Reference Table
% https://zh.wikipedia.org/wiki/BibTeX
% http://tex.stackexchange.com/questions/68080/beamer-bibliography-icon
\begin{filecontents}{\jobname.bib}
@article{ref1,
        author={林永昌},
        title={USB規格與技術},
        journal={CCL TECHNICAL JOURNAL},
        pages={26--32},
        volume={103期},
        year={2003-03-25}
}

% http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=5776968
@article{ref2,
        author={Yung-Hoh Sheua, Tsun-Hsiang Fu, Chun-Ming Ku},
        title={The Design of FlexRay/CAN/LIN Protocol Analyzer},
        pages={5466--5469},
        year={2011},
        journal={Electric Information and Control Engineering (ICEICE)}
}

% http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6287165
@article{ref3,
        author={Nurul Fatihah Jusoh, Muhammad Adib Haron, Fuziah Sulaiman },
        title={An FPGA Implementation of Shift Converter Block
Technique on FIFO for RS232 to Universal Serial
Bus Converter},
        pages={219--224},
        year={2012},
        journal={Control and System Graduate Research Colloquium (ICSGRC)}
}

% http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6168758
@article{ref4,
        author={Nurul Fatihah Jusoh, Azlina Ibrahim, Muhamad Adib Haron and Fuziah Sulaiman},
        title={An FPGA Implementation of Shift Converter Block
Technique on FIFO for UART},
        pages={320--324},
        year={2011},
        journal={RF and Microwave Conference (RFM)}
}

@book{b1,
    title={USB 2.0 系統開發實例精解},
    author={廖濟林},
    isbn={9789861990040},
    year={2007},
    publisher={城邦文化事業股份有限公司},
    keywords = {USB}
}

@book{b2,
    title={USB 2.0 原理與研發技術},
    author={王成儒、李英偉},
    isbn={9572152688},
    year={2006},
    publisher={全華科技圖書股份有限公司},
    keywords = {USB}
}

@book{b3,
    title={微處理機與 USB 主從介面之設計與應用},
    author={許永和},
    isbn={9574997677},
    year={2006},
    publisher={儒林圖書有限公司},
    keywords = {USB}
}

@book{b4,
    title={USB 規格與理論剖析},
    author={許永和},
    isbn={9789574998692},
    year={2009},
    publisher={儒林圖書有限公司},
    keywords = {USB}
}

@book{b5,
    title={USB 應用開發技術大全},
    author={薛園園},
    isbn={9789862041529},
    year={2008},
    publisher={文魁資訊股份有限公司},
    keywords = {USB}
}

@online{arduino,
        author={Circuits@Home},
        title={USB Host Shield 2.0 for Arduino},
        howpublished={\url{https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino}},
        note={Accessed:2015-06-08}
}

@misc{p1,
        title={USB Protocol Analyzer},
        yesr={2013},
        howpublished={\url{http://goods.ruten.com.tw/item/show?21303303948219}},
        note={Accessed:2015-06-08}
}

@misc{p2,
        title={Beagle USB 12 Protocol Analyzer},
        howpublished={\url{http://www.totalphase.com/products/beagle-usb12/}},
        note={Accessed:2015-06-08}
}

@misc{p3,
        title={MQP Electronics Packet-Master USB 12},
        howpublished={\url{http://www.mqp.com/usbdev_buy.htm}},
        note={Accessed:2015-06-08}
}

@misc{p4,
        title={ITIC 1480A USB 2.0 Protocol Analyzer},
        howpublished={\url{http://www.internationaltestinstruments.com/products/97-1480a-usb-20-protocol-analyzer.aspx}},
        note={Accessed:2015-06-09}
}

@misc{p5,
        title={Elisys USB Explorer 200 Basic},
        howpublished={\url{http://www.ellisys.com/products/usbex200/}},
        note={Accessed:2015-06-09}
}

@misc{p6,
        title={LeCroy Conquest Standard},
        howpublished={\url{http://teledynelecroy.com/protocolanalyzer/}},
        note={Accessed:2015-06-09}
}

@misc{mcp2200,
        title={MCP2200},
        howpublished={\url{http://www.microchip.com/wwwproducts/devices.aspx?dDocName=en546923}},
        note={Accessed:2015-06-06}
}

@misc(ncku,
        title={USB (Universal Serial Bus)},
        author={成大資工},
        howpublished={\url{http://wiki.csie.ncku.edu.tw/embedded/USB}},
        note={Accessed:2015-06-13}
}

@misc{zeroplus,
        title={USB2.0信號分析技巧},
        author={ZEROPLUS},
        howpublished={\url{http://www.zeroplus.com.tw/E-paper/201112/images/201112-USB20ProtocolAnalyzer.pdf}},
        note={Accessed:2015-06-13}
}
\end{filecontents}
%==============================================================================
%% Reference Setting 參考文獻環境設定
%% https://www.economics.utoronto.ca/osborne/latex/BIBTEX.HTM
%% http://tex.stackexchange.com/questions/147279/references-at-the-end-of-beamer-slides
\usepackage{cite}
\usepackage{natbib}

%\usepackage{natbib}
%\usepackage{bibtex}
%\usepackage{bibentry}
%\usepackage{chngcntr}
%\bibliographystyle{apalike}
%%%\bibliographystyle{stylename}
%
%\setbeamercolor*{bibliography entry title}{fg=black}
%\setbeamercolor*{bibliography entry author}{fg=black}
%\setbeamercolor*{bibliography entry location}{fg=black}
%\setbeamercolor*{bibliography entry note}{fg=black}
%\setbeamertemplate{bibliography item}{}
%%\setbeamertemplate{bibliography item}{\insertbiblabel}
%\setbeamertemplate{frametitle continuation}[from second]
%
%\counterwithin*{footnote}{page}
%\newcommand\fcite[1]{\footnote{\tiny \bibentry{#1}}\label{\thepage:#1}}
%\newcommand\scite[1]{\textsuperscript{\ref{\thepage:#1}}}
%
%\nobibliography{\jobname}
%==============================================================================
\begin{document}
%==============================================================================
\title[\tiny USB sniffer with the Arduino]{\huge USB sniffer with the Arduino}
\author[\tiny MA330101 廖凱霖]{\\MA330101 廖凱霖}
\date[\tiny 2015/06/17]{2015/06/17}
%==============================================================================
%%% 投影片開始 Frame Start

% Title
\frame{\titlepage}

% Outline
\frame{ \frametitle{Outline}
        \tableofcontents}

% Abstract
% 做什麼東西,用什麼方法,得到什麼結果
\section{摘要}
\frame{ \frametitle{摘要}
\begin{itemize}[<+->]
        \item 做 USB (Universal Serial Bus) 訊號封包解析儀。
        \item 自動解碼,直接得到封包、資料。
        \begin{figure}
                \centering
                \includegraphics[width=0.6\textwidth]{analyzer.jpeg}
                \caption{USB 解析儀架構圖}
        \end{figure}
\end{itemize}
}

%Action 
\section{研究動機}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{研究動機 1/2}
\begin{itemize}[<+->]
        \item 產學合作:「做 PlayStation 4 格鬥搖桿台」。
        \item 實驗室舊型號邏輯分析儀不支援 USB 解析。
        \item 封包做解碼及列表整理需花大量時間。
\end{itemize}
}

%
\frame{ \frametitle{研究動機 2/2}
\begin{itemize}
        \item 市場調查:
        \begin{itemize}
                \item 市面上 USB 封包解析儀,價格昂貴 (至少壹萬元起跳)。
                \item 整合太多功能,操作複雜。
        \end{itemize}
\end{itemize}
% -------------
\captionof{table}{USB 分析儀市場調查表}
\begin{table}[h]
\begin{tabular}{|l|r|}
\hline
\rowcolor[HTML]{000000}
\multicolumn{1}{|c|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} 產品名稱}} & \multicolumn{1}{c|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} 市售價格}} \\ \hline
USB Protocol Analyzer                                                     & NT\$10,500                                                               \\ \hline
Beagle USB 12 Protocol Analyzer                                           & NT\$14,777                                                               \\ \hline
MQP Electronics Packet-Master USB 12                                      & NT\$15,698                                                               \\ \hline
ITIC 1480A USB 2.0 Protocol Analyzer                                      & NT\$21,621                                                               \\ \hline
Elisys USB Explorer 200 Basic                                             & NT\$24,856                                                               \\ \hline
LeCroy Conquest Standard                                                  & NT\$37,300                                                               \\ \hline
\end{tabular}
\end{table}
\nocite{p1,p2,p3,p4,p5,p6}
%-------------
}

%background 
\section{研究背景及知識}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{研究背景及知識 1/5}
\nocite{b1,b2,b5,b3,b4,ref1}
\begin{itemize}[<+->]
        \item 無時脈訊號 (Clock Signal)。
        \item 使用兩條差動訊號 D+/D- 做資料傳遞。
        \item 定義訊號 `1':(D+) - (D-) > 200mV \\
                定義訊號 `0':(D+) - (D-) < -200mV
\end{itemize}
}

%background 
\frame{ \frametitle{研究背景及知識 2/5}
\begin{itemize}[<+->]
        \item 使用 NRZI(Non-Return to Zero Inverted) 編碼:\\
                設起始狀態 H,資料 `0' 狀態反向;`1' 狀態保持原來。
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[width=0.8\textwidth]{NRZI.jpeg}
        \caption{NRZI 編碼流程圖}
\end{figure}
}
%
\frame{ \frametitle{研究背景及知識 3/5}
\begin{itemize}
        \item USB 一個完整的傳輸單位:資訊交易 (Transaction)。
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[width=0.9\textwidth]{transation.jpeg}
        \caption{單個 Transation 架構圖}
\end{figure}
}
%
\frame{ \frametitle{研究背景及知識 4/5}
\begin{itemize}
        \item 封包組成格式\cite{zeroplus}:
\begin{itemize}
        \item 同步序列:取代 Clock 來同步資料。
        \item PID:定義封包類型。
        \item 封包具體資訊:封包資料內容(依 PID 而有所不同)。
        \item CRC:檢查錯誤。
        \item EOP:結束封包 (回到 idle ) 狀態。
\end{itemize}
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[width=0.9\textwidth]{packet.jpeg}
        \caption{封包 Padket 基本格式}
\end{figure}
}
%
\frame{ \frametitle{研究背景及知識 5/5}
\begin{itemize}
        \item 資料型態辨別:PID (Packet ID)。
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[height=0.72\textheight]{0015.jpg}
        \caption{PID Types\cite{ncku}}
\end{figure}
}

%% 
\section{文獻回顧及探討}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{文獻回顧及探討}
\begin{itemize}
        \item 參考文獻 \cite{ref3,ref4},以 FPGA 實作 UART to USB 訊號轉換器。
\end{itemize}
\begin{figure}
        \centering
        \includegraphics[width=0.8\textwidth]{uarttousb.jpg}
        \caption{FIFO 轉換圖框}
\end{figure}
}

% 
\section{研究方法及步驟}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{研究方法及步驟 1/4}
\begin{itemize}
        \item 使用現有設備量測原廠 PS4 搖桿,建立資料庫。
\end{itemize}
\begin{figure}
        \begin{columns}
        \column{0.5\textwidth}
                \includegraphics[width=\textwidth]{agilent.jpg}
                \caption{Agilent 示波器}
        \column{0.5\textwidth}
                \includegraphics[width=\textwidth]{zp.jpg}
                \caption{Zeroplus 邏輯分析儀}
        \end{columns}
\end{figure}
}
%
\frame{ \frametitle{研究方法及步驟 2/4}
\begin{itemize}
        \item 實作的方法:Arduino UNO + MCP2200 \cite{mcp2200}
\end{itemize}
        \begin{figure}
        \centering
        \only<1>{\includegraphics[width=0.6\textwidth]{arch1.jpeg}}\only<2>{\includegraphics[width=0.6\textwidth]{arch2.jpeg}}\only<3>{\includegraphics[width=0.6\textwidth]{arch3.jpeg}}
                \caption{實作方法架構圖}
        \end{figure}
}
%
\frame{ \frametitle{研究方法及步驟 3/4}
\begin{itemize}
        \item 使用 Arduino UNO 開發板 (ClockSpeed 16MHz)。
        \item USB Device (1.5 MBps, Low-speed) 訊號分析不需要高速運算。
        \item 價格低。
\end{itemize}
%figure
\begin{figure}
        \centering
        \includegraphics[width=0.5\textwidth]{uno.png}
        \caption{Arduino UNO 開發板}
\end{figure}

}
%
\frame{ \frametitle{研究方法及步驟 4/4}
\begin{itemize}
        \item 使用晶片:MCP2200 (USB to UART)。
        \item 讓 USB D+/D- 與 Arduino Tx/Rx 能夠互相溝通。
\end{itemize}
%figure
\begin{figure}
        \centering
        \includegraphics[width=0.8\textwidth]{mcp2200_arch.jpg}
        \caption{MCP2200 晶片架構}
\end{figure}

}

% 
\section{預期研究成果}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{預期研究成果}
\begin{itemize}
        \item 對多種主機平台(例如:PS3, PS4, XBOX, PC...等),\\
              解析其 USB 週邊裝置之封包訊號。
        \item 不要太多設定,一插即分析並整理好封包資料。
\end{itemize}
%figure
\begin{figure}
        \centering
        \includegraphics[width=0.8\textwidth]{analyzer_2.jpeg}
        \caption{多平台分析示意圖}
\end{figure}

}

% 
\section{結論}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{結論}
\begin{itemize}[<+->]
        \item USB 為現在及未來之人機介面的主流趨勢。
        \item 封包解析變得更簡易更省成本。
        \item 仍要依循 USB-IF 制定的規則及標準。
        \item 未來進一步的發展方向為`藍芽裝置'的解析。
\end{itemize}
}

% 
\section{參考文獻}
\frame{ \frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{參考文獻}
        \tiny{\bibliographystyle{abbrv} }
        \bibliography{\jobname} }
\end{document}

2015年6月14日 星期日

程式設計概論0614

Data Type
 char = 字元


 byte = 整數
 short
 int
 long


float = 浮點數
double


boolean = 布林



 Data Type 變數名稱 = _____ ; 初始值 

※注意大小寫
※英文字母,數字or底線

#################################################################################

for example2

 //變數的宣告

 public class Test3{
                      public static void main (String args[]){
                                 //int num1=2, num2=3;
                                   int num1=2;
                                   int num2=3;

                                       System.out.println("I have "+num1+" dog"+".");
                                       System.out.println("He has "+num2+" dog"+".");
                                       System.out.println("So we are have "+(num1+num2)+" dogs"+".");                                                        System.out.println("Sol:"); System.out.println(num1+" + "+num2+" = "+(num1+num2)); 
            }
}

 #################################################################################

Ans:


#################################################################################

 ※ 跳脫字元 

\n ---> 換行
\t ---> Tab
\\ ---> 斜線
\" ---> 雙引號
\' ---> 單引號

#################################################################################

 for example 4

 //字元宣告

 public class Test4{
                             public static void main(String args[]){

                                    char c1=71; // ASCII
                                    char c2='G'; // 字母
                                    char c3='\u0047'; // unicode
                                    char c4='\"'; // "
                            System.out.println(c1+","+c2+","+c3);
                            System.out.println("\"Spring is coming.\"");
                            System.out.println(c4+"Spring is coming."+c4); 
               }
}

 #################################################################################

Ans:


#################################################################################

//Data Type Change

1. 轉換前的資料型態要和轉換後相容。
2. 轉換後的資料型態要大於轉前。
※(資料型態) 變數名稱。

#################################################################################

for example 5

//字元宣告

public class Test5{
public static void main(String args[]){

int a=47; //
float b=2.3f; //
int c=36,d=7;        //

System.out.println("Sol:");
System.out.println("a= "+a+" , "+" b= "+b);
System.out.println(a+"/"+b+" = "+(a/b));
 System.out.println("c= "+c+" , "+" d= "+d);
System.out.println(c+"/"+d+" = "+(double)c/d);
}
}


#################################################################################

Ans:


#################################################################################

※String 轉 數值

Byte.parseByte()

Short.parseShort()

Integer.parseInt()

Long.parseLong()

Float.parseFloat()

Double.parseDouble()


#################################################################################

※for example 相乘  (Swing)

//
import javax.swing.*;

public class SwingDemo{
public static void main(String args[]){

String str; //負責接收輸入的data
int num; //負責轉換後的data

 str=JOptionPane.showInputDialog("Input number:"); //將輸入值指定給str
 num=Integer.parseInt(str); //將轉換後的值指定給給num
JOptionPane.showMessageDialog(null,(num*num));

}
}

#################################################################################



一元運算子

+   --->  正號
-    --->  負號

算數運算子

+
-
*
/
%  ---> 取餘數, ex: a=5%3 = 2

if 敘述和關係運算式

>
<
=
!=
==

#################################################################################

遞增遞減運算子

++
--





2015年6月12日 星期五

Beamer 範本:每週進度報告

以下為我個人使用的範本:

檢視:mybeamer.pdf
下載:mybeamer.tex

編譯方式 (若有 .bib 檔可能需要先 rm 刪除掉):
xelatex mybeamer
bibtex mybeamer
xelatex mybeamer
xelatex mybeamer

evince mybeamer.pdf



vi mybeamer.tex

% version 2015/06/06
%===============================================================
% LaTeX Beamer environment setting
\documentclass[xetex,mathserif,serif,xcolor=dvipsnames]{beamer}
%\usepackage{fontspec,xunicode,xltxtra} %可自定義 fonts 的套件
%\usepackage[nodayofweek]{datetime}% 設定 \today 套件
\usepackage{listings} %% 程式語言 demo 套件

%自訂一個 \myday 時間格式
%\newdateformat{mydate}{\twodigit{\THEDAY}{ }\shortmonthname[\THEMONTH], \THEYEAR}

%\usepackage{datenumber}%時間計數器
%\usepackage[top=2cm,botton=2cm,left=2cm,right=2cm]{geometry}

% 解決 XeTeX 中文的斷行問題
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
%\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt

% WebLink
\usepackage{url, hyperref}

% Table Setting
\usepackage{color, colortbl}
\usepackage{caption}
\captionsetup{skip=0pt,belowskip=0pt}
%===============================================================
%% 字型 Fonts Setting
%% http://hyperrate.com/thread.php?tid=23544

% 預設英文字體
\usepackage{arevmath}
\usepackage[no-math]{fontspec}
\setmainfont[Scale=0.9]{DejaVuSansMono}
%\setmainfont[Mapping=tex-text,LetterSpace=-1.25]{DejaVu Sans}
%\setsansfont[Mapping=tex-text,LetterSpace=-1.25]{DejaVu Sans}
%\setmonofont[Color=00663300]{DejaVu Sans Mono}

% 預設中文字體
\usepackage[CJKchecksingle, normalindentfirst, SlantFont, BoldFont]{xeCJK}
\setCJKmainfont{金梅新中楷國際碼}
%\setCJKmainfont[Scale=1.2,BoldFeatures={FakeBold=1.8}]{金梅新中楷國際碼}
%\setCJKmonofont[Scale=1.2,BoldFeatures={FakeBold=1.8},FakeStretch=1.11686,Color=00663300]{金梅新中楷國際碼}

% 自定義字體切換指令
% 中文
\newfontfamily{\J}{金梅新中楷國際碼}
\newfontfamily{\B}{華康中黑體}

% 英文
\newfontfamily{\D}[Scale=0.9]{DejaVuSansMono}
\newfontfamily{\T}{Times New Roman}
\newfontfamily{\A}{Arial}

% 粗體字 / 斜體字
% \textbf{粗體內容}
% \textit{斜體內容} 
%===============================================================
%% Theme 設定主題樣式
%%底部可以加上標題,要注意的是一定要在選定主題 \usetheme 之前就使用
%\useoutertheme{infolines}

%% 參考樣式 https://www.hartwork.org/beamer-theme-matrix/
%% http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme_and_color.html
%% 內設的主題 http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
%% AnnArbor, Antibes, Bergen, Berkeley, Berlin,
%% Boadilla, CambridgeUS, Copenhagen, Darmstadt, Dresden, Frank-
%% furt, Goettingen, Hannover, Ilmenau, JuanLesPins, Luebeck,
%% Madrid, Malmoe, Marburg, Montpellier, PaloAlto, Pittsburgh,
%% Rochester, Singapore, Szeged, Warsaw, boxes
% 較 OK 的:
%Rochester, Copenhagen, Frankfurt, Copenhagen, Luebeck, Warsaw, Boadilla
%\usetheme{Madrid}
\usetheme[height=0mm]{Rochester}%這邊設定投影片標題高度,0 是因為下方設定
%\usetheme{Boadilla}
%===============================================================
%% Color Theme設定投影片顏色
% http://en.wikibooks.org/wiki/LaTeX/Presentations
% 內設顏色: red, magenta, green, blue, cyan, yellow, black, darkgray, gray, lightgray, orange, violet, purple, brown, SeaGreen
\usecolortheme[named=SeaGreen]{structure}

% 內設主題顏色:default, albatross, beaver, beetle, crane, dolphin, dove, fly, lily, orchid, rose, seagull, seahorse, whale, wolverine
%\usecolortheme{beaver}

%============================================================
% 設定投影標題樣式
% 感覺不太出來
%\setbeamertemplate{blocks}[rounded][shadow=true]

% 設定列表樣式
% 可以選擇:ball, circle, rectangle, default
\setbeamertemplate{items}[ball]

% 設定圖片標號
\setbeamertemplate{caption}[numbered]
%============================================================
%隱藏 beamer 底部小工具列
\setbeamertemplate{navigation symbols}{}

%============================================================
% 自訂 footline
%\setbeamerfont{footline}{size=\fontsize{9}{11}  \selectfont}
%\setbeamerfont{footline}{size=\fontsize{5}{5} \D \selectfont}

%%% 自訂 Page Number
%\setbeamertemplate{footline}[frame number]

\setbeamercolor{footline_blue}{fg=blue}
\setbeamercolor{footline_black}{fg=black}
\setbeamerfont{footline}{series=\bfseries}
\addtobeamertemplate{navigation symbols}{}{%
        \usebeamerfont{footline}%
%       \usebeamercolor[fg]{footline}%
        \hspace{1em}%
        {
        \usebeamercolor[fg]{footline_blue}\insertframenumber
        \usebeamercolor[fg]{footline_black}/\inserttotalframenumber
        }
}

%======================================================================
%% Reference Table 參考文獻建表 
% https://www.sharelatex.com/learn/Bibliography_management_in_LaTeX#The_bibliography_file
% http://tex.stackexchange.com/questions/3587/how-can-i-use-bibtex-to-cite-a-web-page
% http://tex.stackexchange.com/questions/68080/beamer-bibliography-icon
% https://zh.wikipedia.org/wiki/BibTeX

\begin{filecontents}{\jobname.bib}
@book{b1,
    title={USB 2.0 系統開發實例精解},
    author={廖濟林},
    isbn={9789861990040},
    year={2007},
    publisher={城邦文化事業股份有限公司},
    keywords = {USB}
}
@misc{WinNT,
  title = {{MS Windows NT} Kernel Description},
  howpublished = {\url{http://web.archive.org/web/20080207010024/http://www.808multimedia.com/winnt/kernel.htm}},
  note = {Accessed: 2010-09-30}
}

@misc{mcp2200,
        title={MCP2200},
        howpublished={\url{http://www.microchip.com/wwwproducts/devices.aspx?dDocName=en546923}},
        note={Accessed:2015-06-06}
}

\end{filecontents}
%======================================================================
%% Reference Setting 參考文獻環境設定
%% http://tex.stackexchange.com/questions/147279/references-at-the-end-of-beamer-slides
%% https://www.economics.utoronto.ca/osborne/latex/BIBTEX.HTM
%% http://tex.stackexchange.com/questions/147279/references-at-the-end-of-beamer-slides

\usepackage{cite}
\usepackage{natbib}

%\usepackage{natbib}
%\usepackage{bibentry}
%\usepackage{chngcntr}
%\bibliographystyle{apalike}
%
%\setbeamercolor*{bibliography entry title}{fg=black}
%\setbeamercolor*{bibliography entry author}{fg=black}
%\setbeamercolor*{bibliography entry location}{fg=black}
%\setbeamercolor*{bibliography entry note}{fg=black}
%\setbeamertemplate{bibliography item}{}
%%\setbeamertemplate{bibliography item}{\insertbiblabel}
%\setbeamertemplate{frametitle continuation}[from second]
%
%\counterwithin*{footnote}{page}
%\newcommand\fcite[1]{\footnote{\tiny \bibentry{#1}}\label{\thepage:#1}}
%\newcommand\scite[1]{\textsuperscript{\ref{\thepage:#1}}}
%
%\nobibliography{\jobname}
%=======================================================================
\begin{document}
%======================================================================%% 標題設定 Title Setting
% 重設 frametitle 的預設為置中,上方的 usetheme 要改為 [height=0]
\setbeamertemplate{frametitle}[default][center]

% 自定義 title 格式
%\usepackage{titlesec}
%\titleformat{\section}{\Large\xbsong}{\thesection}{1em}{}

%%% Title Setting 1 自訂亂設法
% 指令 \datedate 可以設定為 \date 加減幾天
%\setdatetoday
%\addtocounter{datenumber}{-7}
%\setdatebynumber{\thedatenumber}
%\date{\large 2015/03/26}

%\begin{frame}
%       \begin{titlepage}
%               \begin{center}
%               {\Huge 每週進度報告}\\% 標題內容
%               \vspace{.5cm}% 空 0.5cm 垂直空間
%               \rule{\textwidth}{3pt}\\% 粗分隔線
%               \vspace{.5cm}% 空 0.5cm 垂直空間
%               {\LARGE 指導教授:李博明\\
%               MA330101 廖凱霖}
%               \end{center}
%       \end{titlepage}
%\end{frame}
%----------------------------------------------------------------------------
%%% Title Setting 2 正規設法
%% http://tex.stackexchange.com/questions/26848/beamer-font-size-for-footer

%\title[footline title]{\Huge Real Title}
\title[每週進度報告]{\huge 每週進度報告}
%\title[每週進度報告]{\fontsize{20}{25} \selectfont 每週進度報告}

\author{MA330101 廖凱霖}
%\author{ MA330101 廖凱霖}
%\author{{\large 指導教授:李博明\\
%        {\D MA330101} 廖凱霖}}

%\institute{機構}

%\date{\D \number\year/\number\month/\number\day}% 自排格式
\date{2015/06/11}
%======================================================================
%% 投影片開始 Frame Start
% 印出標題
\begin{frame}[fragile]
        \titlepage
\end{frame}

% Outline
\begin{frame}[fragile]
        \frametitle{Outline}
        \tableofcontents        % 插入目錄
\end{frame}

% TEST Test test page
\section{Test Page}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\begin{frame}
        \frametitle{Test Page}
        \begin{itemize}[<+->]
                \item \textbf{正規粗體法 English 0oO}
                \item \textit{測試斜體字 the word 0Oo}
                \item Is it socially\nocite{WinNT} stratified?\cite{b1}
                \item Sauss\cite{mcp2200} said some stuff
        \end{itemize}
\end{frame}

% Road map
\section{Road map}
\begin{frame}[fragile]
        \frametitle{Outline}
        \tableofcontents[currentsection]        %% 插入所在目錄
\end{frame}
\begin{frame}[fragile]
        \frametitle{行程規劃 (Road Map)}
        \begin{itemize}
                \item date word
        \end{itemize}
\end{frame}

% Last Week Issue
\section{Last Week Issue}
\begin{frame}[fragile]
        \frametitle{Outline}
        \tableofcontents[currentsection]        %% 插入所在目錄
\end{frame}
\begin{frame}[fragile]
        \frametitle{上週 lastweek 遭遇問題及後續}
\end{frame}
% This week progress rate
\section{Progress Rate}
\begin{frame}[fragile]
        \frametitle{Outline}
        \tableofcontents[currentsection]        %% 插入所在目錄
\end{frame}
\begin{frame}[fragile]
        \frametitle{本週 thisweek 進度}
        \begin{itemize}
                \item first
                \item second
                \item three
        \end{itemize}
\end{frame}

% This week issue
\section{This Week Issue}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\begin{frame}[fragile]
        \frametitle{本週所遭遇問題及可能解法}
        \begin{block}{問題:這邊輸入問題}
                可能的解法:這邊輸入可能的解法...
        \end{block}
\end{frame}

% Next week progress plan
\section{Next Week Plane}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\begin{frame}[fragile]
        \frametitle{下週 {Nextweek} 預計進度}
\end{frame}

%% 範例10: 參考文獻
\section{Reference}
\frame{\frametitle{Outline}\tableofcontents[currentsection]}
\frame{ \frametitle{Reference}
        \tiny{\bibliographystyle{abbrv} }       % 文獻標號
        \bibliography{\jobname} }               % 文獻來源
%======================================================================
%% 範本 1
%\begin{frame}
%       \frametitle{投影片標題}
%       \begin{block}{小重點}
%               試試 block 的使用方式
%       \end{block}
%       \begin{alertblock}{大重點}
%       特別重要的東西
%       \end{alertblock}
%       \alert{這一點重要}\\
%       \alert<2>{第二張才重要}\\
%       \color<4>{green}{第四張時是綠色}\\
%       \color<6>{brown}{第四張時是棕色}\\
%\end{frame}

%% 範本2: 插入圖片,pdf, .png, 或 .jpg
%\begin{frame}
%       \begin{figure}
%       \centering
%       \includegraphics[scale=.5]{foo.png}
%       %\includegraphics[width=0.5\textwidth]{foo.png}
%       \end{figure}
%\end{frame}

%% 範本3: 條列式
%\begin{frame}
%       我們先說明...
%%% itemize, enumerate, description
%       \begin{itemize}% 指定頁顯示
%               \item<1-> 第一項
%               \item<2-> 第二項
%               \item<6-> 第三項
%       \end{itemize}
%       \begin{itemize}[<+->]% 逐頁顯示
%               \item 第一項
%               \item 第二項
%               \item 第三項
%       \end{itemize}
%       % 暫時跳脫去下面說明
%       \pause
%       然後可以發現...
%       \pause
%       % 指定該 frame 後第幾個投影片出現
%       我們知道「\only<6->{第二張以後才會出現}」°\\
%       我們知道「\uncover<6->{第二張以後才會出現}」°
%       % 直接跳到投影片 here label 位置
%       \hyperlink{here}{\beamerbutton{去這篇投影片}}
%\end{frame}
%
%% 範本4: 投影片標籤 here
%\begin{frame}[label=here]
%       過來這裡
%\end{frame}

%% 範本5: 原文照例 \verb 用法
%\begin{frame}
%\begin{frame}[fragile]% 重點要記得加入 fragile
%\begin{verbatim}
%       輸入原文
%\end{verbatim}
%\end{frame}

%% 範本6: Web Link
%\href{http://tex.stackexchange.com/q/20800/5701}{\beamergotobutton{Link}}

%% 範本7: Table
% http://www.tablesgenerator.com/
% https://www.sharelatex.com/learn/Tables

%% 範例8: outline, current section
%\section{第一點}
%\frame{\frametitle{Outline}\tableofcontents[currentsection]}

%% 範例9: Coding
%% https://www.sharelatex.com/learn/Code_listing#Supported_languages
%% language support: bash, Java, C++, PHP, Python, Latex, HTML... 
%\begin{frame}[fragile]
%       \lstset{language=C++, keywordstyle=\color{blue}, stringstyle=\color{red}, commentstyle=\color{green}, morecomment=[l][\color{magenta}]{\#}}
%       \begin{lstlisting}
%       void make_set(int X) {
%               parent[X] = X;
%       }
%       \end{lstlisting}
%\end{frame}

%%% 範例10: 參考文獻
%\section{Reference}
%\frame{\frametitle{Outline}\tableofcontents[currentsection]}
%\frame{ \frametitle{Reference}
%        \tiny{\bibliographystyle{abbrv} }       % 文獻標號
%        \bibliography{\jobname} }               % 文獻來源

%%% 範例11: 表格 Table
% http://www.tablesgenerator.com/latex_tables#
% \captionof{table}{USB 分析儀市場調查表}
% \begin{table}[h]
% \begin{tabular}{|l|r|}
% ...
% \end{tabular}
% \end{table}

\end{document}

LaTeX 環境建置



一、安裝
sudo apt-get install texlive-full latex-cjk-all

二、設定字型

1. 查看目前系統字型支援
fc-list

2. 字型檔路徑
/home/$USER/.fonts

我的字型檔(不要公開):https://drive.google.com/file/d/0BxEiZ5gd9umbeDgwWWJydk9pWE0/view?usp=sharing

3. 其他免費字體:
sudo apt-get install xfonts-wqy ttf-wqy-microhei ttf-wqy-zenhei


2015年6月6日 星期六

Wicd 網路管理程式(適用 Wireless)

一、 安裝
su
apt-get update
apt-get install wicd

二、 執行
wicd-client

三、 操作

 1. 開啟 WiFi,並搜尋可連線網路。

2. 若 WiFi 需要密碼,則選「特性」。

3. 設定密碼 ( 下次使用會記憶起來)

4. 點選「連線」,正常來講即可連上 WiFi

5. 使用完畢,可以直接「斷線」或「關閉 WiFi」。



Teamviewer 遠端連線程式

Teamviewer 遠端連線程式,可免去 VPN 直接控制,
Windows - Linux 都可以互相連線。
於 Debian Jessie 使用 Teamviewer 只能裝 i386 本版!


1. 下載
teamviewer_10.0.41499_i386.deb

2. 更新 ATP i386 套件庫
sudo dpkg --add-architecture i386
sudo apt-get update

3. 安裝
dpkg -i teamviewer_10.0.41499_i386.deb
apt-get -f install -y
dpkg -i teamviewer_10.0.41499_i386.deb

4. 執行 (一般使用者)
teamviewer

5. 下次開機不要啟動
因為 teamviewerd.service 開著的話,關機會很慢,
故設定下次開機不自動啟動,需要使用在開!

關閉:
sudo systemctl disable teamviewerd
sudo systemctl stop teamviewerd
sudo systemctl status teamviewerd

下次開機要使用:
sudo systemctl start teamviewerd
teamviewer






Reference:
http://steronius.blogspot.tw/2014/08/install-teamviewer-9-in-64bit-debain.html