All posts by Will

Cyclismo change log

Known bugs:

  • Don’t handle other programs seizing control of ant radio gracefully
  • Don’t handle ant usb stick removal gracefully
  • Let us know…

Change log:

  • 0.0.1 initial release
  • 0.0.2 add wakelock to stop ant sleeping
  • 0.0.3 Updated minimum recording distance to 0m (sensor values now drop to zero), improved location determinism, handling most exceptions in TurboService (needs improvement)
  • 0.0.4 Updated google play services lib (not sure how different it was)
  • 0.0.5 Pause status only check first 3 bytes (thanks Dan), added ability to log ant+ communication: see settings -> ant+ -> diagnostic logging

Download

Download latest version

Get the source code

Bushido news

chart_samplesimulation

The Big D and I have been working hard at coding an android app with Tacx Bushido support. The current state is that we have a working app (albeit with a few rough edges) that can simulate GPX courses. So it is with great pleasure that we release a preview (source code now up):

You will need:
– A Tacx Bushido Turbo Trainer and Headunit
– The app: http://cowboycoders.org/Cyclismo.apk
– ANT+ Radio Service: https://play.google.com/store/apps/details?id=com.dsi.ant.service.socket
– ANT+ USB Service and a USB host OTG cable (if you want to use a usb ant+ stick and your device isn’t listed on the ANT+ Radio Service page) : https://play.google.com/store/apps/details?id=com.dsi.ant.usbservice&hl=en

It is worth pointing out that you can run this in VirtualBox on windows/max/linux using android x86 (android-x86.org). I use android-x86-4.0-RC2-eeepc.iso for testing.

You will need to enable:

– Settings -> Location services -> allow GPS satellites
– Settings -> Developer options -> Allow mock locations (this was the easiest way of plotting your position on the google map)

Instructions:
– Upload a gpx you want to simulate some where on your android device
– Start the app
– Press Record
– Choose simulation mode
– Choose the Course (GPX import will appear)
– Select the GPX you uploaded earlier (takes you back to course setup screen)
– Turn on the bushido headunit
– Press Go
– After a few seconds ‘start cycling’ will appear on the headunit display
– Start cycling!

Caveats:

– Connects to the Bushido Head unit only
– Exceptions not really handled at the moment (this means the app will force close (‘stop responding’). This will happen if you don’t have the required packages (see above) or some other incompatability.
– Only tested on Android 4.03 (so your milage may vary on earlier versions)

Features:
– Shows power,cadence, speed and heart rate (in the chart view)
– Route is shown on a google map
– Export ride as tcx (to process in other bits of software)

Feature requests welcome.

In other news, BerryS has reversed a few more nuggets of the Bushido Headunit protocol (see the wiki). We now know about long/medium button presses, the device serial and the user’s weight. Cheers BerryS!

NO WARRANTY – PLEASE REGARD AS EXPERIMENTAL

BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

Introducing JFormica an ANT+ library for java

I have rewritten python-ant by Martín Raúl Villalb in Java. There are presently two drivers: one is a wrapper around Dynastreams own ant library for Android and the other is a javax.usb driver for ANT+ usb sticks. This allows code to be be prototyped on a development machine before adding the android specific stuff.

Features:

  • Most ANT messages have been mapped to a class, and if configurable, contain methods to adjust those configuration options.
  • Easily add listeners to individual channels with message-type filtering
  • Utility methods to wait for a response (with timeouts) to any message sent to the ant chip
  • Burst message helper function (send bursts by simply passing a byte []) – will throw an exception if transmission fails

Grab it from : https://github.com/cowboy-coders/JFormica

Here is a code sample:

class Listener implements  BroadcastListener<BroadcastDataMessage>{

@Override
public void receiveMessage(BroadcastDataMessage message) {
System.out.println("Heart rate: " + message.getData()[7]);
}

}

public void test_hrm() throws InterruptedException, TimeoutException {

// first usb ant-stick
AntTransceiver antchip = new AntTransceiver(0);

Node n = new Node(antchip);

NetworkKey key = new NetworkKey(0xB9,0xA5,0x21,0xFB,0xBD,0x72,0xC3,0x45);
key.setName("N:ANT+");

n.start();
n.reset();

// sets network key of network zero
n.setNetworkKey(0, key);

Channel c;
c = n.getFreeChannel();

c.setName("C:HRM");

ChannelType channelType = new SlaveChannelType();

c.assign("N:ANT+", channelType);

c.registerRxListener(new Listener(), BroadcastDataMessage.class);

c.setId(0, 120, 0, false);

c.setFrequency(57);

c.setPeriod(8070);

c.setSearchTimeout(255);

c.open();

Thread.sleep(10000);

c.close();
c.unassign();

//return the channel to the pool of available channels
n.freeChannel(c);

n.stop();

}

 

PyBushido code up

Overview of PyBushido:

bushido_logger.py

replicates Tacx TTS slope distance mode (headunit enters PC Communication mode)

functionality:

  • logs data to console
  • slope buttons (up and down arrows) implemented

bushido_middle.py

a simple man in the middle implementation for snooping on communication from the headunit to the brake.

to use:

  • start training on tacx headunit
  • run bushido_middle.py
  • you can optionally edit injections.py to modify data before retransmission

Source code

You can grab all the source code we are using to reverse engineer the Tacx Bushido here:

Cowboy Coders Github

Configuring Open Embedded to bake Angstrom images for the mini2440

Please Note: I noticed a few people were having trouble with the Angstrom build using Doug’s article, so I thought I’d post the exact method I used (which seemed to work!) so others can retrace my steps with out confusing anyone by editing the previous article! If you have already successfully baked an Angstrom image please ignore this post!

First off I’d like to point out that this article is essentially an amalgamation of the Open Embedded Wiki (Getting Started) and Angstrom’s ‘Building Angstrom’ articles but in context relating to the mini2440 Embedded PC. If you would like a more detailed and probably better written explanation please refer to these two articles.

Make sure you have the packages needed for Open Embedded(OE) by visiting here and looking under the section relating to your distro. Running fedora 11 I did:

su -c "yum install python m4 make wget curl ftp cvs subversion tar bzip2 gzip unzip
python-psyco perl texinfo texi2html diffstat openjade docbook-style-dsssl
docbook-style-xsl docbook-dtds docbook-utils sed bison bc glibc-devel glibc-static
gcc binutils pcre pcre-devel git quilt groff linuxdoc-tools patch linuxdoc-tools
gcc-c++ help2man perl-ExtUtils-MakeMaker"

Getting down to business…

Open up a terminal. Issue these commands:

su -
mkdir -p /stuff2/build/conf
chmod 777 -Rf /stuff2/
exit
cd /stuff2/

Download latest bitbake from here and extract the bitbake directory in the archive (eg. bitbake-1.8.16) to /stuff2/

A few more commands:

mv bitbake-1.8.16/ bitbake
git clone git://git.openembedded.org/openembedded
cp openembedded/conf/local.conf.sample build/conf/local.conf

Edit the config you have just copied using your favourite text editor.

gedit build/conf/local.conf

It is important that you read the config carefully so that you understand what everything does…

Next edit it to look something like this (which is just a slightly modified version of openembedded/contrib/angstrom/local.conf) :

Note: Do not copy and paste from this article due to formatting issues. You can download a pre-made local.conf here.Just extract to /stuff2/build/conf/ …

MACHINE = "mini2440"

# Where to store sources
DL_DIR = "/stuff2/downloads"

INHERIT += " rm_work "

# Make sure you have these installed
ASSUME_PROVIDED += "gdk-pixbuf-csource-native imagemagick-native librsvg-native"

# Which files do we want to parse:
BBFILES := "/stuff2/openembedded/recipes/*/*.bb"
BBMASK = ""

# What kind of images do we want?
IMAGE_FSTYPES += " tar.bz2 "

# Set TMPDIR instead of defaulting it to $pwd/tmp
TMPDIR = "/stuff2/${DISTRO}-dev"

# Make use of SMP and fast disks
PARALLEL_MAKE = "-j2"
BB_NUMBER_THREADS = "2"

#tinderbox
#INHERIT += "oestats-client"
OESTATS_BUILDER      = "myname"

DISTRO = "angstrom-2008.1"

Save and exit the editor. Download this script and move it to the directory /stuff2/ .

Check it is ok:

gedit /stuff2/source-me.txt

It should look something like this:

export OETREE="/stuff2"
export PATH=/stuff2/bitbake/bin:$PATH
BBPATH=${OETREE}/:${OETREE}/build/:${OETREE}/openembedded/
PKGDIR=${OETREE}/build/
DL_DIR=${OETREE}/downloads
echo Setting up dev env for Ångström

if [ -z ${ORG_PATH} ] ; then
ORG_PATH=${PATH}
export ORG_PATH
fi

if [ -z ${ORG_LD_LIBRARY_PATH} ] ; then
ORG_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
export ORG_LD_LIBRARY_PATH
fi

PATH=${OETREE}/openembedded/bitbake/bin:${ORG_PATH}

cd $PKGDIR

LD_LIBRARY_PATH=
export PATH LD_LIBRARY_PATH BBPATH
export LANG=C
export BB_ENV_EXTRAWHITE="MACHINE DISTRO OETREE ANGSTROM_MODE ANGSTROMLIBC LIBC"

echo "Altered environment for OE Development"

save, and start the script:

cd /stuff2/
source source-me.txt
cd ../openembedded

one last update:

git pull

Issue a few commands to fix build issues:

su
sysctl vm.mmap_min_addr=0
setenforce 0 (Fixes an SELINUX problem during building)
exit

issue build commands:

bitbake base-image ; bitbake console-image ; bitbake  x11-image

Be prepared to saturate your internet connection, wait a long time and take up a lot of disk space!
The result ends up in:

stuff2/angstrom-dev/deploy/glibc/images/mini2440

You should have the image(s) in .jffs2 for flashing and .tar.gz for mounting using NFS.