beaglebone black debian wheezy usb net configuration and ssh login on windows and Linux


follow the tutorial and make usbnet boot automatically

on my BBB debian wheezy:

sudo cat  /etc/modprobe.d/usbnet.conf

#auto load usbnet
options g_multi file=/usbnet.img stall=0
#there is a usbnet.img already there under /

Continue reading

Posted in Uncategorized | Comments Off

batch post-Process Ansys Fluent CFD Case And Plot In Python using Matplotlib or Tecplot


1. parse the ansys fluent profile text file into python list of dict;  draw velocity profiles by matplatlib (“see source code of”)

2. generate tecplot batch and macro file to draw contours automatically in batch mode.  (see “”)

download the source file here,


I hope it can inspire you, but it will not serve you directly.

Edit some variables at the beginning of source code should make it work for you.

you need to record your own tecplot macro to style the plot.




Qingfeng Xia  2013

“CFD study of synthetic jet at low Reynolds numbers”

University of Manchester


Posted in Programming, Research | Comments Off

solutions for python pip install gcc compilation error: -mno-cygwin


(1)install unofficial python extension package  binary installer

Unofficial Windows Binaries for Python Extension Packages

by Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine.


MinGWmay be not compatible with python pip compiler:   -mno-cygwin
remove the official mingw from path. or install mingw built for python

Windows GCC (MinGW) binaries for Python developers  gcc4.3


(3) Remove the  -mno-cygwin  option

-mno-cygwin in Python\Lib\distutils\ causes this problem: see Compiling with cython and mingw produces gcc: error: unrecognized command line option ‘-mno-cygwin’ or

My Python distribution (Anaconda)’s does not have that though. Anyway, after removing all -mno-cygwin in the definition of the Mingw32CCompiler class you should be able to compile.

Posted in Uncategorized | Comments Off

Recommend RT-Thread RTOS to Linux programmers

In a nutshell, Linux programmers will love RT-Thread API.
  1. Thread in RT-Thread works like  POSIX thread:  #include <posix_types.h>
  2. Each thread has TCB (task control block),  like Linux kernel thread, share the global memory, but has its own stack (pre-decleared array with fixed size), has event and timer for each thread;  Thescheduler, which uses bitmap algorithm,  is similar with Linux kernel
  3. RT-Thread is high performance RTOS, mainly focusing on ARM cortex-M 32bit CPU.
  4. RTGUI/FTK   (object-oriented style widget,  just like GTK+)
  5. Device model like Linux device tree.
  6. IPv4 and IPv6 are supported by lwIP lib with <socket.h>, but 6LowPAN is not supported as Contiki.
  7. Simulator on Linux and Windows (32bit  x86 only) and good documentation.
  8. Python scons building system; but it is easier than Makefile to control multiple targets building.

Most important, it is free even  for commercial usage, via applying free license and keep RT-thread banner.

Finally, this is the host place:

Posted in Uncategorized | Comments Off

Software SPI library for Arduino tested on Mega2560

Since there is only one hardware SPI, but it is used by Ethernet or Wifi shield. If you wantto conenct some other sensors via SPI, the Ethernet lib is reluctant to cooperate.

So a software bit-banging library may be necessary.

Four SPI modes are supported, just change the macro definition in header file.

Continue reading

Posted in Uncategorized | Comments Off

[notes]Arduino IDE can NOT include libraries within project subfolders

The IDE requires every file to be in the same directory as the main program!

Continue reading

Posted in Uncategorized | Comments Off

Setup Codelite to work with visual studio toolset

I am tired to upload figures , I just give it as PDF file with figures inside

Setup Codelite to work with visual studio toolset (totorial version)

Posted in Uncategorized | Comments Off

python pinyin module support simplified and traditional chinese codecs

git clone

Pinyin python module

Origin:      Author:cleverdeng (not reachable)

forked by Qingfeng Xia based on v0.9:  
               (1)renamed class name from PinYin to Pinyin, 
               (2)dict file ""  is  renamed  as "" 
               (3) add encoding support, or it will not work for windows cmd prompt! 
               (4) move load_word() (renamed as loaddict() ) into __init__(), to make API concise
               (5)  "ord(UNICODE)= list of pinyin", for quick loading and human readable check
                  why some unicode has multiple pinyin units??? 

               copy the two files:, , into your project folder, or under $PYTHONPATH , or your sitepackages

test:   testing code is under __main__ section
               python -m

 Continue reading 
Posted in Download, Programming | Comments Off

Comparsion of DateTime classes in popular programming Languages (2)

as a further explanation to:

” Comparsion of DateTime classes in popular programming Languages (1)”

This part is a copy and paste of lang/lib spec.

Continue reading

Posted in Programming | Comments Off

Comparsion of DateTime classes in popular programming Languages (1)

C    boost::Datetime  Java JDK8(javax.time)  Qt Python and Javascript

(1) Table comparison

(2) Further explanation from each language spec

Joda package for (Java) is not described here, whose API is analoguous to Qt and Python. As there is new API of LocalDateTime,  it is the equivalent to QDatetime, and python’s datetime.

Table: Comparsion of DateTime classes in popular programming Languages

Author: Qingfeng Xia  2013    Versioin 0.1   

see attached word doc

Table Comparison of DateTime classes in popular programming Languages

Continue reading

Posted in Programming | Comments Off

You must know C++11, but have you noticed C11?

Previous C++ standard is C++03 (2003); previous C std is C99.They are not released together, but they did this time as  a combo of C11 and C++11.

__STDC_VERSION__ == 201112L

C11 (formerly C1X) is an informal name for ISO/IEC 9899:2011  (see wiki)

Continue reading

Posted in Programming | Comments Off

Four wheel car robot based on Arduino Mega2560 and Raspberry Pi

git clone

Datasheets (most of them in Chinedse) for robot parts makes the git size big


Recently, I have been working on Arduino 2/4 wheel car robot in my spare time.

===============design goals==================

Robot car composing 4 DCMotors, Senors, ServoArm, BlueTooth remote control

Phase 1:
(1)   two/four wheel driving car steering,
There is no designated positive or negative pole for DC motor,  swapping pin1 and pin2 can made motor rotate reversely

Phase 2:
(2) sensors:  using  PID for sensor fusion ,
a)  altrasound range sensors included
b)  acceleration or angle speed
c) Infrared receiver
(3) Control by Infrared remote or PC control via bluetooth

Phase 3:
(4)  usb Camera supervision using Raspberry Pi usb wifi
(5) voice command recogniation by raspberry Pi connected to internet

Continue reading

Posted in Programming, Robot | Comments Off

Melexis90620 IR sensor controlled by Arduino and Raspberry Pi

I have made a C++ library class for Melexis90620 (in order to use multiple sensors simultanuously ),  a test program to demo this class, python program to show the contour.

Also, I made I2C C program to control itby Raspberry PI, but raspberry Pi can not read from RAM (reading EEPROM is fine).

A new plan under evaluation is to use 4 Melexis90620 togother to make 16X16 pixel IR camera. The only obstacle is to change the I2C slave address. I saw some guy has change the address of Melexis90614.  I dump EEPROM of reserved addr,  I found some byte should be addr, but I dont know how to write EEPROM. (command sequence)

Continue reading

Posted in Download, Programming, Robot, Sensor | Comments Off

my robotics lab is ready to go


Posted in Robot | Comments Off

QtCore vs C++ STL & boost lib (4) smart pointers

see “Count with me: how many smart pointer classes does Qt have?”

Smart pointers  Introduction Ver
QPointer<T> Qt Object , guarded pointer,
set NULL after delete/deconstruction
However, pointed resource not released
QSharedPointer reference-counted strong sharing of pointers Qt4.5
QWeakPointer reference-counted weak sharing of pointers Qt4.5
QScopedPointer Qt4.6
QScopedArrayPointer QScopedPointer drived Qt4.6
QSharedDataPointer Qt (Implicit Sharing) copy-on-write Qt4.0
QExplicitlySharedDataPointer ExplicitlyShared Qt4.4

C++11 <smart_pointer>

Introduction to smart pointers:

std::auto_ptr  Not recommended in C++11  C++03
std::shared_ptr Reference counting C++11
std::weak_ptr Intended for Garbage collection C++11
std::unique_ptr non-copyable, but can be transfered C++11
boost::scoped_ptr<T> Equal to QScopedPointer

neither copyable nor movable.

Continue reading

Posted in Programming | Comments Off

QtCore vs C++ STL & boost lib (3) Threading

Threading is always tricky, I dare not comment on this topics.

If some useful articles are found, this page will be updated!


Posted in Programming | Comments Off

QtCore vs C++ STL & boost lib (2) Container


just read the article: < Understand the Qt containers >

key points

(1) difference:

a)Qt Containers:  implicitly shared (Copy-On-Write) !

b) size type: QT return signed int, while STL return size_t (unsigned int)

c) Iterator

(2)Qt has C++ STL style API, stick to these API style(3) Usage QVector  instead of QList as much as possible


Qt containers and their STL counterparts

The following table summarises the main sequential and associative Qt containers and their STL counterparts. For the most part, we will ignore the string classes, even though technically, they are also containers.

Sequential Containers
QVector std::vector
QLinkedList std::list
Associative Containers
QMap std::map
QMultiMap std::multimap
QHash std::unordered_map
QMultiHash std::unordered_multimap
QSet std::unordered_set
Posted in Programming | Comments Off

QtCore vs C++ STL & boost lib (1) IO

QFile is the class for  everyday File IO, while C++ STL using  stream

===========based class: std::stream =========
<iostream> (qDebug()  or #include <iostream> cin/cout )
<fstream>  (QFile)
<sstream> (QBuffer)
<boost/archive> ( QDataStream for serialization )

The QIODevice class is the base interface class of all I/O devices in Qt.

#include <QIODevice>

Inherits: QObject.

Inherited by: Q3Socket, Q3SocketDevice,
QAbstractSocket, QBuffer, QFile, QLocalSocket, QNetworkReply,
and QProcess  ( just like bash shell pipe input and output, Python).


Continue reading

Posted in Programming | Comments Off

QtCore vs C++ STL & boost lib: overview

QtCore vs C++ STL & boost lib

Author: Qingfeng Xia
Date: March 05 2013

since most of the content is from documentation or forum threads, it can be regards as same license as QT documentation.  Most of text are copied from internet, reference to original link, I just organized them into sub topics: I did not spend much to retouch the text and grammer, so it will not suitable to be copied into your report or thesis (joking!).


QtCore has cover a wide range of  C standard lib/C++ standard lib,  but you still can use the standard C/C++ lib.   For example, threading is newly added into C++11, but is already in QtCore: QRunnable QMutex  QThread (not in QtConcurrent, usage is more or less like python and Java). <qglobal>  includes a lot of Macros  (e.g.  qint64, no need for <stdint.h>  ) , Q_ASSERT for C++11 static_assert.  Even, there are
<qmath qnumeric  qlocale qendian>.

This article focuses on Qt5 only, as it is mentioned C++11 is prerequisit for QT5 see:
It is not clear, that lambda will be allows in QT slot?

C++11 is still lacking the type system information, boost seems improve it on this topics.  The metadata of QObject is the basis of QT lib.  Reading and understanding QObject and all classes in QtCore before go through this series.  For example,  QFlag is more powerful than enuml it supports bit “and or xor” operation.  see “KDAB contributions to Qt 5.0 (part 1 – 4)”

On the other hand,  there are some merits in C++11 that are abscent in QtCore. C++ <algorithm> is a good companian to STL containters, while QtAlgorithm is available for Qt 4.8 (in Qt5.0 it is recommended to use STL algorithm).  C++ has <function> (function as a class and lambda) and <functional>, but C++ function can not be used as slot of QT!!! (

Personallly, I recommended to use QtCore utility as much as possible, e.g. using QFile instead of STL stream <fstream> for style compatible, and QString for itis power.

(1) IO
(2) STL container (important!  QVector is recommended over QList)
(3) Threading ()
(4) smart pointers (table comparison)
(5) slot and signal ( C++11 in QT5)
(6) boost filesystem and QDir QFile programming notes
(7) serialization boost vs Qt
(8) Boost.Variant vs. Boost.Any  QVariant

Posted in Uncategorized | Comments Off

Solution to SPI and I2C LCD unmeaningful character display

Arduino IDE has its standard “LiquidCrystall” library, but  MCP23008 1602 LCD needed a customed library. Simply installation may lead to unexpected result

Arduino ide 1.5 , Arduino mega 2560, scl(clk 21) sda(20 DAT)  connection is fine,

but  example “HelloWorld_i2c”, compiled sucessfully, but it does not give correct character display, instead,  “//??-> **”, unmeaningful characters are shown on LCD.


test on Arduino 1.0.3, this example links to “LiquidCrystal.h” of standard library, Leading to compiling error.  Corrected included header should be the “LiquidCrystal.h” in the customed liquidcrystall lib.

simple and dirty solution:

After install axxxxliquidcrystall , delete the standard liquidcrystall lib.
Then the example will link to correct header.

tested for IDE 1.0.3 and 1.5

Posted in Robot | Comments Off