Pages

Labels

Wednesday, 26 February 2014

Coding the Arduino in C++ - Choosing a development environment

So now that we have decided what language to write the code in, we need to decide what development environment we want to use, and with the passion that surrounds Arduino, it is not surprising to discover that we are going to be spoilt for choice.

It is however important to remember that we have a number of requirements that we should keep in mind when assessing each environment, these are:
  • Coding in C++
  • Ability to use testing frameworks, including:
    • Google Test (GTest)
    • Google Mock (GMock)
  • 'Projects' that can build on Continuous Integration (CI) build servers, in particular: 
    • Teamcity

Arduino Studio

The first option you are likely to come across, is Arduino's own development environment, Arduino Studio, which truly is a multi-platform set of tools. Even if you end up not using this application, it is strongly advisable to install it, ensure that items like the Windows USB device driver are installed and working, this is well put together and will ensure some of the easy to forget, and hard to retrospectively install are done for you. I would also encourage you to spend a little time going through the process of writing a few of the introduction sketches, as this will make the jump into Arduino development that a little smoother.

The biggest main reason I have chosen not to use Arduino Studio is that as I progress I want to be developing the coding side of the prototyping I plan to do using a truly Test Driven Development (TDD) approach, and run the builds themselves on CI build servers. Although that is not impossible, the TDD framework, and CI environment discouraged me from going down this route.

Atmel Studio

Another option out there, and the one built by the manufacturer of the microcontroller chips, is Atmel Studio, a fully featured Integrated Development Environment (IDE), which is in part because it has been built on top of an existing industry standard IDE, Microsoft's Visual Studio. The fear here would normally be that this would be an expensive option, but it isn't, both Microsoft and Atmel provide their portions of this product free of charge. The biggest problem I have with this is that in order to run the application you must be running Windows, and this does not easily fit in with the mixture of development machines that we use (a combination of Windows, and Mac).

Eclipse

So what else is there? In every branch of software development a product comes up time and time again, Eclipse, and I know that there are many out there that won't have a bad word said about it. However the consensus in our development team is very negative towards this product, so selling it as a development tool for Arduino could adversely effect on Arduino development.

Back to basics

Everything investigated above, and many other options not documented in this post, have all had issues that makes them unsuitable for our requirements, so in the end we have chosen the most universal of the coding environments, the text editor.

More precisely we have chosen a process for developing, rather than an environment, in particular using CMake to define a build file, and Rake as the script that will run it.

Now I know that there will be many out there that are shuddering at this idea, having spent many years working in the comfortable surroundings of Visual Studio, I know how easy it is to become dependent on an IDE that does much for you, and highlights clearly anything it has a problem with, and with third party plugins, like JetBrains Resharper, the process of coding becomes simpler still.

But in this day and age, understanding an assortment of languages, and environments is what all developers should be striving for, and a scripting language like Rake can be used on so many platforms that not learning about it would seem foolish.

What's Next

In the next couple of post I will go through setting up both Windows and Mac OS X, to build projects using this approach, and then I'll detail how to setup Teamcity to enable automated builds and tests to take place.

Once we have done this, I will start a series of posts in which I will take you through the process of developing Arduino projects in a truly TDD approach. 

Tuesday, 18 February 2014

Coding the Arduino in C++ - The reasons behind my decision.

By default most people will code their Arduino boards using the Arduino Studio, which means writing code in a variation of C. Personally I don't have a problem with that, for most developers using this board it's perfectly fine, it's just that I want to do so much more than I can easily achieve with C. Therefore I'll be developing in C++, and will starting with this post describe the decisions, options and then steps I am taking to achieve this.

Firstly I feel I must explain what it is that I want to achieve that the variation of C that is used in Arduino Studio, either doesn't provide me with, or is not as straight forward as I feel it ought to be.

Firstly I am working in a truly agile development environment, and a key to agile development is Test Driven Development (TDD). Now I am aware that there are TDD boiler plates out there that can be used in Arduino Studio, the arduino_c_scaffold git repository created by the throwtheswitch.org guys looks a really good place to start, however I am looking for something with a little more support behind it, and Google Test (gtest) feels a better solution.

Going hand in hand with the unit testing framework, is object mocking, important because if you aren't mocking, faking, or otherwise separating code that you are testing from any dependencies that code is using, you are not doing unit testing, which in itself breaks a core part of TDD. The throwtheswitch guys do have this covered too in their product cmock, and I would fully recommend checking what these guys are up to, as for most this really can be seen as a solution to the TDD problem, but again what I am looking for is a framework that is more widely used and gtest sister product Google Mock (gmock) is the framework that I prefer to use.

Beyond TDD, there are other reasons for choosing to go down the C++ route, not least because we are anticipating having to incorporate hardware that is not currently available in pre-built Arduino shields. If you are building new hardware, or providing libraries of code that other developers will use on Arduino, these are typically written as C++ libraries, so the fact that we are expecting to be writing C++ for these libraries, and the unit tests, it seems sensible to write all the code in C++.

So those are the reasons behind my decision to code in C++, next I will select the development environment, and describe setting up the automated build system we use, Teamcity, to build, test, and deploy these projects.




Monday, 17 February 2014

Arduino Uno - Unboxing

Having decided on prototyping using the Arduino broad, and having little previous experience of doing so, it seemed sensible to go with the most popular starter board on the market, the Arduino Uno. It has been a while since the original board first appeared, and so the board brought was actually the third revision of the board, the R3.

When the board arrived it came in a moderately sized box for a board so relatively small. In part I think this is because a lot of these boards are brought by first timers, and the box is the first part of giving the customer some reassurance of the quality of the device inside.


When you open the box up (simply removing, or slitting the tape), you first find what looks like a colourful booklet, this turns out instead to be an A2 sheet which can be used as a two sided poster. If your looking for instructions on getting started, the only thing you really get is a link back to their website, this though I think is a very sensible approach, almost everybody has internet access 24/7, and rather than reprinting hard-copy instructions whenever a change is made to the hardware (or firmware), the latest information is always available.

Having taken the pamphlet out of the box you get your first sighting of the board itself, and a very well manufactured board it is.


Taking the board out of the box an it looks anything but hobbyist built, with all components perfectly aligned, and securely fixed.


Turn the board over, and you get an extra level of sophistication, with the board coloured in an inverted palette to the front, and plenty of information about the board itself.


That just leaves the final thing to do, plug it in and start playing.



 
 
Blogger Templates ReadABlog.com