The Raspberry pi is a device which uses the Broadcom controller chip which is a SoC (System on Chip). This SoC has the ARM11 processor which runs on 700 MHz at its core. The operating systems like Archlinux ARM, OpenELEC, Pidora, Raspbmc, RISC OS and the Raspbian and also Ubuntu versions are available for the Raspberrypi board. Linux operating systems especially Ubuntu is preferred for all kind of programming and development. The Raspberrypi is a board actually designed for helping computer education for remote schools but it is a nice platform for programmers especially beginners to explore various coding techniques.
This project basically requires two programs which are meant to send data in between them, and a named pipe which will be created by anyone of them. The entire system can be represented with the help of the following diagram:
Fig. 2: Block Diagram Of Name Pipe Process Using Raspberry Pi
Fig. 3: Command To Write Data In Temporary File From Terminal In Raspberry pi
Project Source Code
###
#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>
#define OUR_INPUT_FIFO_NAME "/tmp/my_fifo"
unsigned char rx_buffer [ 256 ];
int rx_length;
int our_input_fifo_filestream = -1;int result;
int main ()
{
printf ( "Making FIFO...n" );
result = mkfifo ( OUR_INPUT_FIFO_NAME, 0777 );
our_input_fifo_filestream = open ( OUR_INPUT_FIFO_NAME, ( O_RDONLY | O_NONBLOCK ) );while ( 1 )
{
rx_length = read ( our_input_fifo_filestream, ( void* ) rx_buffer, 255 ); //Filestream, buffer to store in, number of bytes to read (max)
if ( rx_length > 0 )
{
rx_buffer [ rx_length ] = '