LCD support added in Searduino

I’ve bought some Arduino HW to play around with over Christmas. One of the things I bought was an LCD. After a while i realised LCD support was missing in Searduino[1] so I hacked one. Read more about it here:

http://searduino.wordpress.com/2013/12/28/partial-lcd-support-in-searduino-not-complete-but-ready-for-use/

I will start looking into the photo resistors, led matrices, … and all the other stuff I bought. Perhaps more will come in Searduino? How about a generic way to write your own simulated hardware with a nice GUI, e g write a photo resistor simulator that uses the Analog Input.

BTW; I am using VMM[2] from TestingMachine[3] to build Searduino (nightly builds and tests) on Raspberry Pis. More on this another day.

[1] http://searduino.wordpress.com/

[2] https://github.com/tis-innovation-park/tm-vmm

[3] https://testingmachine.eu/

Searduino autobuils (again) using VMM

Searduino autobuils (again) using VMM.

(Added title to blog post: March 8, 2013)

Why autobuild in the first place?

Your software has been building fine, manually, for a while so one might be tempted to think that autobuilds are superflous. Why check if your software builds and why test it on all the platforms you target automatically when you so easily can do it manually?

In Searduino’s case most of the code is written in C (and C++) using POSIX threads so it should be possible to say that if it build son platofrm A it should build equally well on platofrm B, shouldn’t it? The Java and Python extension could potentially be tested on one platform alone. I don’t think so – but I wouldn’t argue to strong for this case.

I would say you always gain from building your software on various platforms. And a side effect could be nightly dist files and even binary releases.

Searduino is a bit tricky – we don’t claim it is tricky in a unique way nor one of the trickier projects. Anyhow … Searduino provides libraries cross compiled for the various Arduino boards so we’re getting some more interesting cases where things can go wrong. Several times we’ve ran into problems with various combinations of the versions of the cross compiler (avr-gcc), libc (avr-libc), Arduino software and Searduino itself. Add to that the operating systems we target (GNU/Linux (Debian and Ubuntu – Fedora developers are more than welcome!!!), Mac and Windows (using cygwin)). We need to make sure it is easy to build the software – on as many platforms as possible and in an automated fashion. The old build server crashed recently, so we’ve been setting up a new. We’ve had Ubuntu (amd64), built natively, for some days and we needed to add Ubuntu (32 bit). We will continue with other OS:s and GNU/Linux distributions soon.

We don’t have a 32 bit computer lying around and even if we did we don’t want it to be powered on all day. So we decided, as most developers do I assume, to run the builds and test on a virtualised environment. Enter VMM.

How to test the Arduino libraries, built for the Arduino boards? Should we test on actual boards – how do we check if the code is working? Is it enough to build and upload with no errors? This something we will deal with another day. But this blog post is more about VMM so we’re leaving that for now.

Autobuilding using VMM

With VMM it’s easy to start, stop and execute commands on virtualised machines (currently VirtualBox and qemu). On the github site there’s a manual guiding you how to set VMM up.

Here’s what we did to get VMM to autobuild Searduino.

  • Install VMM
  • Install Ubuntu (32bit) in Virtualbox and call the client/guest Searduino-32.  
  • Added a user, autobuilder, to the client/guest Searduino-32. This user should run the actual builds.
  • Add your (local) ssh keys to the autobuilder (.ssh/autohorized_keys) user and to the root account (this is needed to close the host as graceful as possible).
  • Create a basic configuration for VMM called .ats/ats.conf

    # ATS Settings
    LOG_FILE_DIR=/tmp/ats
    # ATSVM Settings
    VM_STARTUP_TIMEOUT=300
    VM_STOP_TIMEOUT=20
    SSH=ssh
    SSH_TEST_OPTIONS=” -o connectTimeout=3″

  • Create a client configuration file on the host (not on the guest/client) called  .ats/clients/Searduino-32.conf
VM_NAME="Searduino-32"
VM_TYPE="VirtualBox"
VM_IP_ADDRESS=localhost
VM_USER=autobuilder
VM_SUPERUSER=root
SSH_PORT=auto
SSH_SHUTDOWN_COMMAND="shutdown -h now"

… and now we should be ready to write our script to do the actual test.

Stripped down version of Searduino’s autobuild script:

# start the client

ats-client –start-client-headless Searduino-32

# make sure the directory is empty

ats-client –client-exec Searduino-32 “rm -fr searduino”

# clone the Searduino git repo

ats-client –client-exec Searduino-32 “git clone git://git.sv.gnu.org/searduino.git”

# Build Searduino – the command line is nasty. Blame Searduino for this

ats-client –client-exec Searduino-32 “export BUILD_DOC=false ; export CXXFLAGS=\”-I/usr/lib/jvm/java-6-openjdk/include/\” ; export CFLAGS=\”-I/usr/lib/jvm/java-6-openjdk/include/\” ; cd searduino && bin/build-and-test.sh”

# Build a binary dist

ats-client –client-exec Searduino-32 “export BUILD_DOC=false ; export CXXFLAGS=\”-I/usr/lib/jvm/java-6-openjdk/include/\” ; export CFLAGS=\”-I/usr/lib/jvm/java-6-openjdk/include/\” ; cd searduino && bin/build-bin-dist.sh”

# Close down the client

ats-client –stop-client Searduino-32

Schedule the builds the way you want it. We simply put the script in /etc/cron.daily/

…. you may, which Searduino does, have to transfer some files from the client. This will be explained later – and we’re currently developing better support for this in VMM. A more complete example (a step by step guide) is currently being written. Meanwhile, check out this script https://github.com/tis-innovation-park/vmm/blob/master/examples/searduino.tmpl.

Results from the execution of the Searduino script:

Builds logs: http://129.16.213.45/searduino-build/build-logs/20130301/i686/
Binary dist: http://129.16.213.45/searduino-build/bin-dist/

Concluding remarks

The configuration needed for using VMM is limeted to some 15-20 lines. Writing a script like the above is only some 10 lines worth of work. So using VMM to do autobuilds is easy.

We’re currently working hard on getting VMM to be useful to as many people as possible.

  • It would be great if you use it
  • It would be great if you want to join us.   

/Henrik and Shaun

BTW, ats will be renamed to vmm shortly

Searduino: @FOSDEM, new GUI simulator and some thoughts on Java

First a small introduction to Searduino. Searduino consists mainly of two things. First, a couple of libs (mainly the Arduino source code compiled and archived) and some Makefiles that together make it possible and easy to write pure C/C++ code for Arduino boards. Secondly, Searduino comes with a simulated Arduino board environment. This can be used to unit test your Arduino code (think automated tests). There’s also a couple of simulators, using the simulated environment, with which you interactively typically can validate your software. The simulation is implemented in a library which loads the Arduino code (on GNU/Linux and Unices using dlload) and runs it in a thread (pthread).  This library can quite easily be wrapped by simulators and extensions for other languages That’s as much of an introduction I’ll give here.

After several attempts to get the Python/Gtk simulator called Pardon, using the Python extension to Searduino (called Pearduino), to work well , I gave up trying. The threading support in Gtk seems to make it impossible to get both speed (and we do need speed) as well as an app that doesn’t crash due to too quick/unsynchronised GUI updates from the underlying thread. Don’t get me wrong – I like working with Gtk and I am a Gnome user since … hmm around 2001 (I think). The problem we’ve seen relates to the rather complex problem of combing C binaries loaded by Python and run that in a separate thread and have the results (via callbacks) update the Gtk GUI. So what to do next?

How about a GUI in Qt? I have tried to get into Qt many times but always lacked the time to give it the time it needs.

We didn’t have to think for a long time, since part of my new job at Gothenburg University will be supervising students in Java. Wow – or perhaps uhh – it’s been a while since I did some Java hacking. A long while. The students should also learn Swing so that will be supervised too. To be able to supervise in Java and Swing I needed, it turned out I really needed it, to refresh my almost forgotten Java and almost non existing Swing skills. What better way to do this than implementing a GUI frontend to Searduino in Java/Swing? Yup, that became the task during the Christmas holiday and also the answer to what gui framework to use for the simulator.

I am more of an imperative/procedural (think C) hacker than an OO hacker (think C++, Java). I often use some concepts from OO when hacking C though – hey I don’t go about saying or thinking that mixing C++ and C is a good idea. Either you write OO (C++) or you write procedural (C). For me writing Java code for a Free Software project is a new thing.

Anyhow, over the last days I have, to my surprise, found that I’ve started to like hacking GUIs in Java. Ok, I fall in to the traps of writing C-ish Java code (send the Spanish inquisition after me for doing that!!!) and I figure most pattern fascists probably will cry so much their bodies will dry out when looking at my Java code. Nevertheless I am happy with the speed of which I wrote the GUI. And apart from some rare and odd behavior when stopping (pthread_cancel) the pthread running the Arduino code it works really well. Updates in the GUI are really really quick.

To be able to communicate with and control the C code I had to write a small JNI layer. Just as we did for Python with the Python extension. Comparing writing a Java extension to writing an extension for Python I would say they are equally easy to write.

I think the fresh GUI is the “final” piece for Searduino to make it really useful for many people – so this blog post feels really nice to write. But hey, so many words and yet nothing has been said. I will try to say at least something useful.

  • I am slightly surprised to say that I enjoyed writing a GUI in Java.
  • Searduino has now become useful for more people
  • It’s easier to join the project now – so join us!!!! We need you!

Next step then. Next steps for Searduino that is? For me personally, I would like, for the fun of it and inspired by Andy Wingo‘s post on Scheme to finally be giving Scheme a go – it may not be the strategically most optimal choice but I’ve been wanting to learn Scheme for a while so why not. Leaving myself and my ego alone for a while and instead start thinking about what the next steps for Searduino should be…. I guess that’s up to you to decide.

… and finally. I will be doing a lightning talk about Searduino at FOSDEM (thanks all FOSDEM volunteers for your friendly and informative emails!). So if you’re interested in seeing Searduino simulate some leds blinking and also actually seeing some real leds blinking – and all of this done in C/C++ – pop by the Searduino lightning talk on Saturday at FOSDEM.

Searduino needs a gui

Do you want to write a gui front-end to Searduino?

 

About Searduino:

Searduino is made to ease and speed up development for the Arduino boards. In short, with Searduino you get

  • C/C++ interface – use C/C++ to program your Arduino boards
  • Makefiles – easy to use Makefiles for inclusion in your project
  • Stand alone program – build your Arduino code to run on your local computer instead
  • Simulator – run your Arduino code in a simulator to test it
  • Simulation API – write your own test cases in C/C++
  • Python simulation API – write your tests in Python
  • Arduino example (to C/C++) translation

About the gui

In a way searduino has a gui – We have been developing a gui written Python (pygtk) to make sure we write the underlying library in a way that makes it easy to develop a real gui. So there is a gui but no proper one. Anyhow, here’s a snapshot of the (non proper) Python gui:

Searduino's simulator GUI - written in PyGtk

 

We believe that the gui needs to be written in C/C++ and using a thread safe graphical toolkit. The speed which which the callbacks call the gui require as short path as possible from the source to the handler and as already mentioned that the toolkit is thread safe (the Arduin ocode is executed in a thread). There is however a threshold for max updates per second which can be used but we still believe that C/C++ is the best way – but don’t hesitate to contact us (see email address below) if you believe differently.

Want to join?

If you like creating guis and want to help out on Searduino – send an email to hesa -at- sandklef.com

Btw: the python gui was also used to test Searduino’s Python extension

 

This post was originally posted at: http://itupw185.itu.chalmers.se/searduino/

Examples in manuals – how to verify (test) them

I’ve gotten some just comments as feedback for the examples in the Searduino Manuals. Searduino is a software to make it easy to program C/C++ for Arduino, a simulator for source level Arduino API, … and more.

Problem is the following: I’d written some examples to make it easy to get started with Searduino. After some weeks of updates to the code the examples were not correct anymore. What good is it to have examples if they don’t work? But on the other hand, it’s really a pain in the ¤/&% to have to update example code. We need a way to test example code in manuals and to automate the tests!

Copying/pasting code from a manual is not something that is not desired (error prune to say one problem). So how to find some middle ground here? Is there any software for this?

My temporary solution was to write all examples as C files and Makefiles and to write some scripts to

  • convert a C file to texinfo file (c2texi)
  • convert a Makefile file to texinfo file (makefile2texi)

and then include the generated texi files in the manual (written in Texinfo). Will probably do the same for GNU Xnee

There must be  a better way … or?

 

Searduino 0.5 released

Implemented features:

Download:

Source code dist:

http://download.savannah.gnu.org/releases/searduino/src/searduino-0.50.tar.gz

Binary dist for GNU/Linux x86_64t

http://download.savannah.gnu.org/releases/searduino/bin/gnu-linux/searduino-bin-0.50-x86_64.tar.gz

Binary dist for GNU/Linux i686t

http://download.savannah.gnu.org/releases/searduino/bin/gnu-linux/searduino-bin-0.50-i686.tar.gz

Documentation:

http://download.savannah.gnu.org/releases/searduino/doc/searduino-docs-0.50.tar.gz

 

Fixed Savannah bugs:

  • 35978  MAIN_SRC SRC_C confusion
  •  35977  Translate Arduino examples script minor bugs
  •  35976  Find a better way to look for Python stuff in configure
  •  35975  Error/warning msg when configuring
  •  35974  Problems with script to translate Arduino examples
  •  35973  exit on failure in configure.ac
  •  35871  Example has file faulty include statement
  •  35965  Run time path into binaries
  •  35982  Don’t fetch Arduino sources if already there
  •  35873  Searduino can not create SHLIBs propoerly on x86_64
  •  35964  Code for Arduino HW can not use SEARDUINO_LOOP
  •  35980  Add option to set the number of pins
  •  35963  Generated examples (arduino-ex2c) miss init();
  •  35979  Fixes for manual
  •  35983  Inclue Arduino examples in dists
  •  35976  Find a better way to look for Python stuff in configure
  •  35870  Built in example code fails to load in Pardon
  •  35872  Example misses info on how to execute program
  •  35991  Converted example includes setup instead of searduno.h
  •  35990  PROG not set when converting arduino ex to C code
  • 36012  pearduino.so link not platofrm independet
  • 36042  Not easy to do conditional programming, DEBUG macro missing

Fixed Savannah tasks:

  • 11900  Move “sleep” code from examples to stubs
  • 11948  Test code to test bin releases
  • 11921  Add examples on how to check (and use) binary dist
  • 11963  Add target lib in searduino-arduino.mk
  • 11964  install target in Makefiles for Arduino

Searduino 0.47 is out

Finally! The new Searduino makes it easy to use Searduino. Manual is up to date, even though we’re planning a new manual release to happen any day, so it should be possible to get started using Searduino really quickly.

This release will be used as a basis for a coming workshop and given the experiences from that we will release 0.5

  • build and upload plain C code for Arduino boards
  • run your arduino code locally on your computer
  • run your arduino code in a simulator (GUI or CLI)
  • write your test cases in C or Python

Get Searduino 0.47 here:

All features in Arduino are not implemented in Searduino yet. Here’s the compatibility page: