2010年11月18日 星期四

qextserialport的用法(Linux)

1. 至sourceforge下載 source code (qextserialport-1.2win-alpha.zip),並解壓縮。

2. 將
  • posix_qextserialport.h
  • posix_qextserialport.cpp
  • qextserialbase.h
  • qextserialbase.cpp

四個檔案加入專案中。

3. 在專案主程式標頭檔中加入 #include posix_qextserialport.h

4. 之後即可在主程式中使用qextserialport函式。

EX:

1. 在主程式標頭檔中的 private: 中加入宣告

  • Posix_QextSerialPort *myCom;

2. 在主程式中加入Serial Port控制設定:
  • myCom = new Posix_QextSerialPort(SerialPort, QextSerialBase::Polling);
  • myCom -> open(QIODevice::ReadWrite);
  • myCom -> setBaudRate(BAUD9600);
  • myCom -> setDataBits(DATA_8);
  • myCom -> setParity(PAR_NONE);
  • myCom -> setStopBits(STOP_1);
  • myCom -> setFlowControl(FLOW_OFF);
  • myCom -> setTimeout(10);

3. 宣告 QByteArray message = myCom -> readAll().toHex(); 讀進來之數據會存於message變數中,可依需求作處理。

※Linux只能使用Polling的方式。

※SerialPort為/dev/中Serial Port的device file name

※以Linux為例:

  • pl2303 USB轉RS232之device file name為ttyUSB0、ttyUSB1、ttyUSB2.....
  • bluetooth spp之device file name為rfcomm0、rfcomm1、rfcomm2.....

※timeout要設短一點,如:myCom->setTimeout(10);

在windows 7下手動安裝qt 4.7.1

為了使用 static compile,所以 Qt 使用 MinGW 自行 make,Qt Creator IDE 則使用官網下載的 windows binary 安裝,再設定好 qmake 的位置即可。

1. 下載各個所需的檔案:

  • mingw-get-inst-20101030.exe
  • qt-everywhere-opensource-src-4.7.1.tar.gz
  • qt-creator-win-opensource-2.0.1.exe

2. 先安裝好 MinGW 與 Qt Creator IDE。

3. 在 windows 的環境變數中加入使用者變數 PATH,值為:C:\MinGW\bin;C:\MinGW\include;C:\MinGW\lib;D:\Qt\4.7.1\bin (請依自己系統環境設定)

4. 將 qt-everywhere-opensource-src-4.7.1.tar.gz 解壓縮到欲安裝的位置 (本例為 D:\Qt\4.7.1\bin ),並進入此資料夾。

5. 下指令 configure -debug-and-release -opensource -static -platform win32-g++ (參數請依需自行加入、設定)

6. configure 完成後下指令 mingw32-make。

7. make 完成後打開 Qt Creator,在 Tools → Options → Qt4 → Qt Versions 中加入自行 make 的 qmake位置路徑,完成後即可使用。

2010年9月28日 星期二

在Ubuntu安裝Qt前請先安裝下面幾個開發工具包

在Ubuntu安裝Qt前請先安裝下面幾個開發工具包
  • libX11-dev
  • libXext-dev
  • libXtst-dev
  • libqglviewer-dev
  • libmysql++-dev
  • g++

2010年8月3日 星期二

cat /dev/rfcomm0 | od -c

hexdump /dev/rfcomm0

可用來讀取 rfcomm0 的數據 (16進位碼)


2010年4月14日 星期三

刪除GRUB選單裡舊kernel選項

隨著Ubuntu的kernel更新,GRUB選單的選項會越來越多
我們可以刪除GRUB選單裡舊kernel選項:

1. 使用synaptic移除
  • linux-headers-x.x.xx-xx
  • linux-headers-x.x.xx-xx-generic
  • linux-image-x.x.xx-xx-generic
2. sudo update-grub2

2010年4月13日 星期二

ubuntu ssh server簡易安裝

1. 在synaptic中找尋,並安裝ssh套件
2. 修改 /etc/ssh/ssh_config
3. 將 # port 22 中的# 去掉,並修改要使用的port number
4. 如有修改port number,需將 /etc/sshsshd_config 之port number也改掉
5. reboot

2010年1月28日 星期四

Qt 4.7.2 手動安裝

0. 如是新安裝,請先裝 libX11-dev、libXext-dev、libXtst-dev、libqglviewer-dev、libmysql++-dev、g++開發工具包。

1. 至NOKIA FTP 下載 qt-everywhere-opensource-src-4.7.2.tar.gz

2. 解壓縮,並進入解壓縮後的資料夾

3. ./configure -static -debug-and-release -qt-sql-mysql -qt-libpng -qt-libjpeg -qt-gif -opengl -prefix /opt/qt-4.7.2-static

4. make

5. sudo make install


順便安裝qtcreator 2.1.0

1. 下載 qt-creator-linux-x86-opensource-2.1.0.bin

2. sudo chmod u+x qt-creator-linux-x86-opensource-2.1.0.bin

3. sudo ./qt-creator-linux-x86-opensource-2.1.0.bin

4. 安裝完成後,在qt versions裡的qmake location新增設定Qt 4.7.2的位置,並Rebuild Debugging Helper。

5. 如果之前有project,記得調整projects中的build configuration及qt versions參數。