Using USB-serial FTDI adapters with Intel Edison

The current Yocto kernel distro available for the Intel Edison (version 68 by configure_edison --version) does not include the FTDI driver. Thus when you plug a USB-serial adapter into the USB OTG host port, you’ll see it partially recognized in dmesg tail upon plugin, but you won’t see an assignment to a /dev/ttyUSB_ device.

You need to install the FTDI kernel module first.
opkg install kernel-module-ftdi-sio
This assumes you have already setup the unofficial opkg repository.

Now when you type dmesg tail you’ll see the line something like
usb: FTDI USB Serial Device converter now attached to ttyUSB0

You may have to update your kernel if this doesn’t work.

Connecting to Boston University’s 802.1x Wifi from a Linux device

BU’s Enterprise Wifi is a little tricky to connect to. The settings below are modified from BU’s recommended settings that didn’t work for me. I have notified BU IT that their webpage is out of date.  Their webpage has now been updated.


# nano /etc/wpa_supplicant/wpa_supplicant.conf

paste at the end
network={
ssid=”BU (802.1x)”

key_mgmt=WPA-EAP
pairwise=CCMP TKIP
eap=TTLS PEAP MSCHAPV2
identity=”Your BU login”
password=”your Kerberos Password: be aware others can read this file!”
phase2=”auth=MSCHAPV2″
}

Then

# reboot

This results in the feedback upon successful connection:

# wpa_cli -i wlan0 status

ssid=BU (802.1x)
id=2
mode=station
pairwise_cipher=CCMP
group_cipher=TKIP
key_mgmt=WPA2/IEEE 802.1X/EAP
wpa_state=COMPLETED
ip_address=155.41.65.23
Supplicant PAE state=AUTHENTICATED
suppPortStatus=Authorized
EAP state=SUCCESS
selectedMethod=21 (EAP-TTLS)
EAP TLS cipher=DHE-RSA-AES256-SHA
EAP-TTLSv0 Phase2 method=MSCHAPV2

WriteLatex vs. ShareLatex

Short answer: Use ShareLatex

Why?
1) ShareLatex is much faster to compile. I have a 30 page journal article draft with numerous figures, and WriteLatex seems to take on the order of a minute to compile while ShareLatex was substantially less.

2) ShareLatex has far better error/warning feedback and a much better IDE overall. WriteLatex error/warnings keep disappearing and the line number with error is not clearly indicated.

3) ShareLatex is open-source. WriteLatex is NOT open source.

Python findpeaks

If you’re looking for a Python function that works like Matlab’s “findpeaks” checkout SciPy argrelmax.

If you want to do a comparison in the same code, you can call Octave findpeaks using Oct2Py, or use the Matlab Python API in Matlab R2014b

Intel Edison: Measuring USB voltage on breakout board

I have been trying out a variety of power sources. One is the 4xAA battery holder to female USB Verbatim 97928 available for about $10. It seems to have a well regulated 5.0 volt output.

edisonpower

The red arrow points to the side of the “74″ diode that comes right off the micro USB connector. I measured 5.00 Volts there with the Edison running on the Verbatim 97928. On the other side (downstream) of the diode I measured 4.72 Volts with the Edison idling. This voltage drop is expected due to the forward bias diode voltage drop.

Under 100% of one core CPU load, I measured 4.98V on the USB side, and 4.66V on the Edison side of this diode while powering from the USB port on the Verbatim 97928. The miniscule apparent 20mV voltage drop on the battery/USB side of the diode is likely to come from ohmic losses in the USB connector and cable.

Based on measurements of Intel Edison power consumption, and assuming 2000mAh, I estimate 10-12 hours of battery life on 4xAA alkaline batteries assuming continuous 100% CPU of one of the two CPU cores (other core idle). Normally the Edison will be mostly resting, drawing perhaps 100mW.

Thus with mixed use, I might expect to get up to 4-5 days of continuous mixed use operation on 4xAA batteries for the Intel Edison.

Miniconda Python on Intel Edison

Since the Intel Edison is a 32-bit CPU, we use the 32-bit version. But first, we need to install GNU Tar because Busybox tar doesn’t have some needed tar options, and it’s not compatible with GNU tar archives (!).

Since original writing, AlexT_Intel has put GNU tar in the opkg repository, so you can just do:

opkg install tar


wget ftp://ftp.gnu.org/gnu/tar/tar-latest.tar.gz
tar xvf tar*
cd tar*
export FORCE_UNSAFE_CONFIGURE=1
./configure
make

The ./configure takes almost a minute on a desktop PC, so it will take a few minutes on the Edison. Likewise for the make step.
You’ll see the tar binary at ~/tar-1.28/src/tar
nano ~/.bashrc
add the line
alias tar='/home/root/tar-1.28/src/tar'

Now let’s get Miniconda

wget http://repo.continuum.io/miniconda/Miniconda3-3.7.0-Linux-x86.sh

Finally run the install (all typed on one line)

BASH_ENV=/home/root/.bashrc bash Miniconda3-3.7.0-Linux-x86.sh

when install complete, since Edison normally uses Dash shell, we create

echo "export PATH=/home/root/miniconda3/bin:$PATH" >> ~/.profile

Then reopening a Terminal window to the Edison will show
python

Python 3.4.1 |Continuum Analytics, Inc.| (default, Sep 10 2014, 17:21:42)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux

And you can use all the very easy to use conda goodness of Miniconda to trivially install packages like Numpy, SciPy, OpenCV, etc. on the Intel Edison.

Example:

conda update conda
conda install numpy scipy astropy

Python logging module versions to disk

I run Python massively in parallel with GNU Parallel across numerous remote PCs. I want to have the version numbers of the Python modules I’m using logged to disk. Here’s how I do so for Python 2.7 and 3.4

Python using NaN or None as sentinel

Sometimes I was forced to use NaN as a sentinel value, for example with the current version of Numba that can’t handle “is not None”.

The summary is that comparing to None instead of NaN is over 100 times faster. This negates the advantage of Numba when you have to compare to sentinel values!

Here’s a test with Python 3.4:

$ ipython3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
IPython 2.3.0 -- An enhanced Interactive Python.
from numpy import isnan
%timeit ~isnan(0)
100000 loops, best of 3: 3.75 µs per loop
%timeit 0 is not None
10000000 loops, best of 3: 35.6 ns per loop

And Python 2.7

$ipython2
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
IPython 2.3.0 -- An enhanced Interactive Python.
%timeit ~isnan(0)
100000 loops, best of 3: 3.73 µs per loop
%timeit 0 is not None
10000000 loops, best of 3: 41.5 ns per loop

Travis CI SciPy requirements.txt

I have noticed that currently Travis CI has SciPy 0.9.0. That’s fine for most of my things (except savgol_filter which is new in 0.14.0)

When I put SciPy>=0.9.0 in requirements.txt, even though Travis gets SciPy 0.9.0 from
apt-get install scipy
Travis still tries to pip install SciPy latest version.

It’s been suggested by many to just use MiniConda with some boilerplate in .travis.yml. You can see what I’m currently using

Matplotlib ValueError on LogNorm plots

I was getting the error

ValueError: Data has no positive values, and therefore can not be log-scaled.

The issue is that I was setting vmin=0 in my pcolormesh() plot. By setting vmin=1 or some small positive value, your plots will work with norm=LogNorm() as expected.