[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1. Background


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. Abbreviations


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3. Supported boards and platforms


Supported Arduino boards


Supported Operating Systems


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Installing Searduino


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Source code releases


Download from
http://download.savannah.gnu.org/releases/searduino/


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Latest Source code


Download from
http://git.savannah.gnu.org/gitweb/?p=searduino.git;a=snapshot;h=HEAD;sf=tgz


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 From git repository


Download from
git clone git://git.savannah.nongnu.org/searduino.git


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 Binary releases


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.1 GNU/Linux


Create a installation directiory (e.g /opt/searduino)
mkdir -p /opt/searduino

Go to the installation directory
cd /opt/searduino

Download a release from
http://download.savannah.gnu.org/releases/searduino/bin/
E.g http://download.savannah.gnu.org/releases/searduino/bin/searduino-bin-0.4-x86.tar.gz

Unpack
tar zxvf searduino-bin-0.4-x86.tar.gz

Verify installation - with the digpins example
cd example/digpins/
Make sure that the SEARDUINO_PATH in the Makefile points to your Searduino installation dir.

Build blinker program for PC
make

Set up environment to find the Searduino shared libs
export LD_LIBRARY_PATH=/opt/searduino/libs

Execute blinker
make check-sw
The blinker program should run and print out (the printouts comes from the stub libraries). Interrupt the program by sending a signal, e g by pressing Ctrl-C.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Using Searduino

In the previous chapter we looked a bit at the digpins example, so we now have some feeling for what a Searduino Makefile contains. We will now proceed by writing our first Arduino program using Searduino.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Writing the first program


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.1 The first C file



To use the Arduino functionality you need to inlude Arduino.h, so we need to add this:

#include <Arduino.h>

When using Arduino IDE you’re used to having the loop function as the starting point for the program. With Searduino we’re back to the normal C way with a main function, so we need to define a main function.

int main(void) { }

As with the loop function you write when you’re using the Arduino IDE, the main function needs to never exit or return. It’s a simple control loop (see http://en.wikipedia.org/wiki/Embedded_system#Simple_control_loop).

So a very simple main function looks like this

int main(void)
{
for(;;)
{
digitalWrite(13, 1);
delay(100);
digitalWrite(13, 0);
delay(100);
}
}


Note: this program sets pin 13 high and low with 0.1 secs interval. You don’t need to connect a led to output pin 13, since pin 13 already has a built in led on the board.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.2 Write the first Makefile

Inporant settings in the Makefile



Include the searduino makefile
You need to include somce settings, targets and rules from Searduino. This is done by adding the following line to your Makefile.

include $(SEARDUINO_PATH)/mk/searduino.mk


Note: You don’t have to use the makefiles provided by Searduino. The makefiles do however provide a lot of help (board settings etc).


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.3 Building the program for PC

To build your software to be executed on your PC:

make sure the the variable ARDUINO in the Makefile is set to stub.

and type:

make clean
make

To run the program

./blinker


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1.4 Building the program for UNO

To build your software to be executed on your PC:

make sure the the variable ARDUINO in the Makefile is set to uno and type:

By setting ARDUINO to uno the Searduino makefiles will use the settings for building and uploading for the Arduino UNO board.
To build the program, all we have to do now is to type:

make clean
make


To upload and run the program on the Arduino UNO board:

make upload

You should now be able to see the built in led (pin 13) flash. If not, the author of this document need to his homework.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6. Build for different targets

With Searduino it’s (relatively) easy to compile your program for various boards. You decide what targets to build for with the ARDUINO variable in the Makefile. The following values of that variable are implemented.

Build types


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7. Various Searduino functions/macros


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.1 print functions/macros


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8. Simulators

With Searduino you can easily build your code with the following stubs/simulators:


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1 Stub


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2 Streamed simulator


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2.1 Scripting with bash


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2.2 Scripting over the network


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.3 Pardon simulator


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.4 xxx simulator


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9. Using the Python scripting interface


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10. Debugging Arduino code


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11. Examples


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.1 Example Makefile



SEARDUINO_PATH=/opt/searduino
PROG=blinker
SRC_C=blink.c
SRC_CXX= stuff.cpp morestuff.cpp
MAIN_SRC=main.c
ARDUINO=stub
$(PROG):
upload:
include $(SEARDUINO_PATH)/mk/searduino.mk


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.2 Example C code



#include <Arduino.h>

int main(void)
{
for(;;)
{
digitalWrite(13, 1);
delay(100);
digitalWrite(13, 0);
delay(100);
}
}


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12. Write your own simulator


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.0.1 Writing a simulator in C/C++


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.0.2 Writing a simulator in Python


[Top] [Contents] [Index] [ ? ]

Table of Contents


[Top] [Contents] [Index] [ ? ]

About This Document

This document was generated by hesa on January 10, 2012 using texi2html 1.82.

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ < ] Back Previous section in reading order 1.2.2
[ > ] Forward Next section in reading order 1.2.4
[ << ] FastBack Beginning of this chapter or previous chapter 1
[ Up ] Up Up section 1.2
[ >> ] FastForward Next chapter 2
[Top] Top Cover (top) of document  
[Contents] Contents Table of contents  
[Index] Index Index  
[ ? ] About About (help)  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:


This document was generated by hesa on January 10, 2012 using texi2html 1.82.