Homepage Wiki Forum Buy



Revision as of 06:26, 27 September 2013 by Sauterbe (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Demo project

This article explains how to integrate the Gnublin API in a project with Makefile.

Before you start, the cross-compile toolchain must be installed as described in C/C++ development environment installation.

After that, we need the following API files:

Let us first create a folder for the demo project

user@dev-pc:~$ mkdir ledblink

Browse to the folder

user@dev-pc:~$ cd ledblink

Download the file gnublin.cpp and gnublin.h

user@dev-pc:~$ wget https://raw.github.com/embeddedprojects/gnublin-api/master/gnublin.h
user@dev-pc:~$ wget https://raw.github.com/embeddedprojects/gnublin-api/master/gnublin.cpp

Once done, you now create a file in the folder with the name ledblink.cpp and copy the following code, or loads the file from the Internet:

user@dev-pc:~$ wget http://www.gnublin.org/downloads/ledblink.cpp

Contents of the file ledblink.cpp:

#include "gnublin.h"
int main(){
  gnublin_gpio gpio;
  gpio.pinMode(3, OUTPUT);    //GPIO3 als Ausgang festlegen
  while(1) {
    gpio.digitalWrite(3, HIGH);  //LED an
    sleep(1);                    // 1 Sekunde warten
    gpio.digitalWrite(3, LOW);   // LED aus
    sleep(1);                    // wieder 1 Sekunde warten

Now we need the Makefile. Create it in the same folder or download it from the internet:

user@dev-pc:~$ wget http://www.gnublin.org/downloads/Makefile

Contents of the file Makefile:

objects = ledblink
all: gnublin.o $(objects)
gnublin.o: gnublin.cpp gnublin.h
	arm-linux-gnueabi-g++ -c gnublin.cpp 
$(objects): $(objects).cpp gnublin.o
	arm-linux-gnueabi-g++ -o $(objects) $(objects).cpp gnublin.o
	rm -Rf *.o $(objects)

Now you can compile the program by typing the following command:

user@dev-pc:~$ make


arm-linux-gnueabi-g++ -c gnublin.cpp
arm-linux-gnueabi-g++ -o ledblink ledblink.cpp gnublin.o

Now you have an file called: ledblink.

If you have a network connection to the gnublin you can copy the binary with the instruction

user@dev-pc:~$ scp ledblink root@

into the root folder. That it works before you have to connect by terminal and create a password for the root user with:

root@gnublin:~# passwd

Now you can start the programm on the GNUBLIN with

root@gnublin:~# ./ledblink

Nun sollte die LED blinken. Wenn man das ledblink Programm wieder beenden möchte, einfach folgende Tastenkombination benutzen: Now the LED should blink. To terminate the program ledblink just press the following key combination:

ctrl + c 

Install the actual debian package

For the Gnublin there is a debian package to install the tools for the modules. The package is available because compiling the tools on the GNUBLIN takes at least 5 minutes.

For security, you should delete all old packages:

apt-get remove gnublin-adcint gnublin-adcmod gnublin-dogm gnublin-relais gnublin-step gnublin-gpio gnublin-pca9555 gnublin-lm75

First you have to download the debian package:

wget https://github.com/embeddedprojects/gnublin-api/raw/master/gnublin-tools_0.1-1_armel.deb

Then transmit the package onto Gnublin and install it with:

root@gnublin:~# dpkg -i gnublin-tools_0.1-1_armel.deb

To remove the package type:

root@gnublin:~# dpkg -r gnublin-tools

Develop with an IDE and the API

Here you can find informations how to write your own applications:

In other languages