Saturday, 31 May 2014

HDMI (High-Definition Multimedia Interface)

HDMI (High-Definition Multimedia Interface) is a compact audio/video interface for transferring uncompressed video data and compressed or uncompressed digital audio data from a HDMI-compliant source device to a compatible computer monitorvideo projectordigital television, or digital audiodevice.[1] HDMI is a digital replacement for existing analog video standards. 
HDMI implements the EIA/CEA-861 standards, which define video formats and waveforms, transport of compressed, uncompressed, and LPCM audio, auxiliary data, and implementations of the VESA EDID.[2][3] CEA-861 signals carried by HDMI are electrically compatible with the CEA-861 signals used by the digital visual interface (DVI). No signal conversion is necessary, nor is there a loss of video quality when a DVI-to-HDMI adapter is used.[4] The CEC (Consumer Electronics Control) capability allows HDMI devices to control each other when necessary and allows the user to operate multiple devices with one remote control handset.[5]
Several versions of HDMI have been developed and deployed since initial release of the technology but all use the same cable and connector. Newer versions optionally support advanced features such as 3D, an Ethernet data connection and improved audio and video capacity, performance and resolution.

DOWNLOAD POWER POINT PRESENTATION OF HDMI


GPU With CUDA Architecture


hello all,

you can download Powerpoint presentation of this topics from bellow link.


https://drive.google.com/file/d/0B-V3GbGzucNNOEtBYVJ0UE5PV2s/edit?usp=sharing

thanks

SOCKET PROGRAMMING FOR SINGLE USER-MULTI CLIENT IN C LANGUAGE

THIS PROGRAM FOR SINGLE SERVER-MULTI CLIENT IN SAME NETWORK.IF YOU WANT TO MAKE THIS CODE FOR DIFFERENT SYSTEM THEN YOU NEED TO CHANGE IP ADDRESS OF ACCORDING TO SERVER'S IP ADDRESS 

SERVER PROGRAM


#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

int main()
{
int sockfd,confd,n,clilen;
char buff[256];

struct sockaddr_in server, client;

sockfd =socket(AF_INET,SOCK_STREAM,0);
printf("Socket OK.\n");

server.sin_family = AF_INET;
server.sin_port = htons(9000);
server.sin_addr.s_addr = inet_addr("127.0.0.1");
bind(sockfd,(struct sockaddr*)&server,sizeof(server));
printf("Bind OK.\n");

listen(sockfd,4);
printf("Listening OK.\n\n");
   
    clilen=sizeof(client);
//confd=accept(sockfd,(struct sockaddr*)&client,&clilen);
//printf("Accept OK.\n");
   
while(1)
{
confd=accept(sockfd,(struct sockaddr*)&client,&clilen);
printf("Accept OK.\n");

printf("Waiting for Client's Message.\n");
bzero(buff,256);
n = read(confd,buff,256);
if(buff[0]=='q')
{
close(confd);
break;
}
printf("CLIENT : %s",buff);
n = write(confd,"Message Received.",17);
}
close(sockfd);
}


CLIENT PROGRAM

/********************************************************************************/
/* Title :: Client Socket Programm */
/* */
/* This is CLIENT program */
/* */
/* Auther : Kaneria Dhaval */
/* */
/* Usage : ~$ gcc -w -o client client.c */
/* ./client */
/* */
/********************************************************************************/

#include<sys/socket.h>

#include<sys/types.h>

#include<netinet/in.h>

#include<stdlib.h>

#include<stdio.h>

#include<string.h>

int main(){

int sockfd,confd,n,len;

char  buff[256];

struct sockaddr_in server,client;

len = sizeof(struct sockaddr_in);

sockfd = socket(AF_INET, SOCK_STREAM, 0);

printf("Socket OK.\n");

server.sin_family = AF_INET;

server.sin_port = htons(9000);

server.sin_addr.s_addr = inet_addr("127.0.0.1");

confd=connect(sockfd,(struct sockaddr*)&server,sizeof(server));

printf("Connection OK.\n");

while(1)

{

printf("\nMessage : ");

fgets(buff,256,stdin);

n=write(sockfd,buff,strlen(buff));

printf("> Message Sent.\n");

if(buff[0]=='q')

{

close(confd);

break;

}
bzero(buff,sizeof(buff));
n=read(sockfd,buff,sizeof(buff));

printf("Server : %s",buff);

}

close(sockfd);

return 0;

}

SOCKET PROGRAMMING BASIC





Friday, 23 May 2014

What is USB (Universal Serial Bus)?

CONCEPT OF PIPES & END POINT
 The ports are used to connect the peripheral devices like mouse, keyboards, or audio devices to them. Each device is given a specific address used during the communication process by the host.  These devices are connected to the root hub and in turn to the host by pipes.  A pipe is a logical connection between the host and end point and is used by client software to transfer data. It sets various parameters such as direction of data flow, length of bandwidth allocated to the device and what kind of transfer will take place. There are two types of pipes in USB one is stream pipe and other is message pipe.
·       Stream Pipes- It is unidirectional communication pipes used for most of the data transfers. These pipes have no defined USB format. We can send any type of data from one end and retrieve it from another end. Data flows sequentially and has a pre-defined direction either IN or OUT. Stream pipes support bulk, isochronous and interrupt type of transfers and controlled by either host or device.

·       Message Pipes- It is bi-directional communication pipes and only used for sending/receiving short messages. These pipes have defined USB format. They are host controlled initiated by request sent from the host. Data is transferred in the desired direction as per the request. They support only control transfers.
Once we have understood the pipes we learn about various types of data transfers. Depending on the type of data we need to decide which type of pipe to use.
 There are four different types of data transfer in USB.

1.Control Transfer- It is used to send commands to the devices for making enquiries. This transfer uses Message pipes.
2. Interrupt Transfers- It is used to send small amount of data that requires a guaranteed minimum time delay. It uses Stream pipes.
3.Bulk Transfer- It is used for transferring large amount of data with no time guarantee and uses Stream pipes
4. Isochronous Transfers- it is used for transferring data that requires a fixed delivery rate as they are capable of fixed bus bandwidth and lack of error correction. Since there is no error correction there is no delay in transfer of data. These transfers use Stream pipes.


In between the device and host there is addressable buffer which is known as endpoint. An endpoint is an electrical terminal usually consists of a set of memory registers that stores the data temporarily in USB peripheral devices on their way in or out. An endpoint stores received data from the host and holds the data to be transmitted to the host. A USB device can have multiple endpoints and each endpoint has a pipe associated with it. Each endpoint is accessed with a device address assigned by the host and an endpoint number that is assigned by the device. Endpoints usually come in pairs, e.g. Endpoint 1 In and Endpoint 1 Out. One set of Endpoints, Endpoint 0 In and Endpoint 0 Out is always turned on which is used for basic commands to all USB devices.
Enumeration Step.
1.The user plugs the device into a USB port.
2.The hub detects the device.
3.The host learns of the devices presence from the hub (Get Port Status Request)
4.The hub detects whether a device is Low speed or Full Speed.
5.The hub resets the device.
6.The host learns if a full speed device supports high speed.
7.The hub establishes a signal path between the device and the bus.
8.The host sends a Get Descriptor Request to learn the maximum packet size of the default pipe.
9.The host assigns an address (Set Address Request).
10.The host learn about a devices abilities (Get Descriptor Request).
11.The host assigns and loads a device driver.
12.The host’s device driver selects a configuration (Set Configuration Request).

Thursday, 22 May 2014

Architecture of Open Hardware for Rapid prototyping: for Raspberry PI, BeagleBone Black & Arduino Tre

Hello All,

You can download ppt of Architecture of Open Hardware for Rapid prototyping:for Raspberry PI,
BeagleBone Black & Arduino Tre

You can find various specification of all hardware.

Link For Download

Sunday, 18 May 2014

Character device driver using semaphore mechanism in linux

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/major.h>
#include <linux/capability.h>
#include <asm/uaccess.h>
#include <linux/cdev.h>
#include <linux/sem.h>
#include <linux/vmalloc.h>
#include <linux/ipc.h>
#include <linux/delay.h>
#include <linux/semaphore.h>

int i,shmid;
char a[10]=0;
struct semaphore lock;

static ssize_t sample_char_read(struct file * file, char __user * buf,size_t count, loff_t *ppos)
{
 printk("sample_char2_read size(%ld)\n", count);
 return 0;
}

static ssize_t sample_char_write(struct file *filp, const char *buf,size_t size, loff_t *offp)
{
 ///semaphore locking
 down(&lock);
 printk("sample_char_write size(%ld)\n", size);
 copy_from_user((void *) a,buf,size);
 printk("kernal=%s\n",a);
 msleep(5000);
 //semaphor unlock
 up(&lock);
 return size;
}

int sample_char_open(struct inode *inode, struct file *filp)
{
 printk("sample_char_open\n");
 //semaphore init
 sema_init(&lock, 1);
 return 0;
}

int sample_char_release(struct inode *inode, struct file *filp)
{
 printk("sample_char_release\n");
 return 0;
}

static struct file_operations sample_char_fops = {
 read:sample_char_read,
 write:sample_char_write,
 open:sample_char_open,
 release:sample_char_release,
};

#define sample_major_number 89
#define max_minors 1
static struct cdev char_cdev;
static dev_t dev;

int init_module(void)
{
 int ret = 0;
 dev = MKDEV(sample_major_number, 0);
 printk("\nLoading the sample char device driver\n");
 ret = register_chrdev_region(dev,1, "sample_char");
 if (ret)
 {
  printk("register_chrdev_region Error\n");
  goto error;
 }

 cdev_init(&char_cdev, &sample_char_fops);
 ret = cdev_add(&char_cdev, dev,2);
 if (ret) {
  printk("cdev_add Error\n");
  goto error_region;
 }

 return 0;
 error_region:
 unregister_chrdev_region(dev, max_minors);
 error:
 return ret;
}

void cleanup_module(void)
{
 cdev_del(&char_cdev);
 unregister_chrdev_region(dev, max_minors);
 printk("\nUnloading the sample char device driver\n");
}


TEST FILE


#include<stdio.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>

int main(int argc ,char *argv[])
{
 char buf[100] ;
 char i = 0;
 int g;
 memset(buf, 0, 100);
 printf("Input: %s\n", argv[1]);

 int fp = open("/dev/sample_char", O_RDWR);
 if(fp<0)
 {
  perror("not sucess");
 }

 i=fork();

 if(i==0)
 {
  g=write(fp,argv[1], strlen(argv[1]));
 }
 else
 {
  g=write(fp,argv[2], strlen(argv[2]));
  wait(0);
 }
}

MAKE FILE

obj-m += semaphore.o
all:
 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
test:app.c

COMPILATION OF CODE

gcc -o test app.c

character device driver using MUTEX in linux

MUTEX DRIVER

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/major.h>
#include <linux/capability.h>
#include <asm/uaccess.h>
#include <linux/cdev.h>
#include <linux/vmalloc.h>
#include <linux/ipc.h>
#include <linux/delay.h>
#include <linux/mutex.h>

int i,shmid;
char *a;
struct mutex lock;

static ssize_t sample_char_read(struct file * file, char __user * buf,size_t count, loff_t *ppos)
{
 printk("sample_char2_read size(%ld)\n", count);
 return 0;
}

static ssize_t sample_char_write(struct file *filp, const char *buf,size_t size, loff_t *offp)
{
 //mutex lock
 mutex_lock(&lock);
 printk("sample_char_write size(%ld)\n", size);
 copy_from_user((void *)a,buf,size);
 printk("%s\n",a);
 msleep(3000);
 //mutex unlock
 mutex_unlock(&lock);
 return size;
}

int sample_char_open(struct inode *inode, struct file *filp)
{
 printk("sample_char_open\n");
 //mutex initialization
 mutex_init(&lock);
 a=(void *)vmalloc(20*sizeof(char));
 return 0;
}

int sample_char_release(struct inode *inode, struct file *filp)
{
 printk("sample_char_release\n");
 return 0;
}

static struct file_operations sample_char_fops = {
 read:
 sample_char_read,
 write:
 sample_char_write,
 open:
 sample_char_open,
 release:
 sample_char_release,
};

#define sample_major_number 89
#define max_minors 1

static struct cdev char_cdev;
static dev_t dev;

int init_module(void)
{
 int ret = 0;
 dev = MKDEV(sample_major_number, 0);
 printk("\nLoading the sample char device driver\n");

 ret = register_chrdev_region(dev,1, "sample_char");
 if (ret)
 {
  printk("register_chrdev_region Error\n");
  goto error;
 }

 cdev_init(&char_cdev, &sample_char_fops);
 ret = cdev_add(&char_cdev, dev,2);

 if (ret) {
  printk("cdev_add Error\n");
  goto error_region;
 }

 return 0;
 error_region:
 unregister_chrdev_region(dev, max_minors);
 error:
 return ret;
}

void cleanup_module(void)
{
 cdev_del(&char_cdev);
 unregister_chrdev_region(dev, max_minors);
 printk("\nUnloading the sample char device driver\n");
}


APPLICATION FILE


#include<stdio.h>
#include <fcntl.h>
#include <assert.h>
#include <string.h> // for memset and strlen
#include<sys/types.h>
#include<sys/stat.h>

int main(int argc ,char *argv[])
{
 //
 assert(argc > 1);//abort program if assertion is false
 char buf[100] ;
 char i = 0;
 int g;
 memset(buf, 0, 100);
 printf("Input: %s\n", argv[1]);

 int fp = open("/dev/sample_mutex", O_RDWR);
 if(fp<0)
 {
  perror("not sucess");
 }

 i=fork();
 if(i==0)
 {
  g=write(fp,argv[1], strlen(argv[1]));
 }
 else
 {
  g=write(fp,argv[2], strlen(argv[2]));
  wait(0);
 }
}

Sleeping mechanism in character driver in linux

#include <linux/module.h>
#include <linux/fs.h>  //various structures(fops)
#include <linux/major.h>
#include <linux/capability.h>
#include <asm/uaccess.h> //copy_to/from_user()
#include <linux/cdev.h>  //cdev
#include <linux/wait.h>  //wait queues
#include <linux/sched.h> //Task states (TASK_INTERRUPTIBLE etc)

wait_queue_head_t queue;
int flag = 0;

static ssize_t sample_char_read(struct file * file, char __user * buf,size_t count, loff_t *ppos)
{
  flag = 0;
  wait_event_interruptible(queue, flag == 1);
  printk("sample_char_read size(%ld)\n", count);
 return 0;
}

static ssize_t sample_char_write(struct file *filp, const char *buf,size_t size, loff_t *offp)
{
  flag = 1;
  wake_up_interruptible(&queue);
  printk("sample_char_write size(%ld)\n", size);
        return size;

}

int sample_char_open(struct inode *inode, struct file *filp)
{
       printk("sample_char_open\n");
       return 0;
}

int sample_char_release(struct inode *inode, struct file *filp)
{

       printk("sample_char_release\n");
       return 0;
}

static struct file_operations sample_char_fops =
{
       .read=          sample_char_read,
       .write=          sample_char_write,
       .open=          sample_char_open,
       .release=        sample_char_release,
};

#define sample_major_number 249
#define max_minors 1

static struct cdev char_cdev;
static dev_t dev;

int init_module(void)
{
  int ret = 0;

  dev = MKDEV(sample_major_number, 0);
  printk("\nLoading the sample char device driver\n");

  ret = register_chrdev_region(dev, max_minors, "sample_char");
  if (ret)
   {
     printk("register_chrdev_region Error\n");
   goto error;
   }
  cdev_init(&char_cdev, &sample_char_fops);
  ret = cdev_add(&char_cdev, dev, max_minors);
  if (ret) {
     printk("cdev_add Error\n");
          goto error_region;
  }

  init_waitqueue_head(&queue);
  return 0;

 error_region:
  unregister_chrdev_region(dev, max_minors);
 error:
  return ret;
}

void cleanup_module(void)
{
  cdev_del(&char_cdev);
        unregister_chrdev_region(dev, max_minors);
        printk("\nUnloading the sample char device driver\n");

}