EmbLogic's Blog

communication between client and server using socket in AF_INET domain

RCS file: ./server.c,v
Working file: ./server.c
head: 1.6
branch:
locks: strict
root: 1.6
access list:
symbolic names:
keyword substitution: kv
total revisions: 6; selected revisions: 6
description:
added all the header files that will be used in the code
—————————-
revision 1.6 locked by: root;
date: 2014/11/07 18:52:45; author: root; state: Exp; lines: +1 -1
now the client writes and the server reads
and print it
—————————-
revision 1.5
date: 2014/11/07 18:51:27; author: root; state: Exp; lines: +1 -1
the server gives the connect request
the server accepts the client request
—————————-
revision 1.4
date: 2014/11/07 18:50:46; author: root; state: Exp; lines: +1 -1
the server listens for the connest request from the client
—————————-
revision 1.3
date: 2014/11/07 18:49:18; author: root; state: Exp; lines: +1 -1
binding the socket address,fd,and the size of socket address
—————————-
revision 1.2
date: 2014/11/07 18:45:53; author: root; state: Exp; lines: +46 -0
unlinkiked the socket path
gave the condition for error
—————————-
revision 1.1
date: 2014/11/07 18:45:27; author: root; state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

creating socket between client and the server in unix

RCS file: ./server.c,v
Working file: ./server.c
head: 1.7
branch:
locks: strict
root: 1.7
access list:
symbolic names:
keyword substitution: kv
total revisions: 7; selected revisions: 7
description:
included all the header files that will be used in the code
—————————-
revision 1.7 locked by: root;
date: 2014/11/07 18:32:31; author: root; state: Exp; lines: +1 -1
closed the socket fd and the client socket fd
—————————-
revision 1.6
date: 2014/11/07 18:31:18; author: root; state: Exp; lines: +1 -1
now the client writes to the server and the server reads and vice-versa
—————————-
revision 1.5
date: 2014/11/07 18:28:36; author: root; state: Exp; lines: +1 -1
before connecting and accepting thfrom the client
—————————-
revision 1.4
date: 2014/11/07 18:26:58; author: root; state: Exp; lines: +1 -1
giving the connect request from the client
accepting the client request in the server
—————————-
revision 1.3
date: 2014/11/07 18:25:39; author: root; state: Exp; lines: +1 -1
binding the servr socket fd,server address and the server length
—————————-
revision 1.2
date: 2014/11/07 18:22:23; author: root; state: Exp; lines: +1 -1
unlinking the server socket
established a connection between server and the client
—————————-
revision 1.1
date: 2014/11/07 18:15:46; author: root; state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

Communication between client and server through socket with Domain-AF_INET

RCS file: RCS/server.c,v
Working file: server.c
head: 1.6
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
main server file
Include socket.h and types.h
—————————-
revision 1.6
date: 2014/11/06 05:25:09;  author: root;  state: Exp;  lines: +10 -7
make server in while 1
—————————-
revision 1.5
date: 2014/11/05 07:16:21;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2014/11/04 12:11:14;  author: root;  state: Exp;  lines: +1 -0
server write after reading from client
—————————-
revision 1.3
date: 2014/11/04 12:02:06;  author: root;  state: Exp;  lines: +1 -0
use perror after listen call
—————————-
revision 1.2
date: 2014/11/04 12:00:45;  author: root;  state: Exp;  lines: +32 -1
done
—————————-
revision 1.1
date: 2014/11/04 10:35:37;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: RCS/client.c,v
Working file: client.c
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
1st client file
include header file
—————————-
revision 1.4
date: 2014/11/06 05:25:29;  author: root;  state: Exp;  lines: +11 -5
usr will enter the data to send
“close” will terminate the communication
—————————-
revision 1.3
date: 2014/11/04 12:11:33;  author: root;  state: Exp;  lines: +3 -0
client read after writing
—————————-
revision 1.2
date: 2014/11/04 12:00:54;  author: root;  state: Exp;  lines: +16 -1
done
—————————-
revision 1.1
date: 2014/11/04 10:36:10;  author: root;  state: Exp;
Initial revision

Posted in Project 04: FTP based Client Server using Threads and Sockets, Uncategorized | Leave a comment

MDC

RCS file: mdc_new.c,v
Working file: mdc_new.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
created the master array of the string.
string accepted from user.
—————————-
revision 1.3 locked by: root;
date: 2014/11/07 11:36:23; author: root; state: Exp; lines: +96 -37
decompression completed for 4 bit compressed data
finally decompressd string printed
—————————-
revision 1.2
date: 2014/11/07 11:12:07; author: root; state: Exp; lines: +42 -0
compressed the string() using 4bit compression technique
—————————-
revision 1.1
date: 2014/11/07 10:59:17; author: root; state: Exp;
Initial revision
=============================================================================

Posted in Uncategorized | Leave a comment

client-server communication using PIPES

server.c:

#include"header1.h"

int main()
{
    pid_t pid_c,pid_p;
    int fd_c[2],fd_p[2],counter=0,pipec_success,pipep_success,stat_val,res;
    char fd_cr[2],fd_cw[2],fd_pr[2],fd_pw[2],*path;
    struct data_format data;

    path = malloc(sizeof(char)*50);

    while(counter < 3)
    {
        pipec_success = pipe(fd_c);
        if(pipec_success != 0)
        {
            perror("Pipe client:");
            return -1;
        }

        sprintf(fd_cr,"%d",fd_c[0]);
        sprintf(fd_cw,"%d",fd_c[1]);

        printf("Enter path\n");
        gets(path);
        pid_c = fork();

        if(pid_c == 0)
        {
            execl(path,fd_cw,"input",NULL);
        }

        if(pid_c != 0)
            wait(&stat_val);

        read(fd_c[0],&data,sizeof(data));
        //printf("read data is %d %d %c",data.num1,data.num2,data.operation);
        pipep_success = pipe(fd_p);
        if(pipep_success != 0)
        {
            perror("Pipe process:");
            return -1;
        }

        write(fd_p[1],&data,sizeof(data));

        sprintf(fd_pr,"%d",fd_p[0]);
        sprintf(fd_pw,"%d",fd_p[1]);

        switch (data.operation)
        {
            case '+':
                pid_p = fork();

                if(pid_p == 0)
                {
                    execl("/home/ritu/emblogic/project_3/adder",fd_pr,fd_pw,NULL);
                }

                if(pid_p != 0)
                wait(&stat_val);
                break;
            case '-':
                pid_p = fork();

                if(pid_p == 0)
                {
                    execl("/home/ritu/emblogic/project_3/subtractor",fd_pr,fd_pw,NULL);
                }

                if(pid_p != 0)
                    wait(&stat_val);
                break;
            case '*':
                 pid_p = fork();

                if(pid_p == 0)
                {
                    execl("/home/ritu/emblogic/project_3/multiplier",fd_pr,fd_pw,NULL);
                }

                if(pid_p != 0)
                    wait(&stat_val);
                break;
        }

        read(fd_p[0],&res,sizeof(res));
        write(fd_c[1],&res,sizeof(res));
        pid_c = fork();
        if(pid_c == 0)
        {
            execl(path,fd_cr,fd_cw,"output",NULL);
        }

        if(pid_c != 0)
            wait(&stat_val);

        counter++;
    }
    return 0;
}
Posted in Project 03: Client Server Communication using Linux and IPC | Leave a comment

message queue

Message queue is the inter process technique in which two or more unrelated process can communicate using that queue. In message queue we send a message number associated with particular client/process along with our data and at the server end data associated with a particular client can be received, recognised by that message numbe and further prcessed(according to client request).

As for each client there is different message no. so in case of message queue technique there is no need of synchronization the clients.

Posted in Project 03: Client Server Communication using Linux and IPC | Leave a comment

VOIP terminology: Digital Audio Broadcasting interaction channel specification for GSM

Screenshot-5

The GSM network may be complemented with another network to reach to the service provider(commonly called PSTN/ISDN). In order to allow access to the GSM network, the user terminal shall be provided with a GSM Interaction Module(IM) referred to as a Mobile Station(MS).

The Interface between the GSM network and MS shall be compliant with the standard requirements on general on Terminal Adaptation Function(TAF) for Mobile Station(MS) as reported in ETS 300 582[12].

 

 

 

Posted in Uncategorized | Leave a comment

complete ipc project using pipes

RCS file: ./server.c,v
Working file: ./server.c
head: 1.10
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 10; selected revisions: 10
description:
gave all the header files that will be used in the programs
created a struct data for variables that will be used in writing code
—————————-
revision 1.10
date: 2014/11/07 08:02:43; author: root; state: Exp; lines: +1 -1
now doing this for all the other three requests
—————————-
revision 1.9
date: 2014/11/07 08:00:24; author: root; state: Exp; lines: +1 -1
after receieving the data from the process
forwarding it to the client side
and displaying the result
—————————-
revision 1.8
date: 2014/11/07 07:56:16; author: root; state: Exp; lines: +1 -1
did the processing of numbers in the process side
wrote back the result to the server
—————————-
revision 1.7
date: 2014/11/07 07:52:31; author: root; state: Exp; lines: +1 -1
converted the file descriptors for read and write into integer
and in the process side again converted those file descriptors into characters
—————————-
revision 1.6
date: 2014/11/07 07:51:05; author: root; state: Exp; lines: +1 -1
created a pipe between the server and the process
—————————-
revision 1.5
date: 2014/11/07 07:48:23; author: root; state: Exp; lines: +1 -1
now after creating the child process and creating link between the server and the client,in the parent processreceieved the request from the requestin—————————-
revision 1.4
date: 2014/11/07 07:45:36; author: root; state: Exp; lines: +1 -1
wrote the data to the server for further processing
—————————-
revision 1.3
date: 2014/11/07 07:41:37; author: root; state: Exp; lines: +1 -0
in the request side again changed the file descriptors into integer receieved by the argument vector
—————————-
revision 1.2
date: 2014/11/07 07:38:04; author: root; state: Exp; lines: +0 -1
created a file between server and request
changed the file descriptors for read and write into characters
—————————-
revision 1.1
date: 2014/11/07 07:33:38; author: root; state: Exp;
Initial revision

Posted in Uncategorized | Leave a comment

communication between client and server(Both on different system) through socket with Domain-AF_INET

RCS file: RCS/server.c,v
Working file: server.c
head: 1.6
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 6;    selected revisions: 6
description:
main server file
Include socket.h and types.h
—————————-
revision 1.6
date: 2014/11/06 05:25:09;  author: root;  state: Exp;  lines: +10 -7
make server in while 1
—————————-
revision 1.5
date: 2014/11/05 07:16:21;  author: root;  state: Exp;  lines: +1 -1
*** empty log message ***
—————————-
revision 1.4
date: 2014/11/04 12:11:14;  author: root;  state: Exp;  lines: +1 -0
server write after reading from client
—————————-
revision 1.3
date: 2014/11/04 12:02:06;  author: root;  state: Exp;  lines: +1 -0
use perror after listen call
—————————-
revision 1.2
date: 2014/11/04 12:00:45;  author: root;  state: Exp;  lines: +32 -1
done
—————————-
revision 1.1
date: 2014/11/04 10:35:37;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: RCS/client.c,v
Working file: client.c
head: 1.4
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 4;    selected revisions: 4
description:
1st client file
include header file
—————————-
revision 1.4
date: 2014/11/06 05:25:29;  author: root;  state: Exp;  lines: +11 -5
usr will enter the data to send
“close” will terminate the communication
—————————-
revision 1.3
date: 2014/11/04 12:11:33;  author: root;  state: Exp;  lines: +3 -0
client read after writing
—————————-
revision 1.2
date: 2014/11/04 12:00:54;  author: root;  state: Exp;  lines: +16 -1
done
—————————-
revision 1.1
date: 2014/11/04 10:36:10;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Project 04: FTP based Client Server using Threads and Sockets | Tagged , , | Leave a comment

Done: client-server using AF_INET on the same system using loopback

RCS file: RCS/server.c,v
Working file: server.c
head: 1.3
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 3;    selected revisions: 3
description:
main server file
Include socket.h and types.h
—————————-
revision 1.3
date: 2014/11/04 12:02:06;  author: root;  state: Exp;  lines: +1 -0
use perror after listen call
—————————-
revision 1.2
date: 2014/11/04 12:00:45;  author: root;  state: Exp;  lines: +32 -1
done
—————————-
revision 1.1
date: 2014/11/04 10:35:37;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: RCS/client.c,v
Working file: client.c
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;    selected revisions: 2
description:
1st client file
include header file
—————————-
revision 1.2
date: 2014/11/04 12:00:54;  author: root;  state: Exp;  lines: +16 -1
done
—————————-
revision 1.1
date: 2014/11/04 10:36:10;  author: root;  state: Exp;
Initial revision
==================================================================

Posted in Project 04: FTP based Client Server using Threads and Sockets | Tagged , , , | Leave a comment

Client-server using socket (AF_UNIX)

RCS file: RCS/client.c,v
Working file: client.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
client requesting to server via socket
—————————-
revision 1.1
date: 2014/11/03 13:31:01;  author: root;  state: Exp;
Initial revision
=============================================================================

RCS file: RCS/server.c,v
Working file: server.c
head: 1.1
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
server file for the socket using AF_UNIX
—————————-
revision 1.1
date: 2014/11/03 13:29:21;  author: root;  state: Exp;
Initial revision
=============================================================================

Posted in Project 04: FTP based Client Server using Threads and Sockets | Tagged , , | Leave a comment

Understand RS232 Connection & Signals

RS-232C, EIA RS-232, or simply RS-232, refers to the same standard defined by the Electronic Industries Association in 1969 for serial communication.

RS-232 is a standard for serial communication transmission of data. It formally defines the signals connecting between a DTE (Data terminal equipment) such as a computer, and a DCE (Data communication equipment), such as a modem.

A straight-through cable is used to connect a DTE (e.g. computer) to a DCE (e.g. modem), all signals in one side connected to the corresponding signals in the other side in a one-to-one basis. A crossover (null-modem) cable is used to connect two DTE directly, without a modem in between.

 

Posted in Serial Port Driver | Leave a comment

Program that create a file with 4k bytes free space.

Program that create a file with 4k bytes free space.

RCS file: file_size.c,v
Working file: file_size.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
Implemented to create file with 4k bytes free space.
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 09:43:23;  author: root;  state: Exp;
Initial revision

Posted in Data Structures with C | Leave a comment

Nibble Mode Communication using IEEE Standard 1284-1994(Standard Signalling Method)

Implementation of Nibble Mode communication using Parallel Port Device Driver.

1. Host signals ability to take data by making the Busy pin low.

2. Now peripheral or writer responds by placing First nibble. Writer Writes on Data line, on the other side Reader reads from Status line.

3. Before reading from Reader side Peripheral or writer signals valid nibble by Sending signal on one of the status line.

4. The Reader indicate to writer that it has received the lower nibble. And is is not ready to accept another nibble. This is done by sending signal on status line to indicate the writer.

5. Now repeate all these steps for second nibble…

RCS file: header.h,v
Working file: header.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
implemented linux/ioport.h and asm/io.h
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

RCS file: declaration.h,v
Working file: declaration.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

RCS file: initilization.c,v
Working file: initilization.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
Implemented check_region(), request_region() and release_region()
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

RCS file: cleanup.c,v
Working file: cleanup.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
Implemented release_region
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

RCS file: dev_open.c,v
Working file: dev_open.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

RCS file: dev_release.c,v
Working file: dev_release.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

RCS file: dev_write.c,v
Working file: dev_write.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
Written LSB nibble and MSB nibble. Taken character from application and calaulated LSB and MSB
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

RCS file: dev_read.c,v
Working file: dev_read.c
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
Read the Nibbles and arranged to calculate the original character
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

RCS file: file_op.h,v
Working file: file_op.h
head: 1.1
branch:
locks: strict
root: 1.1
access list:
symbolic names:
keyword substitution: kv
total revisions: 1;    selected revisions: 1
description:
Performed different file operations
—————————-
revision 1.1    locked by: root;
date: 2014/11/03 08:52:22;  author: root;  state: Exp;
Initial revision

Write synopsis:

ch2 = ch1 & 0x0f;

ch3 = ch1 & 0xf0;
ch3 = ch3 >> 4;

Read synopsis:

ch1 = ch1 << 1;
ch1 = ch1 >> 4;
ch1 = ch1 & 0x0f;

ch2 = ch2 << 1;
ch2 = ch2 & 0xf0;

Enjoy Implementing……

Posted in Parallel Port Driver | Leave a comment

IEEE Std 1284 – 1994 : Standard Signalling Method for a bi-directional parallel peripheral interface for personal computers (Nibble Mode) and associated device driver

This project implements the protocol, for data transfer between a personal computer and a parallel peripheral interface, under NIBBLE MODE.
The protocol has been implemented by using polling method for checking the status of the peripheral
device and the host.
Successfully able to transfer a byte of data.
The user applications are configured for sending and receiving multiple bytes of data.

Following are the RCS files and code snippet of the project :

1. intialization module :
RCS file: ./initialization.c,v
Working file: initialization.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
IEEE Std. 1284-1994
Standard Signalling method for a Bi-directional parallel peripheral Interface for personal computer.
IC : 74LS244
Mode : Nibble Mode
Module Info : initialization
This module is responsible for :
- creating scull for the device.
- allocating required address for the driver to work.
- add driver to kernel tree.
—————————-
revision 1.2 locked by: root;
date: 2014/11/03 06:38:42; author: root; state: Exp; lines: +0 -8
Successfully allocated memory to the device scull.
requested and acquired the required address space i.e. 0×0378 – 0x037a
0×0378 for data lines.
0×0379 for status lines.
0x037a for control lines.
—————————-
Code Snippet :
tatic int __init initialization_function(void){
/* the name of the driver which you want your driver to be visible */
const char *name = “character_device_latest”;
int ret, i;
printk(KERN_ALERT”%s : Begin”, __func__);

/* checking and acquiring region for parallel port*/
ret = check_region(START, RANGE);
if(ret >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2. write module :
RCS file: ./dev_write.c,v
Working file: dev_write.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
Module : the module implements the protocol for sending a byte of data in two nibbles.
The module implements the protocol in the following manner :
1. reset the data and control lines.
2. write data to data lines.
3. check the busy status of the device by polling.
4. if device is free send strobe signal.
5. wait for acknowledgement corresponding the first nibble.
6. repeat steps 2-6 for sending the second nibble.
—————————-
revision 1.3 locked by: root;
date: 2014/11/03 07:15:13; author: root; state: Exp; lines: +0 -7
the writer performs the following operations successfully following the protocol for nibble mode.
1. read data to be sent from user application.
2. write first nibble to data lines.
3. get acknowledgement for first nibble and then send the second nibble
4. wait for acknowledgement of second nibble.
—————————-
Code Snippet :
int protocol(const char __user* buffer){
unsigned char temp;
volatile unsigned char busy;
volatile unsigned char ack;
struct nibble n;

/* remove garbage content from the control and data lines */
outb(0×0000, CTRL_REG);
outb(0×0000, DATA_REG);

/* prepare the first nibble to be sent */
temp = buffer[0];
printk(KERN_INFO”data to be sent to the reader = %d\n”, temp);
n.val = temp;
printk(KERN_INFO”nibble 1 to be sent to the reader = %d\n”, n.val);
outb(n.val, DATA_REG);
/* check the busy status of the device */
do{
busy = inb(STATUS_REG);
busy = busy & 0×0080;
}while(busy!=0×0080);
printk(“Device free\n”);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
3. read module :
RCS file: ./dev_read.c,v
Working file: dev_read.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
this module implements the protocol for receiving the data on the reader side.
protocol implemented for Nibble mode.
—————————-
revision 1.3 locked by: root;
date: 2014/11/03 07:12:53; author: root; state: Exp; lines: +1 -0
the reader correctly reads a byte of data as sent by the writer.
—————————-
revision 1.2
date: 2014/11/03 07:09:30; author: root; state: Exp; lines: +14 -14
corrected the error in reading the value from the status register.
——————————
Code Snippet :
ssize_t dev_read(struct file *filep, char __user *ubuff, size_t size, loff_t *loff)
{
volatile unsigned char strobe;
unsigned char data;
unsigned char temp;
printk(KERN_INFO”BEGIN %s\n”, __func__);

/* reset the data and control lines and update the busy status to free. */
outb(0×0000, CTRL_REG);
outb(0×0001, CTRL_REG);
outb(0×0000, DATA_REG);

/* wait on strobe value = 1, first nibble */
do{
strobe = inb(STATUS_REG);
strobe = strobe & 0×0080;
}while(strobe!=0×0080);
printk(KERN_INFO”Got strobe signal from the writer = %d\n”, strobe);

outb(0×0000, CTRL_REG); // make device appear busy to reader

// read the first nibble
temp = inb(STATUS_REG);
printk(KERN_INFO” inb, temp = %d\n”, temp);
temp = temp & 0×0078;
temp = temp >>3;
printk(KERN_INFO”temp after masking= %d\n”, temp);
printk(KERN_INFO”Data received (nibble – 1)= %d\n”, temp);

Posted in Parallel Port Driver | Leave a comment