Nowadays programming language is getting more popular and is being used in each and every domain. Various applications, software etc. are created by programming. C programming is easy and simple language, which can prove to be a useful choice for a beginner who wants to become a programmer.C language is the basis of all languages and is useful to understand the concept of Linux in brief. Most of the part of Linux kernel is written in C language. So knowledge of C programming helps to understand Kernel program and application.
A file is everything in Linux. When a file is executed, it is understood as a process. Process is created by another process and gets destroyed after being used. Multiple processes can run on Linux system and various commands are specified for management of process. Each process is identified by a unique number called Process-ID (PIDwhich is allocated while the process is created. from the parentPID.If you execute any single command from shell terminal, it also creates a process. Refer the tutorial Process in Linux for more information about process.Here I will explain various process commands which give out the information about running process.
Linux supports both GUI (Graphical User Interface) and CLI (Command Line Interface) environments. GUI is more user friendly for users and it’s easy to point, click and drag without any confusion. You can create folder, file and various operations as per your need and work upon them like window operating system. Traditional UNIX environment supports CLI but not GUI. Command Line Interface is a terminal where you can enter the command to tell computer what to do. You can create file, folder and various operations by entering command in CLI terminal and it is faster and more powerful than GUI. Various Linux distributions make use of similar commands. You need to read various commands before working in Linux with CLI.
Bell Lab laboratories developed advanced OS with highly feature written in C language named UNIX operating system. In 1990, PC were fully powered by UNIX and well featured but not fully open source, then in the year 1991, Linus Torvalds introduced an operating system called Linux which is member of large family UNIX-like OS. Linux is fully customizable free operating system. Due to advent open source feature of Linux, everyone can download the source code of Linux and modify it. It is supported any hardware components. Linux uses only POSIX (Portable Operating System Interface Standards) of UNIX, which is standards specified by IEEE computer society for maintaining compability between OS.
This tutorial explains how to install and run Arduino in Linux distribution such as an Ubuntu. Arduino is already available in the software center of Ubuntu which is one of the repositories of Linux. Ubuntu needs to meet the required dependencies of Arduino. so before installibng Arduino make sure that the dependencies are met.Arduino software is made in java environment and to run the java program, we need to download and install Java run time environment. There is no need of installing java run time if it is already installed in your system.. Since Arduino software already includes java you can install it individually from Ubuntu software center using the following command line from command terminal: Ubuntu needs to meet the required dependencies of Arduino. so before installibng Arduino make sure that the dependencies are met.
Beaglebone Black aka BBB is a low cost open source development board mainly used by developers and lobbyists. Although it’s quite similar to a Raspberry Pi yet it comes with some additional features. Developed by a non-profit corporation beagleboard.org, this credit card sized board also supports embedded Linux platform. Due to the presence of so many advanced peripherals, it is also considered to be a minicomputer.BBB consists of core architecture of ARM family and houses AM35X ARM cortex A8 (1GHz) processor. It can be powered either through a micro USB port or an external 5V supply that is present as an optional arrangement.
Linux kernel supports modular approach. It supports insertion and removal of code from itself at a routine. Module is loadable kernel object which we can load and unload during run time. Module is single binary image which contains the information of related subroutine, group, data, entry and exit. Device driver is also one type of module which provides the facilities to reload, debugging, and loading new driver on demand in response to hot plugging of new device. It is allowed to access hardware connected to the system. We can build monolithic kernel using module kernel and new functionality in kernel image. Let’s understand how module would be created and work in Linux. Module is like a simple file and we can save it as C file with .c extension but it is somewhat different. It does not need to write code inside main function.
Semaphore is a basic synchronization mechanism and it works as a simple counter which increments on resource allocation and decrements on resource de-allocation. You can refer to the tutorial Semaphore before learning this tutorial. I will explain how to create counting semaphore in Linux. Counting semaphore is non-negative counter. Semaphore count initializes with a number of free resources. Counter value is incremented when resources are added and decremented when resources are released. In C language, semaphore parameter and functions are defined in <semaphore.h> header file. Various operations on semaphore are performed by different functions which are defined in semaphore header file. You can initialize semaphore, lock and unlock, release the semaphore etc.
A semaphore is a synchronization mechanism that controls access by multiple processes to a common resource in parallel programming environment. It is widely used to control access to file and shared memory. In computer system it is a variable whose value indicates the status of common resource. Its purpose is to lock resource being used. They are counter used to provide control access to the shared data structure for multiple processes. Operation allocated with semaphore is tested, set and waited. Test and set process is concerned, uninterruptable and can’t be stopped once started. The result of test and wait process is the current value of the semaphore.
In previous tutorial, I explained about communication between server-client through socket programming. We can also establish server-client communication using UDP/IP. In this tutorial I will explain how communication occurs between server-client through UDP/IP. Before explanation, let’s see some basic view of terminology. Three main things are needed to establish connection between server-client models:1) Transport protocol (TCP or UDP)2) Socket3) IP address and port UDP is a connection-less protocol which stands for user datagram protocol. It is an unreliable protocol but with IP it provides the best communication mechanism
TCP is connection oriented protocol which stands for transfer control protocol. It is a reliable and secured protocol. In TCP, receiver can generate the acknowledgement of received packet so sender (client) does need to wait for acknowledgement and if back response doesn’t come or any packet error is generated, it will resend to the client.Socket is end point connection for communication between two machines. It is like data connectivity path between two wireless terminals. Socket is required at both sides of server and client. You can refer to the tutorial socket and How to create socket in Linux.IP address is a unique numerical address of each computer and device. It plays an important role in networking domain with Internet protocol.
This tutorial will explain about how to create socket programming in C language. Socket is virtual end point communication over the network between two hosts or processes. Refer to the tutorial Socket in Linux before learning this tutorial. You always open the Google page in your web browser but do you know how our web browser accesses the Google page form www.google.com? When you type www.google.com in your web browser, it will open the socket and send the request to server (www.google.com). Server always listens to the request from different hosts. When server receives and accepts the request it sends response back to the host (i.e. Local PC). After establishment of connection, server will send the Google page to our web browser.This tutorial assumes you know about socket in Linux and are aware with C programming language. Linux has standard C library of socket in package named <sys/socket.h> header file. Socket creates file descriptor using the socket ( ) system call.
I explained an Interprocess communication (i.e. Pipe, named pipe) between two applications or process in system. You might be wondering if two applications available in different machines over the network (i.e. local PC or server), pipe or named pipe are communicated or not? Pipe or named pipe can communicate only those processes which are located in the same system. We can communicate with application which is located in different systems through new communication method named Socket.
It is similar to a pipe but created in different ways. Here mkfifo ( ) function creates the file in file system. mkfifo ( ) makes a file named pathname. Pathname is the location of FIFO file where it is created. Once you create the file, you can read or write it as defined in mode user permission what user wants to do with FIFO file.The system call mknod ( ) creates file system node as specified pathname with attribute described in mode and dev. Once you have created the file, you can read or write as defined in mode.which seeks user permission as to what user wants to do with FIFO file. dev define the types of file system node (i.e. file, device file, socket, named pipe). The file type must be one of S_IFREG, S_IFCHR, S_IFBLK, S_IFIFO, or S_IFSOCK to specify a regular file, character file, device block file, named pipe and socket respectively.
I already explained about pipe in tutorial Pipe in Linux. FIFO or unnamed pipe is same as pipe or named pipe expect for one thing. Pipe is a one way communication between process which is related to each other like parent and child processes. Related processes have same file descriptor, so they communicate easily through single pipe but unrelated processes have different file descriptors, so they cannot communicate through single pipe. You can communicate only through creating multiple pipes each for one communication. Communication between multiple processes is not sufficient and hence FIFO or named pipe overcomes this limitation.FIFO (First In First Out) is first out file which is like normal file but doesn’t save the content of file, it should pass data, write or read by first in and first out process. When one process is read or written using FIFO, another process waits to access FIFO. So FIFO can also be used for one-way communication between multiple and unrelated processes instead of single and related process.
This tutorial explains how to interface LM35 Temperature sensor with Beaglebone black to work with sensor interfacing. LM35 is an analog sensor which measures the temperature and linear output given in voltage form. I have interfaced temperature sensor LM35 with 12 bit ADC of BBB where output of LM35 is in analog form and output of ADC is in digital value and later is converted in Celsius and Fahrenheit by formula. LM35 is with 3 terminals- Vcc terminal is connected with 3.3 V supply, Ground is connected with ADC ground of BBB (pin number 34th of header P9) and Output terminal is connected to the input of AIN1 (pin number 40th of header P9). Now you can open the command terminal and take an access of Beaglebone black through SSH as explained in getting started with Beaglebone black.
When you execute python script from SSH command prompt, you need to make BBB connection with PC because you are accessing the BBB through SSH connection. If you wish to run Python Script on BeagleBone Black Boot without connecting it with PC, an external power is needed to be supplied. You can run python script when you power up BBB without any command prompt or command by Crontab. Crontab is a task management tool which is built-in into Debian and then we can add the new Cron Job at which a Python script will run at boot. When script is running, both the LEDs are switched ON and OFF for one second.
How to capture images and video on the beaglebone – I do this using Open Source Computer Vision (OpenCV) image processing. OpenCV image processing captures image and video data on the BBB (Beaglebone Black) with the help of USB webcams by using python script programming. It is simple tutorial where you can also add effects in the form of black and white image, motion detection, sharp picture etc. I have used opencv library which programs functions of real time computer and machine learning. In this project required tools are Webcam and Beaglebone Black.
This tutorial explains how to connect Beaglebone with WI-FI adapter for internet connectivity. Before proceeding, we need some basic configuration as well as an internet connection. First connect the internet through Ethernet. Complete step-by-step guide to get WiFi running for your BeagleBone Black to manually configure the adapter to automatically connect with your network. Before you get started make sure that you are running the latest official Debian image on BeagleBone Black. Here, I have used EDMAX which works with almost any kind of WI FI adapter.
This tutorial explains about the fundamental use of PWM where servo motor is controlled by potentiometer. It is a DC motor which operates on electrical pulse. You can directly interface servo motor with Beaglebone black without any driver IC. For this you have to write a program in python script with adafruit PWM and ADC library.It is a simple learning tutorial in which I have interfaced servo motor and potentiometer with Beaglebone black. When script is being executed, it enters into a continuous loop.