compile c++ codes using Visual C++ Build Tools from the command prompt

Introducing the Visual Studio Build Tools

“If you have installed Microsoft Visual C++ Build Tools 2015 on Windows 10, open the Start menu and choose All apps. Scroll down and open the Visual C++ Build Tools folder. Choose Visual C++ 2015 x86 Native Tools Command Prompt to open the command prompt window.”

1) for single file source file

cl -> gcc , but the command options is different,

cl /EHsc hello.cpp

https://msdn.microsoft.com/en-us/library/f35ctcxw.aspx

2) for a small project, CMake is recommended,

it is handy to write one from example CMakeLists.txt online.

In your source code folder: md build && cd build && cmake ..

then using nmake instead of make

3) for exsitent vs solution using msbuild:

compile visual studio solution/project designed by VS IDE, no corresponding command on Linux.

search “MSBuild Command-Line Reference”

In the near future, other light weight IDE might support detecting “Visual Studio Build Tools”, e.g QtCreator

Posted in Programming | Leave a comment

Mibox 2 install youtube and play to kodi (just as chromecast)

1. install shafa TV manager and/or ES file explorer to be enable install apk from USB/SD card
http://www.shafa.com/articles/yWNpNK6erhB6Q4dO.html

2. install Kodi/XMBC apk from shafa’s file manager (in toolbox) on USB storage

3. install apk of youtube for Google TV, and also enable USB keyboard in MiBox system setting -> Input.

3. enable DNLA, web http control, UPnP in kodi settings
http://kodi.wiki/view/web_interface
write down the IP (check on your router), port, user name and password on this setting page

For web http control, install the new “Chorus” theme addon

4. install “play to Kodi” Chrome extension, Firefox should be possible
then, right click to video link, kodi->play/queue
first of all, setup kodi extension to login to kodi web interface

5. disable screen saver, for Kodi

Posted in Uncategorized | Leave a comment

Evaluation of OpenFOAM on bash on Ubuntu on windows 10

## installation

After Anniversary Build (2016 Aug) for x65 windows 10, it is possible to evaluate this beta feature in developer mode without upgrade to claimed unstable insider version.

see detailed tutorial:

To install ubuntu on windows 10 from power shell prompt:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

## overview
In addition to apt-get, some other tool are there like python2, and python3, gcc4.9, perl5. dbus, systemd
Xwindows has been explored by geeks, but it is not stable/usable to run GUI app.

After fireup bash, the current path is /mnt/c/Windwos/System32 . It is better to “cd /mnt/c//Documents/” at the end of .bashrc, not mess up system folder and for better locate file generated by bash commands.

## look around

dpkg -l to see installed package, while not sure snap pkg will be supported.
sudo apt-get update To update the repo, it will show trusty repo info
ls /dev/
ls /usr/include/, almost empty
lsb_release -a shows it is 14.04.4
uname -a
> Linux DESKTOP-DELL15 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux

## test POSIX API

It may be used to easily run software previously POSIX only program on windows.
apt-get install gcc will install gcc 4.8 and *linux-libc-dev*

ls /usr/include/ will give unistd.h

## install OpenFOAM

see instruction:

two versions are available for ubuntu 14.04
openfoam30
openfoam4

OpenMPI may not work; ParaView is definetly not working.

apt-get install openfoam30, then apt-get remove openfoam30 (leave dependent pkg remained.)
install openfoam4 by force, will not install all paraview related tons of new packages.

apt-get download openfoam4
dpkg --force-all -i openfoam4

force remove this pkg can fix error message each time

## Run OpenFOAM solver


mkdir -p $FOAM_RUN
cp -r $FOAM_TUTORIALS $FOAM_RUN
cd $FOAM_RUN/tutorials

bash
/OpenFOAM/qingfeng-4.0/incompressible/simpleFoam/windAroundBuildings$ ./Allrun
Running surfaceFeatureExtract on /home/qingfeng/OpenFOAM/qingfeng-4.0/incompressible/simpleFoam/windAroundBuildings
Running blockMesh on /home/qingfeng/OpenFOAM/qingfeng-4.0/incompressible/simpleFoam/windAroundBuildings
Running snappyHexMesh on /home/qingfeng/OpenFOAM/qingfeng-4.0/incompressible/simpleFoam/windAroundBuildings
Running simpleFoam on /home/qingfeng/OpenFOAM/qingfeng-4.0/incompressible/simpleFoam/windAroundBuildings

## Feature wanted

– right click to open bash, just as cmd prompt, or git-bash

## upgrade to ubuntu 16.04
upgrade to ubuntu 16.04 is planned by official support


apt-get update
apt-get dist-upgrade
do-release-upgrade -f DistUpgradeViewNonInteractive -d

lxrun.exe is used to manage WSL. This command can be used to install or uninstall the Ubuntu image.

Posted in Uncategorized | Comments Off on Evaluation of OpenFOAM on bash on Ubuntu on windows 10

disable windows input method hotkey

UPDATE: it seems the following methods still fails, as restart pc or windows update will invalidated the setting

===========

Avoid the annoying hotkey to trigger the IME shape/punctation in Chinese for half/full
see tutorial: http://superuser.com/questions/327479/ctrl-space-always-toggles-chinese-ime-windows-7
In addition to disapble Ctrl-Space, IME shape/punctation hotkeys are also disabled, which are shift-space and ctrl-period respectively. Once your edit the hotkey in GUI, which you will fail, you may need to rerun this reg file again. Logout to make it take effect

copy the following into notepad and save as “diasableIMEHotkey.reg” to anywhere in your PC. right click “merge” will import them into registry.

[HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000010] for simplified Chinese,  for traditional Chiese, use : [HKEY_CURRENT_USER\Control Panel\Input Method\Hot Keys\00000070]

Once your edit the hotkey in GUI, which you will fail, you may need to rerun this reg file again. Logout to make it take effect

Continue reading

Posted in Uncategorized | Comments Off on disable windows input method hotkey

Toshiba L650 laptop disassembling

QQ图片20160529094125
I got a 5 year old laptop, it does not boot, no screen show, no beeping. So I need to disassemble and check.
Generally, this laptop is easy to repalce harddisk or memory on the back.  And the dissabling is straight forwards.

Continue reading

Posted in Uncategorized | Comments Off on Toshiba L650 laptop disassembling

Introduction to Industrial IO (sensor framework for Linux)

introduciton to Industrial IO


  • overview of industrial IO. In short, SPI and I2C sensor framework for Linux
  • sensor categories: “ADC, DAC, light, accel(erometer), gyro, magnetometer, humidity, temperature, amplifier, frequency, orientation, health”, etc
  • merged to mainline kernel 3.14, used by beagleBone, sysfs and char device based, see the IIO architecture

related projects/libs


  • DAQmx base for linux: commercial lib from national instrument
  • comedi: PCI/PCIe, USB devices for data acquisition
  • hwmon: very low speed,traditionally for CPU temperature monitoring
  • HID: like mouse, keyboard, generally low speed input device
  • bluetooth smart:

user space IIO API


user space library libiio (https://wiki.analog.com/resources/tools-software/linux-software/libiio)

  • #include <iio.h> four basic classes: iio_contex, iio_device, iio_channel and iio_buffer
  • iio_trigger is kind of iio_device without channel but with name inc “trigger”
  • iio_context has internal operation functions structure, kernel driver
  • windows user can use libiio to access network iiod
  • python and cshaprt wrapping for user space API: python-iio libiio-cil-dev
  • XML context: attributes calibration data, scale, etc.

detailed

(http://events.linuxfoundation.org/sites/events/files/slides/lceu15_baluta.pdf) + scan_element(), iio_channel_is_scan_element(): elements in buffer is called scan /sys/bus/iio/devices/iio:devices/scan elements

  • read_raw() from register (possible 12bit) to integer in memory. NO integer to physical quantity (with unit) like comedilib?

trigger readings based on an external interrupt source hardware interrupt (IRQ pins) software interrupts (periodic timers, sysfs triggers)

design of IIO


  • modes: DIRECT,BUFFER SOFTWARE,BUFFER HARDWARE,BUFFER TRIGGERED
  • iio_triggered_buffer iio_events only found in kernel mode iio_core, see(linux/iio/triggered_buffer.h);trigger are software trigger, not hardware TTL signal in DAQ terminology?

documentation for IIO


source code


supported hardware list


About 200 device drivers by the time of kernel 4.4; many drivers supports a varierty of models.

see/search kernel source tree linux/iio, there are a few subfolders corresponds to sensor categories: “ADC, DAC, light, accel(erometer), gyro, magnetometer, humidity, temperature, amplifier, frequency, orientation, health”, etc

test of IIO dummy device on ubuntu 16.04


“dummy” a virtual sensor for testing

python-iio example

desired feature of IIO


  1. user space tool to expose sensors to webUI?
  2. devicetree: platform device support is supported such as beaglebone.
  3. standardisation calibration data in XML attribute file to simulate: IEEE 1451.4 Plug and Play Sensors (TEDS)
  4. possiblity of user space driver development based on user space SPI, i2c and libusb?
  5. physical value conversion “The functions comedi_to_physical, comedi_to_phys, comedi_from_physical and comedi_from_phys are used to convert between Comedi’s integer data and floating point numbers corresponding to physical values (voltages, etc.). ”
Posted in Linux, Sensor | Comments Off on Introduction to Industrial IO (sensor framework for Linux)

A recommendation for free of charge 2D CAD and office system, also cross-platform

for office system, I recommend kingsoft  WPS office, which is based on Qt, much faster than java based solution. It has Android, Linux version in alpha, in addition to mature windows ‘s version

http://wps-community.org/download.html

For 2D CAD drawing, I recommend   Dassault system’ Draftsight,  it is  a professional level product. just need a email activation.  Linux version is still in beta.

http://www.3ds.com/products-services/draftsight-cad-software/free-download/

Both are not open source, but free of charge for production usage.

Posted in Linux | Comments Off on A recommendation for free of charge 2D CAD and office system, also cross-platform

Solve CFD via OpenFOAM in free CAx platform FreeCAD

Updated 2016-04-17

Boundary condition setup GUI has been done for preview

This is an early preview, only for people with experience of OpenFoam.
Test instruction could be found at
https://github.com/qingfengxia/FreeCAD/ … /Readme.md

I would love to see some feedback for stage III development, see roadmap:
https://github.com/qingfengxia/FreeCAD/ … roadmap.md

A video preview of OpenFoam plugin for FreeCAD Fem workbench
http://www.iesensor.com/FreeCADDoc/oepn … engXIA.mp4

The discussion of this module on FreeCAD community can be found here:

http://forum.freecadweb.org/viewtopic.php?f=18&t=13699

Continue reading

Posted in Linux, Programming, Research | Comments Off on Solve CFD via OpenFOAM in free CAx platform FreeCAD

Why power adapters for laptop are NOT compatible

see the word document contains figure to demonstrate various power adapters from diff manufacturers and how the claimed incompatible adapter could be reused.

why laptop power adapter are not compatible and howto

Posted in Uncategorized | Comments Off on Why power adapters for laptop are NOT compatible

Using paraview to visualise vorticity (Lambda2, vorticity, Q-Criterion)

Please download the word document, which contains the details on setting up the Python Calculator filter to calc lambda2, and use the advanced option of ‘Gradient’ filter to calculate vorticity, Q-Criterion.

Using Paraview to visualise vortex by lambda2

Posted in Programming, Research | Comments Off on Using paraview to visualise vorticity (Lambda2, vorticity, Q-Criterion)

What is the max array size you can declare (big data challenge)

by Qingfeng Xia @ iesensor.com 2015

With the popularity of BIG DATA concept, have you think about what is the max data structure you can run?http://stackoverflow.com/questions/216259/is-there-a-max-array-length-limit-in-c

Continue reading

Posted in Programming | Comments Off on What is the max array size you can declare (big data challenge)

Ten things you must do after install Openwrt 15.05 on raspberry pi B

This is not a tutorial, but list some interesting things for Openwrt

2015-09-14 by Qingfeng Xia
Continue reading

Posted in Ineternet of Things, Linux | Comments Off on Ten things you must do after install Openwrt 15.05 on raspberry pi B

Gmail backup to your google drive using app script (isenensor.com)

 

Link to my google spread sheet with script: Gmail backup isenensor.com

https://docs.google.com/spreadsheets/d/1vcQ-dJ_9iEmISLDnDjAFWrb4zcGOhEJzIJmMoq_MLYQ/pubhtml

Continue reading

Posted in Uncategorized | Comments Off on Gmail backup to your google drive using app script (isenensor.com)

Electronics under extreme environment (high temperature, low temperature)

Electronics under extreme environment

dirlist

 

 

 

 

Collection of public resource, product catalog, NASA presentation, etc

Posted in Uncategorized | Comments Off on Electronics under extreme environment (high temperature, low temperature)

smoother python 2.7 to 3.x transition (scite as IDE)

I aim to write code in python script, most of time, single file script, to run on both 2.x and 3.x with my favorite light-weighted IDE scite. So here is my setup
Continue reading

Posted in Programming | Comments Off on smoother python 2.7 to 3.x transition (scite as IDE)

readonly root file system for raspbian

crash of SD card file system make me crasy, so I need to to sth!
Continue reading

Posted in Linux | Comments Off on readonly root file system for raspbian

raspberry pi 2 is tested in compressed air vessel working at 5bar

Recently, as a byproduct of exp work in Ox Uni,  I tested raspberry pi 2 works at 5 bar, it could work at higher pressure but not tested.

All the rpi 2 use no electrolytic capacitor (all components are supposed to be pressure tolerant), so it is potentially working at higher pressure than atm.  Now it is confirmed.

Also, UART (RT and TX) pins are used to communicate between two pi. It works with 1 meter cable at 115200. amplifier_HP_testing

Posted in Sensor | Comments Off on raspberry pi 2 is tested in compressed air vessel working at 5bar

Allyoyn 14.12 compiled on raspberry pi and ubuntu

based on ref in Chinese:  [blog.csdn.net/huangjuegeek/article/details/38515445]

Continue reading

Posted in Ineternet of Things | Comments Off on Allyoyn 14.12 compiled on raspberry pi and ubuntu

using raspberry pi and beaglebone launchpad as USB-uart

This is a note collected from internet source

Continue reading

Posted in Uncategorized | 1 Comment

《思学篇》

序: 今吾留学已逾二载,尚且彷徨。观乎同辈,或有身兼中西之学,文理书乐皆通,踌躇满志者,窃以为不如。 吾温顺静思,非浪荡轻浮之人,奈何拘于家学见闻。究其根本,盖教育环境之异。

吾祖世代或农或商,非书香门第,几无藏书,唯《本草》《毛选》,皇历账本数册而已,想儿时亦无此趣。闲暇务农而少游冶,亦无良师益友导引。既入大学,尚忧衣食。而后随波逐流,年华暗换,而立之年近,尚且浑噩。

余常叹:幼不得读书以茂才,少不能观史以宏志,壮不及交游以广识。幸入大学门径,博览群书,略晓古今之智士,初窥大道;偶得游历机缘,登堂入室,声闻中外之贤达,眼界始开。

“穷则思,思则变”,听闻“苏老泉,二十七,始发愤”,吾以为桑隅非晚,故思学。身已后人,当奋发图前,奈何心力见衰,难以专志。唯恐心有余而力不足,观荀子之《劝学篇》,做《思学篇》以自勉。

—-

方今之世,风云变幻。万马奔腾,先者领之;鱼跃龙门,能者居上。

人皆有天赋,需发而养之。欲增其才,识不可以不广;欲显其能,学不可以不精。雄韬武略,非生而有之;高瞻远瞩,需广学精思。古今中外不乏先例。魏吴起身先士卒,吸疮负粮,众人争死。拿破仑博闻强识,因势利导,举国拥戴。丘吉尔文武双修,弘毅独行,力挽狂澜。

或曰纵子勤勉,无家学家世可承,抑将有成乎?吾以为不尽然也!

谋 国之举,一代难成;佐国之臣,出于当世;鸿儒巨硕,自励自成。王莽篡国,三代之力;三国鼎立,各有家承。然煮酒论英雄之时,袁绍承四世三公之势,虎踞冀州 之地,曹操不以英雄论之,何也?善始不必善成,非有能者不能成其大。乱世出英豪,时势造英雄。刘邦布衣起家,而夺项王之天下。朱元璋由卑至尊,今谓之草根 皇帝。北宋一代,治世能臣多出寒门。自古大儒多出寒门。穷则益坚,安贫知命,不为逢迎攀比而劳身,虚名福利损命。

家世显赫,乃生之幸,非众人之福;良师益友,世人皆可寻而得之。 盖今世之教育,童蒙重在家教,小学贵在师严,中学益在志高,大学旨在求索。 所闻所见所识所能,皆可后天补养,所需者,时也!

而立之年吾志方立,其晚乎?尽人事而听天命。 诚能守一毅行,去躁守静,当有所成。


西元二零零九年年末
英国曼彻斯特

Posted in 时评随笔 | Comments Off on 《思学篇》