Tuesday, 12 November 2013

configuring the gpio pin

//configure the pins and convert the source file to object file


#!/bin/bash

dtc -O dtb -o uart1-00A0.dtbo -b 0 -@ uart1.dts
cp uart1-00A0.dtbo /lib/firmware/uart1-00A0.dtbo
echo uart1 > /sys/devices/bone_capemgr.9/slots

GSM EXAMPLE WITH BEAGLEBONE BLACK

beaglebone black gsm program for sending the message

Using this program we can send the message to the specified person using gsm module which is connected to the beaglebone black



//# dtc -O dtb -o uart1-00A0.dtbo -b 0 -@ uart1.dts
//# cp uart1-00A0.dtbo /lib/firmware/uart1-00A0.dtbo
//# echo uart1 > /sys/devices/bone_capemgr.8/slots
//Modified by ABHISHEK GOWDA

#include <stdio.h> // standard input / output functions
#include <string.h> // string function definitions
#include <unistd.h> // UNIX standard function definitions
#include <fcntl.h> // File control definitions
#include <errno.h> // Error number definitions
#include <termios.h> // POSIX terminal control definitionss
#include <time.h>   // time calls

int open_port(void)
{
int fd; /* File descriptor for the port */
    fd = open("/dev/ttyO1", O_RDWR | O_NOCTTY | O_NDELAY );//open the tty01 folder in readwrite and nodelay
    //fd = open("/dev/ttyAMA0", O_RDWR | O_NOCTTY | O_SYNC);
    printf("text openport\n");
if (fd == -1)
{
/* Could not open the port. */
perror("open_port: Unable to open /dev/ttyO1");//throw error
}
else
{
  fcntl(fd, F_SETFL, 0);//set the flag to 0 for file descriptor
  printf("Port1 has been succesfully opened.\n");
}
return(fd);

} //open_port

int configure_port(int fd)      // configure the port
{
struct termios port_settings;      // structure to store the port settings in

cfsetispeed(&port_settings, B9600);    // set baud rates
cfsetospeed(&port_settings, B9600);

port_settings.c_cflag &= ~PARENB;    // set no parity, stop bits, data bits
port_settings.c_cflag &= ~CSTOPB;  
port_settings.c_cflag &= ~CSIZE;
port_settings.c_cflag |= CS8;
tcsetattr(fd, TCSANOW, &port_settings);    // apply the settings to the port
printf("text configport\n");
return(fd);

}

int query_modem(int fd)   // query modem with an AT command
{
int m,n,d,e;
//char buff[100];

//n=read(fd,buff,100);
//printf("Result %i\n",n);
//printf("Buf = %s\n\n\n", buff);
//sleep(1);
//memset(buff, 0, 100);
printf("AT+CMGF=1\r\n");
d = write(fd, "AT+CMGF=1\r\n", 11);
if (d < 0)
fputs("write() of 4 bytes failed!\n", stderr);
else
printf("write succeed n0 %i\n",d);

sleep(2);
//d=read(fd, buff, 100);
//printf("Buf = %s\n\n\n", buff);
//memset(buff, 0, 100);

printf("AT+CMGS=\"9019354797\"\r\n"); // \r and \n CR n LF
e = write(fd, "AT+CMGS=\"9019354797\"\rhello,hi from aj group\n\x1A", 30);

if (e < 0)
fputs("write() of 4 bytes failed!\n", stderr);
else
printf("write succeed n0 %i\n",e);
sleep(8);
//e=read(fd, buff, 100);
//printf("Buf = %s\n\n\n", buff);

return (fd);
}


int close_port(int fd)
{
close(fd);
printf("text close port\n");
}
int main(void)
{
int fd = open_port();
sleep(5);
configure_port(fd);
query_modem(fd);
close_port(fd);
return(0);
} //main

DEVICE TREE STRUCTURE(.dts file)USING PINMUX FOR BEAGLEBONE BLACK


THE PINMUX SETTING,BEAGLEBONE BLACK MODE AND PIN NO SELECTION CAN BE DONE  WHICH WILL BE LATER CONVERTED TO THE OBJECT FILE USING THIS SOURCE FILE.SO BASED ON THE REQUIREMENT IN UR PROJECT YOU USE THE PINS.AND RUN THE CODE IN TERMINAL WHICH SHOULD BE SAVED IN .dts EXTENTION,HERE IN DOWN WE USED IT FOR THE LED GLOWING A SIMPLE PROGRAM WE USED ONLY 5 GPIO PINS THOSE ARE GPIO15,GPIO45.GPIO60,GPIO44 AND GPIO23.



/*

* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Purpose License Version 2 as
* published by the Free Software Foundation
*
* Original from: github.com/jadonk/validation-scripts/blob/master/test-capemgr/
*
* Modified by ABHISHEK GOWDA for the example 
* that maps GPIO pins for the example(HERE WE WILL BE USING THE REQUIRED PIN WITH GIVING THE INPUT MODE AND THE PIN NO)
*/

/dts-v1/;

/plugin/;

/{

       compatible = "ti,beaglebone", "ti,beaglebone-black";
       part-number = "DM-GPIO-Test";
       version = "00A0";

       fragment@0 {

             target = <&am33xx_pinmux>;
            
             __overlay__ {
                  pinctrl_test: DM_GPIO_Test_Pins {
pinctrl-single,pins = <


//the required pin address can be given here which u gonna use in ur project


0x078 0x07 /* P9_12 60 OUTPUT MODE7 - The LED Output */

0x184 0x07 /* P9_24 15 INPUT MODE7 none - The Button Input */
0x034 0x07 /* P8_11 45 INPUT MODE7 (37)pullup - Yellow Wire */
0x030 0x27 /* P8_12 44 INPUT MODE7 (27)pulldown - Green Wire */
0x024 0x2f /* P8_13 23 INPUT MODE7 (2f)none - White Wire */
                       
                              
>;
};
             };
       };

       fragment@1 {

target = <&ocp>;
__overlay__ {
test_helper: helper {
compatible = "bone-pinmux-helper";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_test>;
status = "okay";
};
};
};
};

EXPORTING GPIO PINS OF BEAGLEBONE BLACK


How to Use the GPIO Pins

Access to the various pins in the headers on the left and right side of the BBB is done through the Linux kernel using its GPIO Interfaces.

echo 60 > /sys/class/gpio/export      

//now to set the gpio pin we are exporting it,here we are using gpio60

echo "out" > /sys/class/gpio/gpio60/direction    

//give out direction for the gpio60th pin(it will be the pin whr we can see the output).

echo 1 > /sys/class/gpio/gpio60/value          

//now what to show in the gpio60?? so to give output we need to store that in value directory here we are giving a high value (ie 1).

CONFIGURING GPIO PINS AND SLOTS OF BEAGLEBONE BLACK.

we know the basics of beaglebone black now its time to know how to configure the beaglebone black so lets start
will write a shellscript for configuring


#!/bin/bash
 
                //It's a convention so the *nix shell knows what kind of interpreter to run.(It's called                            shebang. In unix-speak, # is called sharp (like in music) or hash (like hashtags on twitter), and ! is called bang.)

echo "adc pin initialise"

//print(echo as adc pin initialise)

echo cape-bone-iio > /sys/devices/bone_capemgr.9/slots

//we r giving slots extention to cape-bone-iio with the help of its directory under bone_capemgr.9(no can be 8 or 9)

echo "export slots"

//in terminal again print exporting slots using echo command

export SLOTS=/sys/devices/bone_capemgr.9/slots

//export the slots of the beaglebone by giving export command with directory direction of slots

echo "export pins"

//print as export pins on the terminal while executing this bash script

export PINS=/sys/kernel/debug/pinctrl/44e10800.pinmux/pins

//now export the pins of the beaglebone black using pinmux(which gives the mode of the pin)


echo "Compiling the overlay from .dts to .dtbo"   //print the text

dtc -O dtb -o DM-GPIO-Test-00A0.dtbo -b 0 -@ DM-GPIO-Test.dts

// device tree overlay convert the device tree source file into object file with specified extentions

echo "copy the file"   //print the text

cp DM-GPIO-Test-00A0.dtbo /lib/firmware/  

//now converted .dtbo file form .dts should be saved in firmware directory under lib,copy that into firmware


echo "echo the file to slots"     //print the text

echo DM-GPIO-Test > $SLOTS

//redirect gpio file to slot with sucession case using $!!

echo "export the pin"    //print the text using echo

How to Use the GPIO Pins

Access to the various pins in the headers on the left and right side of the BBB is done through the Linux kernel using its GPIO Interfaces.

echo 60 > /sys/class/gpio/export      

//now to set the gpio pin we are exporting it,here we are using gpio60  

echo "out" > /sys/class/gpio/gpio60/direction      

//give out direction for the gpio60th pin(it will be the pin whr we can see the output).

echo 1 > /sys/class/gpio/gpio60/value          

//now what to show in the gpio60?? so to give output we need to store that in value directory here we are giving a high value (ie 1).

Wednesday, 6 November 2013

how to open .pub file in linux | ubuntu

if u want to use software u can install this and can try out.write and hit enter in your terminal window!

sudo apt-get install scribus

hope now u r ready to go....

linux is not windows! so you can convert it into a pdf format or a doc format just by using this online site.try out
http://www.zamzar.com/
also by using this site u can convert the format,you  can download the video from the internet just by giving the url. Sending and managing of file also can be done