Pages

Wednesday 10 August 2022

LED Display

 create a folder ledprg in contiki/examples

copy the makefile from helloworld into the above created folder 


create a file led.c in ledprg folder


//led.c

#include "contiki.h"
#include <stdio.h>

#include "dev/leds.h"
#include "dev/button-sensor.h"

PROCESS(led_process, "LED Process");

AUTOSTART_PROCESSES(&led_process);
PROCESS_THREAD(led_process,ev,data)
{

PROCESS_BEGIN();
SENSORS_ACTIVATE(button_sensor);

while(1)
{
printf("Press the Button of the sensor\n");
PROCESS_WAIT_EVENT_UNTIL(ev==sensors_event && data==&button_sensor);
leds_toggle(LEDS_GREEN);
}

printf("The sensor value is %u \n",leds_get());
PROCESS_END();
}

//Makefile


see that both the files are in the same folder ledprg

RUN THE PROGRAM:

vl@ubuntu:~/contiki-ng/examples/ledprg$ make TARGET=native


Note :

if there is an error regarding gcc version

wget http://www.netgull.com/gcc/releases/gcc-4.8.0/gcc-4.8.0.tar.bz2
 

To extract the file:

tar -xvjf gcc-4.8.0.tar.bz2

Install some additional libraries (sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libc6-dev)

Compile the source: ./gcc-4.8.0/configure --prefix=/app/gcc/4.8.0
 

Run make (This will take some time to complete. Go make some coffee, or bake some cookies. ;-))
 

Install the code: sudo make install


sudo dpkg --add-architecture i386
sudo apt update
sudo apt upgrade
sudo apt-get install gcc-multilib libstdc++6:i386
wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.bz2 --no-check-certificate
tar xf gcc-4.8.5.tar.bz2
# cd gcc-4.8.5
# ./contrib/download_prerequisites
# cd ..
sed -i -e 's/__attribute__/\/\/__attribute__/g' gcc-4.8.5/gcc/cp/cfns.h
sed -i 's/struct ucontext/ucontext_t/g' gcc-4.8.5/libgcc/config/i386/linux-unwind.h
mkdir xgcc-4.8.5
pushd xgcc-4.8.5
$PWD/../gcc-4.8.5/configure --enable-languages=c,c++ --prefix=/usr --enable-shared --enable-plugin --program-suffix=-4.8.5
make MAKEINFO="makeinfo --force" -j
sudo make install -j

No comments:

Post a Comment

OSPF Using CPT

OSPF (Open Shortest Path First)  is a common networking protocol used for routing within an autonomous system and is widely used due to its ...