EmbLogic's Blog

USB OTG

The universal serial bus (USB) On-the-Go (OTG) specification, a supplement to the USB 2.0 . USB host capability that enables point-to-point communication. Such a setup allows embedded devices such as digital cameras, mobile phones, and printers to connect to each other directly.

An embedded USB device that switches roles, referred as dual role device, has features that include minimal USB host capability, Session Request Protocol (SRP), Host Negotiation Protocol (HNP), and 8mA on VBUS.

Linux has a simple infrastructure to support OTG devices. The OTG infrastructure is much closer to the hardware, similar to the peripheral device controller (PDC) driver, the OTG framework is responsible for handling
and responding to the OTG protocol negotiations such as SRP and HNP.broad level, the functionality of the OTG framework controls the USB transceiver hardware to meet the OTG requirement.

OTG Driver Framework
The OTG framework is not clearly defined like the gadget framework is sometimes the OTG implementation is mixed with the other frameworks. The Linux USB subsystem source code of OTG framework is maintained in the
/drivers/usb/otg/ folder. Some part of the usbcore module plays a key role (drivers/usb/core/hub.c). Most of the OTG activities are based on the physical layer activity and the timing of the electrical signals. The role of OTG software framework is minimal .It is responsible for setting up the signal and switching to different states defined by the OTG specification .
The OTG framework is divided into two major parts: callback methods and utility functions. The methods provided by struct otg_tranceiver are extended to the other Linux USB frameworks using wrapper functions. The OTG
framework also helps save and retrieve the struct otg_transceiver object using utility functions. The other main part is interface methods of the transceiver to platform.

The OTG driver flow consists of both the host and the device driver framework, taking its part to switch the role by using the OTG framework. Like the PDC driver, the OTG driver is specific to the hardware and the platform
for which the transceiver is developed. OTG driver starts by registering itself successfully with the Linux platform, along with the platform callbacks such as probe routine. The platform calls the registered probe routine when it detects transceiver. The probe routine maps the platform resource and creates the struct otg_transceiver object. The probe routine also sets the callbacks of otg_transceiver. Once the probe is successful, the OTG framework is functionally ready for the host and gadget framework to use it.

Posted in USB Driver | Leave a comment

To boost up

NO Matter of size but Life is on the Earth so all Emblogician who are going and preparing to face the World .Don’t afraid from the world, World is for you . Move ahead and conquer entire world with your knowledge and humble through your entire Life .

Posted in Uncategorized | Leave a comment

socket programming

1 head    1.1;
2 access;
3 symbols;
4 locks
5         root:1.1; strict;
6 comment @ * @;
7
8
9 1.1
10 date    2013.12.31.10.09.33;    author root;    state Exp;
11 branches;
12 next    ;
13
14
15 desc
16 @AF_INET server source code
17 @
18
19
20 1.1
21 log
22 @Initial revision
23 @
________________________________________________________________________________________________________

1 head    1.1;
2 access;
3 symbols;
4 locks
5         root:1.1; strict;
6 comment @ * @;
7
8
9 1.1
10 date    2013.12.31.10.11.31;    author root;    state Exp;
11 branches;
12 next    ;
13
14
15 desc
16 @AF_INET client source code
17 @
18
19
20 1.1
21 log
22 @Initial revision
23 @

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

FIRST WEEK AT EMBLOGIC

It is my 1ST WEEK and i really appericiate the professional atmosphere over here. LINUX is a new thing to learn and its different and easy as compared to WINDOWS. I found it interesting to learn. Many things we already done in our college and there are many new things….combining them both will head towards a healthy learning………..

Posted in Uncategorized | Tagged | Leave a comment

RS232 Connection & Signals

Synchronous and Asynchronous Communications

Synchronous Communication requires the sender and receiver to share the same clock. The sender provides a timing signal to the receiver so that the receiver knows when to “read” the data. Synchronous Communication generally has higher data rates and greater error-checking capability. A printer is a form of Synchronous Communication.

Asynchronous Communication has no timing signal or clock. Instead, it inserts Start/Stop bits into each byte of data to “synchronize” the communication. As it uses less wires for communication (no clock signals), Asynchronous Communication is simpler and more cost-effective. RS-232/RS-485/RS-422/TTL are the forms of Asynchronous Communications.

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 Connections

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. They cross transmit and receive data signals between the two sides and there are many variations on how the other control signals are wired.

The data transmission starts with a Start bit, followed by the data bits (LSB sent first and MSB sent last), and ends with a “Stop” bit.

The voltage of Logic “1″ (Mark) is between -3VDC to -15VDC, while the Logic “0″ (Space) is between +3VDC to +15VDC.

RS-232 connects the Ground of 2 different devices together, which is the so-called “Unbalanced” connection. An unbalanced connection is more susceptible to noise, and has a distance limitation of 50 ft (which is around 15 meters).

Handshaking is also called “Flow Control”. The main purpose of Handshaking is to prevent receiver overloading. By using Handshaking signals, receivers will be able to tell the sending device to pause data transmission if the receiver is overloaded. There are three types of handshaking: Software handshaking, Hardware handshaking and Both.

Software handshaking uses two control characters: XON and XOFF. The receiver sends these control characters to pause transmitter during communication. XON is decimal 17 and XOFF is decimal 19 in the ASCII chart. The drawback of Software handshaking is that these two control characters can not be used in data. This is quite important when you are transmitting Binary data as you might need to use these two codes in your data.

Hardware handshaking makes use of actual hardware lines, such as RTS/CTS, DTR/DSR, and DCD/RI (for modem).

The DTE 1 uses the DTR (Data Terminal Ready) signal to indicate it is ready for information exchange, whereas the DTE 2 uses the DSR signal for the same purpose. Before sending a data, the DTE 1 asks permission by setting its RTS output to high. No data will be sent until the DTE 2 grants permission by using the CTS line.  RTS/CTS are ON or OFF for each data transmission. DCD (Data Carrier Ready) is used by the modem when a connection has been established with remote equipment, while RI (Ring Indicator) is used by the modem to indicate a ring signal from telephone line.

 

Posted in Uncategorized | Leave a comment

queue implementation using an array in C

RCS file: queue_using_array.c,v
Working file: queue_using_array.c
head: 1.5
branch:
locks: strict
	root: 1.5
access list:
symbolic names:
keyword substitution: kv
total revisions: 5;	selected revisions: 5
description:
Queue implementation using arrays is done successfully.
Different functions are made for inserting and deleting elements.
----------------------------
revision 1.5	locked by: root;
date: 2013/12/31 14:01:43;  author: root;  state: Exp;  lines: +6 -3
Prototype of the display function is changed.
If the user chooses the display function without inserting an element.
The display function prints the queue is empty and return.
----------------------------
revision 1.4
date: 2013/12/31 13:38:29;  author: root;  state: Exp;  lines: +1 -1
Underflow condition in display() function is given.
To display to the user if the user enters display function before inserting any
element in to the array.
Display function working fine.
----------------------------
revision 1.3
date: 2013/12/31 13:36:36;  author: root;  state: Exp;  lines: +2 -0
Error occurred,may be missing parenthesis.
Debugging the error in the display function.
----------------------------
revision 1.2
date: 2013/12/31 13:34:00;  author: root;  state: Exp;  lines: +1 -1
More optmizations are done in the code.
----------------------------
revision 1.1
date: 2013/12/23 12:30:51;  author: root;  state: Exp;
Initial revision
Posted in Data Structures with C | Leave a comment

socket implementation

head  1.1;
access;
symbols;
locks
root:1.1; strict;
comment     @ * @;

1.1
date  2013.12.30.05.37.11;    author root;      state Exp;
branches;
next  ;

desc
@this is server implemented by socket and create usrname & password for server
@

1.1
log
@Initial revision
@
text

head  1.1;
access;
symbols;
locks
root:1.1; strict;
comment     @ * @;

1.1
date  2013.12.30.05.36.51;    author root;      state Exp;
branches;
next  ;

desc
@this is client implemented by using socket
@

1.1
log
@Initial revision
@
text

Posted in Uncategorized | Leave a comment

USB device driver

USB Device Driver

 

Introduction to USB:

These days we are using USB(Universal Serial Bus) devices like pen drive

,mouse,printer etc instead of using serial or parallel port devices. One of the original intentions of USB was to reduce the amount of cabling at the back of your PC. USB port can connect up to 127 peripheral devices by using hub. Averagely it gives us 12Mbps data transfer speed.

Basically host controller keep checking at the USB port to detect device. Whenever device came due to voltage difference it generate interrupt and inform to the system about the device.

 

Now to make USB communication between the host and the device there is need of the drivers on the both side.In our system there is core usb driver which load the appropriate interfacing driver (that is of our concern )for the usb device (mouse ,keyboard etc.) for service. In our system there are different different drivers for different type of devices to make core driver less bulky.

 

USB device basic:

USB device may have one or more configurations and each configuration consist of one or more interfaces and each interfaces consist of one or more endpoints. Generally there is only one configuration in more devices if more, then it will be select able by hardware switch. In our GSM modem there is facility of attaching storage device also so it has two interfaces.

Now for communication we have to send or receive data from the endpoints which is inside the interface ,these may be input endpoint or output endpoint for receiving and sending respectively.

 

Type of data transfer from endpoint:

Control :

Control endpoint is used to retrieve the device information at the time of enumeration of device

Enumeration is the process in which core driver take the information about the hardware from the device firmware to check the vendor id,product id ,serial number etc to load appropriate interfacing driver to serve.

Interrupt:

Interrupt endpoint is used to send the small data of in asynchronous manner like in keyboard. This endpoint is not used to transfer large amount of data.

Isochronous:

Isochronous endpoint is used to send large amount of data but it is generally used where we can accept some data loss like in video streaming where continuous stream of data is required.

Bulk:

Bulk endpoint is also used to send large amount of data and there is no loss in the data. It is used for the mass storage devices to copy the data to and from t he system. It split the data into small chunks if there is large amount of data according to the block size.

 

Now it is clear from above discussion that data is transferred from the endpoint. Data is generally transferred in URBs i.e USB request blocks.

 

Interfacing Driver:

Interfacing driver means that driver which is loaded by usb core driver for specific device to server. It communicate between the application layer and the usb core driver to serve the device request. If we want to use our interfacing driver in the system to provide service then we have to register our driver with USB subsystem first using usb_register() system call and then in our driver we also have to specify that our driver is made for which device (vendor id, product id etc.). All these information is provided in the linux/usb.h header file.

Now one important thing is that you have to remove the usbhid named driver from the system using rmmod usbhid if it is moduler otherwise recompile raw kernel by making hid(human interface device) driver moduler from static.

 

Thank you.

Posted in Uncategorized | Leave a comment

FTP, client-server by socket.

Client-server using socket(AF_INET) implemented. Also FTP, client-server netwroking based project implemented successfully.

Log file for server:

head    1.2;
access;
symbols;
locks
root:1.2; strict;
comment    @ * @;

1.2
date    2013.12.30.10.38.40;    author root;    state Exp;
branches;
next    1.1;

1.1
date    2013.12.30.10.35.58;    author root;    state Exp;
branches;
next    ;

desc
@This is the soruce code file for server file for FTP, client server using sockets(domain AF_INET).
@

1.2
log
@The error are removed from server file and FTP, client server using socket implemented successfully.
@

____________________________________________________________________________________

Log file for client:

head    1.2;
access;
symbols;
locks
root:1.2; strict;
comment    @ * @;

1.2
date    2013.12.30.10.38.40;    author root;    state Exp;
branches;
next    1.1;

1.1
date    2013.12.30.10.35.58;    author root;    state Exp;
branches;
next    ;

desc
@This is the soruce code file for server file for FTP, client server using sockets(domain AF_INET).
@

1.2
log
@The error are removed from server file and FTP, client server using socket implemented successfully.
@

Posted in Uncategorized | Leave a comment

Socket (AF_INET)

Log file for server

head    1.1;
access;
symbols;
locks
root:1.1; strict;
comment    @ * @;

1.1
date    2013.12.30.10.47.35;    author root;    state Exp;
branches;
next    ;

desc
@source file for ftp server

————————————————————————————————————————————-

log file for client

head    1.1;
access;
symbols;
locks
root:1.1; strict;
comment    @ * @;

1.1
date    2013.12.30.10.52.02;    author root;    state Exp;
branches;
next    ;

desc
@source code for client for FTP

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

FTP USING SOCKET OVER THE NETWORK

->THIS IS SERVER

head    1.1;
access;
symbols;
locks
root:1.1; strict;
comment    @ * @;

1.1
date    2013.12.30.10.36.35;    author root;    state Exp;
branches;
next    ;

desc
@this is server which is asking for username and password from client to check its authentication
@

1.1
log
@Initial revision
@

->THIS IS CLIENT

head    1.1;
access;
symbols;
locks
root:1.1; strict;
comment    @ * @;

1.1
date    2013.12.30.10.39.00;    author root;    state Exp;
branches;
next    ;

desc
@this is client which is requesting for connection to the server
@

1.1
log
@Initial revision
@

->THIS DATABASE OF SERVER

head    1.1;
access;
symbols;
locks
root:1.1; strict;
comment    @# @;

1.1
date    2013.12.30.10.39.36;    author root;    state Exp;
branches;
next    ;

desc
@this is database of server
@

1.1
log
@Initial revision
@

Posted in Uncategorized | Leave a comment

Client Server Communication using AF_INET Sockets [RCS Log]

HEADER RCS

head    1.1;
access;
symbols;
locks; strict;
comment @ * @;

1.1
date    2013.12.30.09.22.36;    author raman;   state Exp;
branches;
next    ;

desc
@this is header file

CLIENT RCS

head    1.1;
access;
symbols;
locks; strict;
comment @ * @;

1.1
date    2013.12.30.09.10.15;    author raman;   state Exp;
branches;
next    ;

desc
@This is a client

SERVER RCS

head    1.1;
access;
symbols;
locks; strict;
comment @ * @;

1.1
date    2013.12.30.09.21.44;    author raman;   state Exp;
branches;
next    ;

desc
@This is a server

 

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

SERIAL COMMUNICATION

SERIAL COMMUNICATION

The serial port on your PC is a full-duplex device meaning that it can send and receive data at the same time. In order to be able to do this, it uses separate lines for transmitting and receiving data. Some types of serial devices support only one-way communications and therefore use only two wires in the cable – the transmit line and the signal ground.

 Communicating by Bits

Once the start bit has been sent, the transmitter sends the actual data bits. There may either be 5, 6, 7, or 8 data bits, depending on the number you have selected. Both receiver and the transmitter must agree on the number of data bits, as well as the baud rate. Start and stop bit is send before and after the data has send.

The Parity Bit

Besides the synchronization provided by the use of start and stop bits, an additional bit called a parity bit transmitted along with the data. A parity bit provide a small amount of error checking, to help detect data corruption that might occur during transmission. You can choose either even parity, odd parity. When even or odd parity is being used, the number of marks (logical 1 bits) in each data byte are counted, and a single bit is transmitted following the data bits to indicate whether the number of 1 bits just sent is even or odd.

RS-232 Protocol

RS-232 is the name for a standards for serial binary single-ended data and control signals connecting between data terminal equipment and data circuit-terminating equipment. It is commonly used in computer serial ports. The standard defines the electrical characteristics and signals timing, size and pin-out of connectors. This protocol defines the maximum open-circuit voltage of +/- 25 volts. Valid signals are in the range of +3 to +15 volts or the range -3 to -15 volts with respect to the ground. The range between -3 to +3 volts is not a valid RS-232 level. For data transmission lines (TxD, RxD etc.) logic one is defined as a negative voltage and the condition is called mark. Logic zero is +ve and the signal condition is termed space. Control signals have the opposite polarity: the active state is positive voltage and the inactive state is negative voltage.

Posted in Serial Port Driver | Leave a comment

Block Driver

Have you ever used VIM editer in the linux? If yes then you must have observed that whatever you type in the editor is visible to you and your system knows that what characters you have written. It means these characters are stored somewhere in the system.
What happens when you just gave the :q command in the VIM editor, the editor is closed now and whatever characters you have written in the Vim Editor is lost now.
What happens when you gave the :wq command in VIM, the editor is closed but whatever you have written in the Editor is not lost. You can get this saved file even after rebooting your system. If you know the secondary memory then it simply means that now the file is in the secondary storage.

Both the times the file was saved in the system but only difference is that for the first observation the file was saved in you primary memory and the second time you just saved your file in the secondary storage.

Who did this stuff? The answer is block layer of the Operating system.

This is just a example to understand what is the role of Block layer of the Operating System but there are too many stuffs in the operating system where the block driver works. To implement the block driver we can simply have a conclusion i.e. whenever we need to save the primary storage data into the secondary storage or to fetch the data stored in the secondary storage into the primary one, the block layer comes into the picture.

The block driver simply writes the block of bytes into the secondary storage from the primary storage or reads the block of bytes from secodary storage to the primary storage.

The block driver deals with the data in fixed size of blocks. Mostly all the devices which are used as the secondary storage are the block devices.

We require to mount a filesystem on the block devices. Filesystem provides the way of arrangment in the device and meaning of the simple 0s and 1s(raw data stored on the device) to the Operating System. The device file provides the interface between the filesystem and the block device driver. Filesystem can divide the disk (Mostly the secondary storage) into multiple logical parts i.e. partitions of the disk.

Block devices support random access and generally use buffered input and output routines. The operating system allocates a data buffer to hold a single block each for input and output. When a program sends a request to read data from, or write data to, the device, the system stores each character of that data in the appropriate buffer. When the buffer fills up, the appropriate operation takes place (data transfer) and the system clears the buffer.

The sector is the smallest addressable unit of the disk. Each sector stores a fixed amount of user-accessible data, traditionally 512 bytes for hard drives and 2048 bytes for CD-ROMs and DVD-ROMs. Newer hard drives use 4096-byte sectors.

Posted in Block Driver | Leave a comment

An introduction to Parallel port

An Introduction to parallel port

A parallel interface for connecting an external device. Parallel port is basically used to transfer data parallely . 8 bits of data is transmitted at a time in parallel port.On PCs, the parallel port uses a 25-pin connector (type DB-25) and is used to connect printers, computers and other devices that need relatively high bandwidth. It is often called a Centronics interface after the company that designed the original standard for parallel communication between a computer and printer. (The modern parallel interface is based on a design by Epson.) A newer type of parallel port, which supports the same connectors as the Centronics interface, is the EPP (Enhanced Parallel Port) or ECP (Extended Capabilities Port). Both of these parallel ports support bi-directional communication and transfer rates ten times as fast as the Centronics port.

There are 5 modes of transferring data using parallel port :-

1- compatibility mode or centronic  mode
2- nibble mode
3-byte mode

4-ECP mode
5- EPP mode

compatibility mode :- The Centronics interface is a standard input/output (I/O) interface designed in the 1970s for connecting printers and other devices. It was developed by the Centronics printer company which is now defunct. The Centronics interface, also known as a Parallel Port, became the standard means of connecting printers to personal computers for decades.

The technology that the Centronics interface developed into included a number of incarnations of the Parallel interface including the ECP (Entended Capabilities Parallel) and EPP (Enhanced Parallel Port) versions. The technology required a 25 way connector of which up to 17 wires were used in the specification and bi-directional communications became possible in the enhanced versions like ECP and EPP.

Today, the Centronics interface has been largely replaced by the universal serial bus (USB). For the most part, many manufactures have entirely omitted the parallel interface. However, a USB-to-parallel port adapter is available for PCs without a parallel port. These can be used for parallel printers and other peripheral devices that have a parallel interface.

Nibble mode :-The Nibble mode is the most common way to get reverse channel data from a printer or peripheral. This mode is usually combined with the Compatibility mode or a proprietary forward channel mode to create a complete bi-directional channel.
All of the standard parallel ports provide 5 lines from the peripheral to the PC to be used for external status indications. Using these lines, a peripheral can send a byte of data (8-bits) by sending 2 nibbles (4-bits) of information to the PC in two data transfer cycles. Unfortunately, since the nACK line is generally used to provide a peripheral interrupt, the bits used to transfer a nibble are not conveniently packed into the byte defined by the Status register. For this reason, the software must read the status byte and then manipulate the bits in order to get a correct byte.

1. Host signals ability to take data by asserting HostBusy low
2. Peripheral responds by placing first nibble on status lines
3. Peripheral signals valid nibble by asserting PtrClk low
4. Host sets HostBusy high to indicate that it has received the nibble and is not yet ready for another nibble.
5. Peripheral sets PtrClk high to acknowledge host
6. States 1 through 5 repeat for the second nibble.

Posted in Parallel Port Driver | Leave a comment