Sunday, November 20, 2011

Creating MySQL database on Linux system

http://www.webdevelopersnotes.com/tutorials/sql/mysql_primer_creating_a_database.php3

Creating MySQL database on Linux system

  1. I assume that you are working from your account and not the root. Start a terminal session and become the superuser (Type su at the prompt and then enter the root password).
  2. Now we'll access the MySQL server. Type:
     mysql -u root -p 
    The system prompts for the MySQL root password that you set up in Installing MySQL on Linux. (Note: This is not the Linux root password but the MySQL root password). Enter the password, which is not displayed for security reasons.
    Once you are successfully logged in, the system prints a welcome message and displays the mysql prompt ... something like
     Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 1 to server version: 3.22.32  Type 'help' for help.  mysql>  
  3. Now we are ready for creating the employees database. Issue the command:
     create database employees; 
    (Note: The command ends with a semi-colon)
  4. An important point to note is that this database is created by the root and so will not be accessible to any other user unless permitted by the root. Thus, in order to use this database from my account (called manish), I have to set the permissions by issuing the following command:
     GRANT ALL ON employees.* TO manish@localhost IDENTIFIED BY "eagle" 
    The above command grants my account (manish@localhost) all the permissions on employees database and sets my password to eagle. You should replace manishwith your user name and choose an appropriate password.
  5. Close the mysql session by typing quit at the prompt. Exit from superuser and come back to your account. (Type exit).
  6. To connect to MySQL from your account, type:
     mysql -u user_name -p 
    Type in the password when prompted. (This password was set by the GRANTS ALL... command above) . The system displays the welcome message once you have successfully logged on to MySQL. Here is how your session should look like:
     [manish@localhost manish]$ mysql -u manish -p Enter password:  Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 3 to server version: 3.22.32  Type 'help' for help.  mysql>  
  7. Typing the command SHOW DATABASES; will list all the databases available on the system. You should get a display similar to:
     mysql> SHOW DATABASES; +----------------+ | Database       | +----------------+ | employees      | | mysql          | | test           | +----------------+ 3 rows in set (0.00 sec) 
  8. Enter quit at the mysql> prompt to come out of the mysql client program.

Friday, November 18, 2011

quick fix of mysqldump error 1044

mysqldump: Got error: 1044: Access denied for user 'root'@'localhost' to database 'information_schema' when using LOCK TABLES

To quickly fix this problem use the following switch when running mysqldump for MySQL database backups.

mysqldump -u root -p –all-databases –single-transaction > all.sql



Tuesday, November 15, 2011

Ready to use script for website backup

http://www.cyberciti.biz/tips/how-to-backup-mysql-databases-web-server-files-to-a-ftp-server-automatically.html

HowTo: Backup MySQL Databases, Web server Files to a FTP Server Automatically

by Vivek Gite on August 10, 2006 · 104 comments

This is a simple backup solution for people who run their own web server and MySQL database server on a dedicated or VPS server. Most dedicated hosting provider provides backup service using NAS or FTP servers. These service providers will hook you to their redundant centralized storage array over private VLAN. Since, I manage couple of boxes, here is my own automated solution. If you just want a shell script, go here (you just need to provided appropriate input and it will generate FTP backup script for you on fly, you can also grab my php script generator code).

Making Incremental Backups With tar

You can make tape backups. However, sometime tape is not an option. GNU tar allows you to make incremental backups with -g option. In this example, tar command will make incremental backup of /var/www/html, /home, and /etc directories, run:
# tar -g /var/log/tar-incremental.log -zcvf /backup/today.tar.gz /var/www/html /home /etc

Where,

  • -g: Create/list/extract new GNU-format incremental backup and store information to /var/log/tar-incremental.log file.

Making MySQL Databases Backup

mysqldump is a client program for dumping or backing up mysql databases, tables and data. For example, the following command displays the list of databases:
$ mysql -u root -h localhost -p -Bse 'show databases'

Output:

Enter password: brutelog cake faqs mysql phpads snews test tmp van wp

Next, you can backup each database with the mysqldump command:
$ mysqldump -u root -h localhost -pmypassword faqs | gzip -9 > faqs-db.sql.gz

Creating A Simple Backup System For Your Installation

The main advantage of using FTP or NAS backup is a protection from data loss. You can use various protocols to backup data:

  1. FTP
  2. SSH
  3. RSYNC
  4. Other Commercial solutions

However, I am going to write about FTP backup solution here. The idea is as follows:

  • Make a full backup every Sunday night i.e. backup everything every Sunday
  • Next backup only those files that has been modified since the full backup (incremental backup).
  • This is a seven-day backup cycle.

Our Sample Setup

   Your-server     ===>       ftp/nas server IP:202.54.1.10   ===>       208.111.2.5 

Let us assume that your ftp login details are as follows:

  • FTP server IP: 208.111.2.5
  • FTP Username: nixcraft
  • FTP Password: somepassword
  • FTP Directory: /home/nixcraft (or /)

You store all data as follows:
=> /home/nixcraft/full/mm-dd-yy/files - Full backup
=> /home/nixcraft/incremental/mm-dd-yy/files - Incremental backup

Automating Backup With tar

Now, you know how to backup files and mysql databases using the tar and mysqldump commands. It is time to write a shell script that will automate entire procedure:

  1. First, our script will collect all data from both MySQL database server and file system into a temporary directory called /backup using a tar command.
  2. Next, script will login to your ftp server and create a directory structure as discussed above.
  3. Script will dump all files from /backup to the ftp server.
  4. Script will remove temporary backup from /backup directory.
  5. Script will send you an email notification if ftp backups failed due to any reason.

You must have the following commands installed (use yum or apt-get package manager to install ftp client called ncftp):

  • ncftp ftp client
  • mysqldump command
  • GNU tar command

Here is the sample script:

#!/bin/sh # System + MySQL backup script # Full backup day - Sun (rest of the day do incremental backup) # Copyright (c) 2005-2006 nixCraft <http://www.cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # Automatically generated by http://bash.cyberciti.biz/backup/wizard-ftp-script.php # --------------------------------------------------------------------- ### System Setup ### DIRS="/home /etc /var/www" BACKUP=/tmp/backup.$$ NOW=$(date +"%d-%m-%Y") INCFILE="/root/tar-inc-backup.dat" DAY=$(date +"%a") FULLBACKUP="Sun" ### MySQL Setup ### MUSER="admin" MPASS="mysqladminpassword" MHOST="localhost" MYSQL="$(which mysql)" MYSQLDUMP="$(which mysqldump)" GZIP="$(which gzip)" ### FTP server Setup ### FTPD="/home/vivek/incremental" FTPU="vivek" FTPP="ftppassword" FTPS="208.111.11.2" NCFTP="$(which ncftpput)" ### Other stuff ### EMAILID="admin@theos.in" ### Start Backup for file system ### [ ! -d $BACKUP ] && mkdir -p $BACKUP || : ### See if we want to make a full backup ### if [ "$DAY" == "$FULLBACKUP" ]; then   FTPD="/home/vivek/full"   FILE="fs-full-$NOW.tar.gz"   tar -zcvf $BACKUP/$FILE $DIRS else   i=$(date +"%Hh%Mm%Ss")   FILE="fs-i-$NOW-$i.tar.gz"   tar -g $INCFILE -zcvf $BACKUP/$FILE $DIRS fi ### Start MySQL Backup ### # Get all databases name DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')" for db in $DBS do  FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").gz  $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE done ### Dump backup using FTP ### #Start FTP backup using ncftp ncftp -u"$FTPU" -p"$FTPP" $FTPS<<EOF mkdir $FTPD mkdir $FTPD/$NOW cd $FTPD/$NOW lcd $BACKUP mput * quit EOF ### Find out if ftp backup failed or not ### if [ "$?" == "0" ]; then  rm -f $BACKUP/* else  T=/tmp/backup.fail  echo "Date: $(date)">$T  echo "Hostname: $(hostname)" >>$T  echo "Backup failed" >>$T  mail  -s "BACKUP FAILED" "$EMAILID" <$T  rm -f $T fi  

How Do I Setup a Cron Job To Backup Data Automatically?

Just add cron job as per your requirements:
13 0 * * * /home/admin/bin/ftpbackup.sh >/dev/null 2>&1

Generate FTP backup script

Since I setup many Linux boxes, here is my own FTP backup script generator. You just need to provided appropriate input and it will generate FTP backup script for you on fly.

Wednesday, October 26, 2011

How to reset MySQL root password


1. edit /etc/mysql/my.cnf
add "skip-grant-tables" in mysqld settings section

2. restart mysqld
/etc/init.d/mysql restart

3. connect mysql database
mysql -u root -p mysql

4. update root password
>update user set password=PASSWORD("12345") where user='root';
quit

5. delete the configuration added in step 1

6. restart mysqld again
/etc/init.d/mysql restart

DONE!

Sunday, October 23, 2011

Enable SSL on ubuntu apache2

http://beginlinux.com/blog/2009/01/ssl-on-ubuntu-810-apache2/

Setting up SSL with Ubuntu 8.10 is a simple process but it does have a few gotchas that you need to be aware of.  The setup has changed from 8.04.  One issue is that the +CompatEnvVars is no longer used as it created a bug in 8.10 and you will have to enable the default-ssl site to get everything working.

First, log on to your server  Install Apache:

sudo apt-get install apache2

Change to the /etc/apache2/mods-available directory and look at the available modules.  Then change to the /etc/apache2/mods-enabled directory to see what modules are enabled:

cd /etc/apache2/mods-available
ls
cd /etc/apache2/mods-enabled
ls

Now, install and enable SSL:

sudo a2enmod ssl
sudo /etc/init.d/apache2 force-reload

Change to the default webserver directory, and create a simple web page:
cd /var/www
sudo vim index.html

Add the following content:
<html>
<head>
<title>Welcome to Your_Name's Web Site</title>
</head>
<body>
<p>This is the best web site in the whole wide world.     </p>
</body>
</html>

Save and exit.  On your own local computer, open a tab or window for your web browser.  For the URL, enter:

http://IP_address_of_my_server

You should be able to view your web page.  Now, you'll want to encrypt your site.    Create the server encryption keys:

cd /etc/apache2
sudo openssl genrsa -des3 -out server.key 1024

Use this set of keys to create a certificate request:

sudo openssl req -new -key server.key -out server.csr

When asked to input data, use your imagination to create something appropriate.  Be sure to write down your passphrase.  Use this request to create your self-signed certificate:

sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Install the key and certificate:

sudo cp server.crt /etc/ssl/certs/ 
sudo cp server.key /etc/ssl/private/

Open the "defaults" file for editing:

cd /etc/apache2/sites-available
sudo vim default-ssl

This file is basically set up but you will want to uncomment  the SSLOptions line and also change the SSLCertificate lines to reflect the location and name of your new information.

SSLEngine on
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
SSLCertificateFile /etc/ssl/certs/server.crt
SSLCertificateKeyFile /etc/ssl/private/server.key

The port 443 is enabled when you use SSL so that is ready to go.

Enable the default SSL site:
sudo a2ensite default-ssl

If you do not enable the default-ssl you will get this error:
"ssl_error_rx_record_too_long apache"

Restart Apache.

sudo /etc/init.d/apache2 restart

That should do it.


Friday, July 22, 2011

IEEE 802.15.4 in the Context of Zigbee

http://freaklabs.org/index.php/Articles/Zigbee/IEEE-802.15.4-in-the-Context-of-Zigbee-Part-2-MAC-Layer.html
IEEE 802.15.4 in the Context of Zigbee - Part 2 - MAC Layer | Print |
Written by Akiba   
Sunday, 14 December 2008

When the economic news is too unbearably depressing to allow me to even write software, I turn to the few things that I know I can count on: my Groove Salad streaming MP3 radio station (legal, of course), a glass of wine, and the tutorial series on 802.15.4 and Zigbee that I have yet to finish. 

When we left off last time, Jan was sleeping with Jim, the transsexual who goes by the name of….wait…no, we left off at the 802.15.4 PHY layer. Well, the PHY layer is pretty straightforward unless you're an RF IC engineer, so now we're going to get into the real meat of things…the MAC layer.

The MAC layer is where all the fun is in terms of a software protocol stack. Actually, the 802.15.4 MAC is fairly complicated and feature-packed, which is why I named this series "802.15.4 in the Context of Zigbee". As the title implies, I'm only going to cover enough of 802.15.4 to understand how it fits into a protocol like Zigbee. Luckily, Zigbee eschewed a good portion of 802.15.4 in the name of simplicity and getting a spec out quick, so you won't need to know a whole bunch about 802.15.4. Unfortunately, this has also become a weakness of Zigbee.

Beacon Modes

One of the most glaring omissions of the Zigbee spec is that it doesn't use the 802.15.4 MAC in beacon mode (except for tree-only routing implementations which are impractical as I'll explain in some later article). 

The MAC layer defines two basic modes of operation: beacon mode and non-beacon mode. Beacon mode is timing dependent, where a beacon frame is sent out at some set interval defined by the implementation. The beacon defines the start of a superframe which is basically the interval between the beacons, and is used as a way for the devices on the network to synchronize with each other. The superframe is divided into two parts: the active part where data transfers occur, and the inactive part where the device can go to sleep. For very low power operation, you can define the ratio of the active time to the inactive time to be very low so that the device spends most of its time sleeping.

Superframe

In non-beacon mode, there is no concept of a superframe and the beacons are only used to discover what networks exist within a channel. In other words, beacons are only used when a device is first turned on and it scans for networks to join. Non-beacon mode is completely asynchronous so the upper layer protocol needs to treat each node as completely independent. This has certain implications, especially to power consumption. One of the biggest complaints about Zigbee is that the routers are not allowed to sleep due to the asynchronous nature of non-beacon mode. Since the routers never know if an end device is sleeping or not, it needs to always be on to receive and buffer frames for its children. The children will poll the router periodically to see if there are any messages buffered for that device. The fact that the routers are always on means that certain types of applications are non-feasible for Zigbee, such as applications where the routers do not have access to a MAINS supply.  

Media Access Control

The main purpose of the MAC layer is to provide access control to the shared channel and reliable data delivery. In layman's terms, that means that it controls the channel so that only one device is transmitting at a time and it also defines the handshaking acknowledgement when a frame is received successfully. 

So let's get started with one of the main functions of the MAC. That is to provide access control to the wireless medium. To accomplish this, it uses a simple algorithm called CSMA/CA which stands for Carrier Sense Multiple Access/Collision Avoidance. It sounds complicated, but it's really rather simple: 

Think of the street that you live on. When you pull your car out of your driveway in the morning, you need to implement CSMA/CA. As you inch your car out of the driveway, you're constantly checking your right and left rear sides to make sure no cars are coming. That's the carrier sense, where the street is the carrier. The fact that you're checking for a car other than yours coming down the street is the multiple access. You're making sure that no other cars are trying to access the road that you want to get on. If you see another car coming as you're trying to get on the road, you stop, possibly inch your car back up the driveway, and wait some unspecified amount of time for the car to pass. That's called collision avoidance. Yes, that's the genius algorithm that engineers devised for the 802.15.4 media access. It's actually slightly more complicated if you use beacon mode, however since we're only focusing on Zigbee, then we don't need to worry about that.

So now that we have the cheesy analogy out of the way, let's see how it really works. When you want to transmit a frame, the first thing you need to do is a CCA, or clear channel assessment. That means that you instruct the radio to check the receive channel and see if there is any data being transmitted, either to you or some other device on the channel that you're on. If it's clear, then you can transmit the frame. Voila!

If it's not, then you have to go into collision avoidance mode. If the channel is not clear, then you wait for a random amount of time and check the channel again. If it's still not clear, you do the same thing. To avoid ending up in an infinite loop, the implementor sets a maximum amount of CSMA backoffs that can be performed. If that amount is exceeded, then the transmit attempt is failed. This usually means you have a serious problem with the channel that you're on so your software better do something to handle it. This gets into frequency (channel) agility which we can discuss more about in the Zigbee section.

 

 CSMA/CA

802.15.4 Device Types


There are two devices types defined by the 802.15.4 spec:

  • Full Function Device (FFD):
    • Full function devices are allowed to start a network and assume the role of coordinator. They are also able to allow other FFDs or reduced function devices (RFDs) to join them. For Zigbee, FFDs are known as Zigbee Routers and are the only devices that can forward frames. They must have sufficient RAM to buffer frames for the devices that are joined to it and hold all the tables including the routing and neighbor tables. These devices usually have large flash memory footprints as well since they handle the bulk of the logic in a Zigbee network. 
  • Reduced Function Device (RFD):
    • These devices are only allowed to join FFDs and cannot have other devices join them. They cannot start a network or become a coordinator and are also not allowed to do any routing. In Zigbee, they are known as Zigbee End Devices (ZEDs). The advantage of a Zigbee End Device is that the code and RAM footprint are much smaller resulting in a lower cost device. They are also allowed to sleep so they can reduce their power consumption and survive for long periods of time on a battery.


802.15.4 MAC Topologies

802.15.4 defines two main topologies: point-to-point and star networks. A point-to-point topology is the simplest and isn't even a network. This is just a serial cable replacement where one device can transmit to another device. It's nothing too fancy so I won't spend too much time on it.

A star network is perhaps the simplest real networking topology supported by 802.15.4. It defines a central coordinator and multiple satellite devices that have joined to the coordinator. Unlike an actual star network where the data needs to pass through the center of the star before going to another satellite, an 802.15.4 star network can send data to any device within listening range. However the topology exists because the coordinator always needs to exist to start the network and the devices need to join the coordinator before they can start transmitting on the network.

Star Network Topology

The MAC layer also defines the services required for a peer-to-peer network where any device can transmit to any other device on the network. However if the receiving device is outside the listening range of the transmitting device, then the frame needs to be somehow forwarded until it reaches the destination. This forwarding mechanism is where the boundary lies between 802.15.4 and Zigbee, since Zigbee defines the mechanism and rules for forwarding frames across a network. 

Incidentally, although Zigbee is touted as supporting a mesh network, the actual Zigbee network topology is called a clustered star network. The reason that it follows this topology is because the Zigbee End Devices (ZEDs) are not allowed to perform any routing. Hence the ZEDs are just satellites to their parents. In this type of topology, only the Zigbee Routers (ZRs) are allowed to route frames to each other. A true mesh network would allow routing from any device to any other device, which implies that all devices need to have routing capabilities.

Clustered Star Topology

 

802.15.4 Frame Formats

An generic 802.15.4 frame consists of the PHY header, MAC header, MAC data payload, and the frame checksum. There are four specific types of frames that are defined by the 802.15.4 specification and the frame type is defined in the Frame Control Field, located in the first two bytes of the MAC header. After the general frame format diagram, I'll cover each individual frame type.

802.15.4 General Frame Format

 

  • Beacon:
    • The beacon frame is a special frame that is used to transmit network information and also synchronize devices on the network and can only be transmitted by full function devices. In Zigbee, the beacon is used to transmit network information and is only used for network discovery.
Beacon Frame Format

  • Data:
    • The data frame is the basic and most common frame. It's used to transmit data and can be sent as a unicast or broadcast frame. A unicast frame means that it will only go to the device specified in the destination address. A broadcast frame means that it will go out to all devices within listening range on the network.
Data Frame Format

  • Command:
    • Command frames are used for network management and control and have a command ID associated with them. The command ID will identify the type of command that is being requested and the command frame recipient will respond accordingly.
Command Frame Format

  • Acknowledge:
    • If a frame is received with its ack_request flag set, then that means that the frame requires an ACK to inform the transmitter that it was received properly. The receiver will then transmit an ACK frame which basically consists of the frame's unique identifier (DSN) and a frame ID that identifies it as an ACK.
ACK Frame Format


Addressing

There are two types of addresses in 802.15.4:

  • Extended address
    • This is an 8-byte address that is used as a universal, unique identifier for the device and will differentiate it from all other devices in the world. It is similar to the MAC address of an Ethernet device. The IEEE 64 bit address is known as the extended unique identifier (EUI) and consists of the 24-bit organizationally unique identifier (OUI) a.k.a. company ID, and a 40-bit unique identifier assigned by the company that owns the OUI. The address range needs to be purchased from the IEEE.
  • Short address
    • This is a 2-byte address that is unique only on the network that the device has joined to. It is the main addressing method used in a Zigbee network to identify a device and also serves the purpose of determining the position of the device within the Zigbee tree routing hierarchy.

 Indirect Data Transfers

Indirect transfers are used to send data to an RFD (Zigbee end device). Since it is not possible for a parent to know when a child RFD is sleeping, it cannot simply send a frame to it at any time. Hence it will buffer all frames destined to the child device. The child device will poll the parent at a set interval determined by the implementation and retrieve any pending frames for it. 

In order to poll the parent, the child sends a special frame called the data request command frame to the parent. If the parent has data for the child, the parent will indicate it in the "frame pending" field of the ACK. That will let the child know that it should keep its receiver on for the incoming data frame. Otherwise, if the ACK indicates no frames, the child will turn off its transceiver and go back to sleep.

Indirect Transfer Sequence Diagram

Network and Energy Scanning

802.15.4 defines a generic scan mechanism that allows the device to perform different types of scans. The ones most often used by Zigbee are the energy scan and the network scan. The network scan is used for Zigbee network discovery and the energy scan is used in conjunction with the network scan for Zigbee network formation.

An energy scan is a relatively simple operation where a device turns on its receiver and samples the energy level for a certain amount of time. The scan is performed on all channels that are allowed to the device, and the results of the energy scan will tell the device how much noise or interference exists on a channel. This will be useful for the device in determining an optimal channel to form a network on. 

A network scan consists of a device broadcasting a beacon request command frame. This is a command frame with an ID of "beacon request" and it will be received by all devices on the network. If an FFD receives a beacon request command frame, it must respond with a beacon frame containing information about itself and the network. The scanning device will then collect all the beacons and compile a list of FFDs within listening range as well as the different networks that exist on that channel.

Network Scan Sequence Diagram



Association

Association is the process of a device joining to a parent node. Association is very dependent on the upper layer for many of the decisions on joining criteria, so in this sense, it's basically a service that is used by the upper layer, Zigbee in this case, to join devices to the network. That being said, let's take a closer look at the association sequence. 

The association process occurs after a device finishes its network scan and chooses a suitable parent to join. The choice of a suitable parent is determined by the Zigbee stack. Once a parent is chosen, the device will issue an association request command frame to the potential parent. When the parent receives the request, it will determine if it has the capacity to add another device and is permitting other devices to join it. This is also determined by the Zigbee layer. The potential parent will then issue an association response command frame telling the device whether the join was successful or not. If it was successful, the response frame will also contain the short address that will be used to identify the node on the network. It might be kind of hard to follow so I tried to illustrate the data flow in the following sequence diagram.

You might notice that there's a slight complication where the association response is sent via indirect data transfer. This is because the parent can't send the response directly to the child in the case that the child is asleep so it uses an indirect transfer instead.

Association Sequence Diagram

 

Well, I guess that covers the major areas that I wanted to hit for the MAC layer in this part. The next part will get into the data and management services descriptions and some of the minutiae of the MAC layer, and hopefully wrap things up so I can get started on the Zigbee portion.


Thursday, July 21, 2011

Fwd: MAC OS keyboard shortcut

http://support.apple.com/kb/ht1343

Last Modified: March 03, 2011
Article: HT1343
Old Article: 75459

Summary
Learn about common Mac OS X keyboard shortcuts. A keyboard shortcut is
a way to invoke a function in Mac OS X by pressing a combination of
keys on your keyboard.

Products Affected
Mac OS X 10.0, Mac OS X 10.3, Mac OS X 10.2, Mac OS X 10.1, Mac OS X
10.4, Mac OS X 10.6, Mac OS X 10.5
To use a keyboard shortcut, or key combination, you press a modifier
key with a character key. For example, pressing the Command key (the
key with a  symbol) and the "c" key at the same time copies whatever
is currently selected (text, graphics, and so forth) into the
Clipboard. This is also known as the Command-C key combination (or
keyboard shortcut).

A modifier key is a part of many key combinations. A modifier key
alters the way other keystrokes or mouse clicks are interpreted by Mac
OS X. Modifier keys include: Command, Control, Option, Shift, Caps
Lock, and the fn key (if your keyboard has a fn key).

Here are the modifier key symbols you can see in Mac OS X menus:

 (Command key) - On some Apple keyboards, this key also has an Apple logo ()
 (Control key)
 (Option key) - "Alt" may also appear on this key
 (Shift key)
 (Caps Lock) - Toggles Caps Lock on or off
fn (Function key)

Startup keyboard shortcuts

Press the key or key combination until the expected function
occurs/appears (for example, hold Option during startup until Startup
Manager appears, or Shift until "Safe Boot" appears). Tip: If a
startup function doesn't work and you use a third-party keyboard,
connect an Apple keyboard and try again.

Key or key combination  What it does
Option  Display all bootable volumes (Startup Manager)
Shift   Perform Safe Boot (start up in Safe Mode)
C       Start from a bootable disc (DVD, CD)
T       Start in FireWire target disk mode
N       Start from NetBoot server
X       Force Mac OS X startup (if non-Mac OS X startup volumes are present)
Command-V       Start in Verbose Mode
Command-S       Start in Single User Mode

Finder keyboard shortcuts

Key combination What it does
Command-A       Select all items in the front Finder window (or desktop if
no window is open)
Option-Command-A        Deselect all items
Shift-Command-A Open the Applications folder
Command-C       Copy selected item/text to the Clipboard
Shift-Command-C Open the Computer window
Command-D       Duplicate selected item
Shift-Command-D Open desktop folder
Command-E       Eject
Command-F       Find any matching Spotlight attribute
Shift-Command-F Find Spotlight file name matches
Option-Command-F        Navigate to the search field in an already-open
Spotlight window
Shift-Command-G Go to Folder
Shift-Command-H Open the Home folder of the currently logged-in user account
Command-I       Get Info
Option-Command-I        Show Inspector
Control-Command-I       Get Summary Info
Shift-Command-I Open iDisk
Command-J       Show View Options
Command-K       Connect to Server
Shift-Command-K Open Network window
Command-L       Make alias of the selected item
Command-M       Minimize window
Option-Command-M        Minimize all windows
Command-N       New Finder window
Shift-Command-N New folder
Option-Command-N        New Smart Folder
Command-O       Open selected item
Shift-Command-Q Log Out
Option-Shift-Command-Q  Log Out immediately
Command-R       Show original (of alias)
Command-T       Add to Sidebar
Shift-Command-T Add to Favorites
Option-Command-T        Hide Toolbar / Show Toolbar in Finder windows
Shift-Command-U Open Utilities folder
Command-V       Paste
Command-W       Close window
Option-Command-W        Close all windows
Command-X       Cut
Option-Command-Y        Slideshow (Mac OS X 10.5 or later)
Command-Z       Undo / Redo
Command-1       View as Icon
Command-2       View as List
Command-3       View as Columns
Command-4       View as Cover Flow (Mac OS X 10.5 or later)
Command-, (Command and the comma key)   Open Finder preferences
Command-` (the Grave accent key--above Tab key on a US English
keyboard layout)        Cycle through open Finder windows
Command-Shift-? Open Mac Help
Option-Shift-Command-Esc (hold for three seconds) - Mac OS X v10.5,
v10.6 or later only     Force Quit front-most application
Command-[       Back
Command-]       Forward
Command-Up Arrow        Open enclosed folder
Control-Command-Up Arrow        Open enclosed folder in a new window
Command-Down Arrow      Open highlighted item
Command-Tab     Switch application--cycle forward
Shift-Command-Tab       Switch application--cycle backward
Command-Delete  Move to Trash
Shift-Command-Delete    Empty Trash
Option-Shift-Command-Delete     Empty Trash without confirmation dialog
Spacebar (or Command-Y) Quick Look (Mac OS X 10.5 or later)
Command key while dragging      Move dragged item to other volume/location
(pointer icon changes while key is held--see this article)
Option key while dragging       Copy dragged item (pointer icon changes
while key is held--see this article)
Option-Command key combination while dragging   Make alias of dragged
item (pointer icon changes while key is held--see this article)


Application and other Mac OS X keyboard commands

Note: Some applications may not support all of the below application
key combinations.

Key combination What it does
Command-Space   Show or hide the Spotlight search field (if multiple
languages are installed, may rotate through enabled script systems)
Control-A       Move to beginning of line/paragraph
Control-B       Move one character backward
Control-D       Delete the character in front of the cursor
Control-E       Move to end of line/paragraph
Control-F       Move one character forward
Control-H       Delete the character behind the cursor
Control-K       Delete from the character in front of the cursor to the end
of the line/paragraph
Control-L       Center the cursor/selection in the visible area
Control-N       Move down one line
Control-O       Insert a new line after the cursor
Control-P       Move up one line
Control-T       Transpose the character behind the cursor and the character
in front of the cursor
Control-V       Move down one page
Option-Delete   Delete the word that is left of the cursor, as well as
any spaces or punctuation after the word
Option-Command-Space    Show the Spotlight search results window (if
multiple languages are installed, may rotate through keyboard layouts
and input methods within a script)
Command-Tab     Move forward to the next most recently used application in
a list of open applications
Shift-Command-Tab       Move backward through a list of open applications
(sorted by recent use)
Shift-Tab       Navigate through controls in a reverse direction
Control-Tab     Move focus to the next grouping of controls in a dialog or
the next table (when Tab moves to the next cell)
Shift-Control-Tab       Move focus to the previous grouping of controls
Command-esc     Open Front Row (if installed)
Option-Eject    Eject from secondary optical media drive (if one is installed)
Control-Eject   Show shutdown dialog
Option-Command-Eject    Put the computer to sleep
Control-Command-Eject   Quit all applications (after giving you a chance
to save changes to open documents), then restart the computer
Control Option-Command-Eject    Quit all applications (after giving you a
chance to save changes to open documents), then shut down the computer
fn-Delete       Forward Delete (on portable Macs' built-in keyboard)
Control-F1      Toggle full keyboard access on or off
Control-F2      Move focus to the menu bar
Control-F3      Move focus to the Dock
Control-F4      Move focus to the active (or next) window
Shift-Control-F4        Move focus to the previously active window
Control-F5      Move focus to the toolbar.
Control-F6      Move focus to the first (or next) panel
Shift-Control-F6        Move focus to the previous panel
Control-F7      Temporarily override the current keyboard access mode in
windows and dialogs
F9      Tile or untile all open windows
F10     Tile or untile all open windows in the currently active application
F11     Hide or show all open windows
F12     Hide or display Dashboard
Command-`       Activate the next open window in the frontmost application
Shift-Command-` Activate the previous open window in the frontmost application
Option-Command-`        Move focus to the window drawer
Command- - (minus)      Decrease the size of the selected item
Command-{       Left-align a selection
Command-}       Right-align a selection
Command-|       Center-align a selection
Command-:       Display the Spelling window
Command-;       Find misspelled words in the document
Command-,       Open the front application's preferences window (if it
supports this keyboard shortcut)
Option-Control-Command-,        Decrease screen contrast
Option-Control-Command-.        Increase screen contrast
Command-?       Open the application's help in Help Viewer
Option-Command-/        Turn font smoothing on or off
Shift-Command-= Increase the size of the selected item
Shift-Command-3 Capture the screen to a file
Shift-Control-Command-3 Capture the screen to the Clipboard
Shift-Command-4 Capture a selection to a file
Shift-Control-Command-4 Capture a selection to the Clipboard
Command-A       Highlight every item in a document or window, or all
characters in a text field
Command-B       Boldface the selected text or toggle boldfaced text on and off
Command-C       Copy the selected data to the Clipboard
Shift-Command-C Display the Colors window
Option-Command-C        Copy the style of the selected text
Control-Command-C       Copy the formatting settings of the selected item
and store on the Clipboard
Option-Command-D        Show or hide the Dock
Command-Control D       Display the definition of the selected word in the
Dictionary application
Command-E       Use the selection for a find
Command-F       Open a Find window
Option-Command-F        Move to the search field control
Command-G       Find the next occurrence of the selection
Shift-Command-G Find the previous occurrence of the selection
Command-H       Hide the windows of the currently running application
Option-Command-H        Hide the windows of all other running applications
Command-I       Italicize the selected text or toggle italic text on or off
Option-Command-I        Display an inspector window
Command-J       Scroll to a selection
Command-M       Minimize the active window to the Dock
Option-Command-M        Minimize all windows of the active application
to the Dock
Command-N       Create a new document in the frontmost application
Command-O       Display a dialog for choosing a document to open in the
frontmost application
Command-P       Display the Print dialog
Shift-Command-P Display a dialog for specifying printing parameters (Page Setup)
Command-Q       Quit the frontmost application
Command-S       Save the active document
Shift-Command-S Display the Save As dialog
Command-T       Display the Fonts window
Option-Command-T        Show or hide a toolbar
Command-U       Underline the selected text or turn underlining on or off
Command-V       Paste the Clipboard contents at the insertion point
Option-Command-V        Apply the style of one object to the selected object
(Paste Style)
Option-Shift-Command-V  Apply the style of the surrounding text to the
inserted object (Paste and Match Style)
Control-Command-V       Apply formatting settings to the selected object
(Paste Ruler Command)
Command-W       Close the frontmost window
Shift-Command-W Close a file and its associated windows
Option-Command-W        Close all windows in the application without quitting it
Command-X       Remove the selection and store in the Clipboard
Command-Z       Undo previous command (some applications allow for
multiple Undos)
Shift-Command-Z Redo previous command (some applications allow for
multiple Redos)
Control-Right Arrow     Move focus to another value or cell within a view,
such as a table
Control-Left Arrow      Move focus to another value or cell within a view,
such as a table
Control-Down Arrow      Move focus to another value or cell within a view,
such as a table
Control-Up Arrow        Move focus to another value or cell within a view,
such as a table
Command-Right Arrow     Move the text insertion point to the end of
the current line
Command-Left Arrow      Move the text insertion point to the beginning of
the current line
Command-Down Arrow      Move the text insertion point to the end of the document
Command-Up Arrow        Move the text insertion point to the beginning
of the document
Shift-Command-Right Arrow

Select text between the insertion point and the end of the current line (*)
Shift-Command-Left Arrow        Select text between the insertion point and
the beginning of the current line (*)
Shift-Right Arrow       Extend text selection one character to the right (*)
Shift-Left Arrow        Extend text selection one character to the left (*)
Shift-Command-Up Arrow  Select text between the insertion point and the
beginning of the document (*)
Shift-Command-Down Arrow        Select text between the insertion point and
the end of the document (*)
Shift-Up Arrow  Extend text selection to the line above, to the nearest
character boundary at the same horizontal location (*)
Shift-Down Arrow        Extend text selection to the line below, to the
nearest character boundary at the same horizontal location (*)
Shift-Option-Right Arrow        Extend text selection to the end of the
current word, then to the end of the following word if pressed again
(*)
Shift-Option-Left Arrow Extend text selection to the beginning of the
current word, then to the beginning of the following word if pressed
again (*)
Shift-Option-Down Arrow Extend text selection to the end of the
current paragraph, then to the end of the following paragraph if
pressed again (*)
Shift-Option-Up Arrow   Extend text selection to the beginning of the
current paragraph, then to the beginning of the following paragraph if
pressed again (*)
Control-Space   Toggle between the current and previous input sources
Option-Control-Space    Toggle through all enabled input sources
Option-Command-esc      Force Quit
(*) Note: If no text is selected, the extension begins at the
insertion point. If text is selected by dragging, then the extension
begins at the selection boundary. Reversing the direction of the
selection deselects the appropriate unit.


Universal Access - VoiceOver keyboard commands

For information about VoiceOver key combination differences in Mac OS
X v10.6, see this article.

Key combination What it does
Command-F5 or
fn Command-F5   Turn VoiceOver on or off
Control Option-F8 or
fn Control Option-F8    Open VoiceOver Utility
Control Option-F7 or
fn Control Option-F7    Display VoiceOver menu
Control Option-;
or fn Control Option-;  Enable/disable VoiceOver Control Option-lock
Option-Command-8 or
fn Command-F11  Turn on Zoom
Option-Command-+        Zoom In
Option-Command- - (minus)       Zoom Out
Option-Control-Command-8        Invert/revert the screen colors
Control Option-Command-,        Reduce contrast
Control Option-Command-.        Increase contrast
Note: You may need to enable "Use all F1, F2, etc. keys as standard
keys" in Keyboard preferences for the VoiceOver menu and utility to
work.


http://support.apple.com/kb/ht1343

Universal Access - Mouse Keys

When Mouse Keys is turned on in Universal Access preferences, you can
use the keyboard or numeric keypad keys to move the mouse pointer. If
your computer doesn't have a numeric keypad, use the Fn (function)
key.

Key combination What it does
8       Move Up
2       Move Down
4       Move Left
6       Move Right
1       Move Diagonally Bottom Left
3       Move Diagonally Bottom Right
7       Move Diagonally Top Left
9       Move Diagonally Top Right
5       Press Mouse Button
0       Hold Mouse Button
. (period on number pad)        Release Hold Mouse Button
See also: Shortcuts for Mouse Keys.

Tuesday, April 12, 2011

USB Cable Color Code

Standard USB Pinout & Cable Color Code

Pin Wire Color Function
1 Red V BUS (+5V)
2 White D-
3 Green D+
4 Black Ground

Mini-USB Type-A Pinout & Cable Color Code

Pin Wire Color Function
1 Red V BUS (+5V)
2 White D-
3 Green D+
4 Joined to pin 5 ID
5 Black Ground

Mini-USB Type-B Pinout & Cable Color Code

Pin Wire Color Function
1 Red V BUS (+5V)
2 White D-
3 Green D+
4 Not connected (*) ID
5 Black Ground

(*) Sometimes  joined to pin 5 via a resistor

Thursday, April 07, 2011

Understanding USB OTG - difference between OTG and USB host/device

http://www.edn.com/article/492321-Understanding_USB_On_The_Go.php


The USB specification introduced a simple and inexpensive infrastructure for easily connecting multiple external peripherals to a PC. That was several years ago; today, more than 500 million peripheral devices are designed with USB ports, making USB the market's dominant I/O-connectivity standard. The widespread availability of USB peripherals is now driving non-PC applications, such as mobile, handheld, and embedded post-PC applications, to adopt USB for direct-I/O connections. In addition, many devices that have traditionally functioned as peripherals now require direct connections to other devices. USB's greatest limitation—its lack of support for point-to-point communication between devices—has deterred its use in consumer-electronic devices, such as mobile phones and PDAs. However, these devices are gaining popularity and intelligence, increasing the need for direct connections among them. The answer to this requirement is in a developing standard called USB OTG (USB On-The-Go), a supplement to the USB specification that eliminates the requirement for a PC to act as host in exchanges of data among connected devices.

There has been much speculation—and, unfortunately, some misinformation—regarding USB OTG. The OTG specification's goal is to enhance certain USB peripherals to enable them to also act as hosts for a selected set of peripherals. OTG introduces point-to-point communication between these enhanced USB peripherals. OTG's complexity comes from the requirement that these dual-role devices be able to directly exchange data with each other. Moreover, because the specification targets portable devices with significant power constraints, the initial OTG host must supply only a small amount of power.

Two connected devices take turns functioning as the bus host and the peripheral, thus maintaining the current USB host/peripheral architecture model. The OTG host always initiates communication with a normal bus-enumeration process (bus reset, acquisition of USB descriptors, and peripheral-device configuration). After these steps, the device serving as OTG host may transfer data to and from an OTG device performing as a peripheral. The OTG specification defines a mechanism for exchanging the roles of OTG host and peripheral. The initial role of each device is defined by which mini plug a user inserts into its receptacle.

There are two types of OTG devices: dual-role devices and peripheral-only devices. A dual-role device can function as either a USB peripheral or an OTG host. Dual-role devices must be able to supply at least 8 mA on VBUS. Though a peripheral-only device has no host capabilities, it must be able to request a dual-role device to communicate with it. Dual-role devices must minimally operate at full speed. Operation at high speed is optional. Peripheral-only OTG devices may operate at any of USB's three signaling rates.

OTG dual-role devices support only a subset of all USB devices (potentially, only one). Supported devices may be other instances of the same OTG dual-role device, other dual-role devices, or self-powered USB peripherals that the dual-role device can power. The dual-role device must provide drivers for the listed supported devices. For example, an OTG still-image camera may have a driver for a specific printer or for a set of printers. In such a case, a user will be able to print from that camera to only the specific printer or the set of printers; it is unlikely that he or she will be able to print to every USB printer. The dual-role device's vendor must provide drivers for all of the supported devices. An OTG-device vendor that claims to support a class of devices, such as keyboards, that meet the power requirements for OTG peripherals must supply the corresponding class driver.

Cables and connectors

The USB 2.0 specification defines three types of connector pairs (plugs and receptacles): the standard-A, the standard-B, and the mini-B. The mini-B connector was developed for smaller peripherals, such as mobile phones. Because work on OTG began before completion of this mini connector, a new pin, the ID pin, was added to the plug in anticipation of OTG's needs and was left unconnected in the mini-B plug.

The OTG specification introduces a fourth plug, the mini-A, and two receptacles, mini-A and mini-AB. The differences between the mini-A and mini-B connectors are as follows. First, each plug is keyed so that the mini-A plug does not fit into a mini-B receptacle, and a mini-B plug does not fit into a mini-A receptacle. However, the mini-AB receptacle accepts either a mini-A or a mini-B plug. Second, the mini-A plug's ID pin is shorted to ground. The overmoldings of the two plugs are different; the mini-A plug has a more oval shape, whereas the mini-B plug is more square. Last, the plastic inside the plugs and receptacles is color-coded. Inside the mini-A plug and receptacle, the plastic is white; inside the mini-B plug and receptacle, the plastic is black; and inside the mini-AB receptacle, the plastic is gray.

The USB 2.0 specification defines two cables: the standard-A to standard-B and the standard-A to mini-B. OTG defines two more cables: the mini-A to standard-B and the mini-A to mini-B. The end-to-end delay of the mini-A-to-mini-B cables has been reduced to allow the use of adapters at the A end of the cable.

Adapters are required to allow for connecting different combinations of devices. For example, connecting a USB device with a captive cable and a standard-A plug to an OTG dual-role device requires a standard-A-receptacle-to-mini-A-plug adapter. Conversely, connecting an OTG device with a captive cable and a mini-A plug to a standard-A port requires a mini-A-receptacle-to-standard-A-plug adapter. The only permitted usage of the mini-A receptacle is on an adapter.

There are no usability issues when users are connecting two dual-role devices. However, when a user is connecting a peripheral-only device to an OTG dual-role device, he or she might plug the mini-B end of the cable into the dual-role device and then try plugging the mini-A end of the cable into the peripheral-only device's mini-B receptacle. Because the mini-B receptacle is keyed to prevent its accepting mini-A plugs, users should let the differences in the cable ends guide them to reverse the cable connections. The color-coding inside the plugs and receptacles plus the overmolding requirements for the plugs can also be a guide.

Dual-role devices

Because each OTG dual-role device incorporates a mini-AB receptacle, a mini-A-to-mini-B cable can directly interconnect the devices. Users will perceive no difference in the devices based on the cable connection. That is, users will not know which device is the initial OTG host and which is initially the peripheral.

A dual-role device's initial role is defined by which end of the cable a user inserts into the device's mini-AB receptacle. The dual-role device with the mini-A plug is the initial OTG host, also known as the A-device. Conversely, the dual-role device with the mini-B plug is the initial peripheral, also called the B-device. The dual-role device determines which end of the cable to insert by whether or not the ID pin is shorted to the GND pin.

The A-device must supply the voltage on VBUS when a communication session is in progress. This key difference between the A- and the B-devices causes the two connected devices to be unequal and prevents a peer-to-peer connection. Because the A-device supplies the voltage on VBUS and, therefore, controls when a communication session occurs, the B-device requires a mechanism for requesting a communication session. This mechanism is the SRP (Session Request Protocol).

Peripheral-only OTG devices

Peripheral-only OTG devices are normal USB peripherals, but they also support the SRP. These devices must have an OTG capability descriptor, which indicates that the device supports the SRP but is not a dual-role device. Last, peripheral-only OTG devices may use only the B receptacles or must have a captive cable with a mini-A plug attached. Peripheral-only OTG devices may not use the mini-AB receptacle.

The SRP is the mechanism for a peripheral-only device and a dual-role device, configured as a B-device, to request a communication session with a dual-role device configured as an A-device. This protocol consists of two signaling methods generated by the B-device: data-line pulsing and VBUS pulsing.

The A-device must detect one of these two methods and respond by starting a communication session. Two protocols are defined because having them simplifies implementing A-devices, which need to be designed to respond to only one of the two protocols. (There are small advantages and disadvantages in responding to either method.) There is virtually no added cost, other than some extra firmware, in having B-devices generate both methods. Dual-role and OTG peripheral-only devices must be capable of generating the SRP.

First, the B-device executes data-line pulsing; the B-device must pulse its pullup resistor for 5 to 10 msec. The B-device must then drive VBUS (VBUS pulsing) for a period long enough to charge a capacitance on VBUS . The capacitance is smaller than 13 µF to at least 2.1V. OTG devices have a capacitance of 6.5 µF or less but do not charge above 2V a VBUS capacitance of 96 µF or more. (Standard hosts have a capacitance of 96 µF or more.) This limitation prevents the VBUS current from the B-device from damaging standard host ports.

Exchanging device roles

The OTG specification defines a negotiation protocol, the HNP (Host Negotiation Protocol). This protocol provides a means by which the A- and B-devices can exchange the OTG host and peripheral roles.

Because the A-device is by default the bus host, it supplies the voltage on VBUS. When the A-device drives, the voltage rises above a valid level, and the B-device asserts its pullup resistor. When detecting a connection, the A-device resets and enumerates the B-device. The A-device then uses the functions that the B-device provides. Once the A-device finishes using the B-device, it may determine that the B-device is a dual-role device by querying for the B-device's OTG-capability descriptor. If the B-device responds with a valid OTG-capability descriptor that indicates it supports HNP, the A-device generates a set-feature command (HNP_Enable), which informs the B-device that it may assume the host role once the bus is suspended. (The A-device can also determine that the B-device is a dual-role device by successfully completing this set-feature command.) The A-device then suspends the bus.

The B-device signals that it wishes to assume the host role by signaling a disconnect (deasserting its pullup resistor if operating at full speed or deasserting its pulldown resistors if operating at high speed). In response to the B-device's disconnect, the A-device asserts its pullup resistor and operates as a peripheral. After the B-device resets and enumerates the A-device, the B-device may use the functions that the A-device provides. Once the B-device finishes with the A-device's functions, the B-device suspends the bus and asserts its pullup resistor, returning to operation as a peripheral. Detecting the bus suspend, the A-device signals a disconnect and resumes the host role. If the B-device is a dual-role device, and the A-device doesn't wish to use the B-device's functions, the A-device reissues the same set-feature command and then suspends the bus. If the HNP-enabled B-device fails to signal its request to assume the host role within a specified time frame, the A-device can end the session by dropping VBUS.

If the B-device initiates a session, the A-device may skip enumeration after reset by issuing the set-feature (HNP_Enable) command while the B-device is still in the default state. If the command succeeds—that is, if the B-device is a dual-role device—the A-device suspends the bus. If the command fails—that is, if the B-device operates only as a peripheral—the A-device enumerates the B-device and, if possible, services the reason for the session request.

Differences with USB 2.0

Because portable devices are typically battery-powered, forcing such devices to source a relatively large amount of current would result in very short battery life. The current-driving capability is often unnecessary anyway, because the device connected to the portable device is often self-powered. Instead of providing 100 or 500 mA at its port, a dual-role device must provide at least 8 mA. Dual-role devices are allowed to provide more current to accommodate additional peripherals but are not required to do so.

Another key difference is the VBUS capacitance at the connector. OTG dual-role devices have a capacitance of 1 to 6.5 µF. Standard hosts have a capacitance of 96 µF or more. This difference is significant during the SRP. When an OTG device performs VBUS pulsing, it drives a charge onto the VBUS line through either a constant current source or a resistor. If the OTG device is connected to a standard host, the voltage will not be driven above 2V, thereby avoiding any possible damage to the host. However, because OTG devices have much smaller capacitance than standard hosts, another OTG device will have its VBUS line driven above 2.1V.

Section 7.1.2.2 of the USB 2.0 specification defines four test points corresponding to the connectivity from host silicon (TP1) to host connector (TP2) to peripheral connector (TP3) to peripheral silicon (TP4). The maximum allowable delay is 30 nsec. Section 7.1.16 of the USB 2.0 specification limits the cable delay (from TP2 to TP3) to 26 nsec. Because of the possible use of adapters, which are allowed a 1-nsec delay, any cable with a mini-A plug is limited to a cable delay of 25 nsec. Using a 5m standard-B-to-standard-A cable with a standard-A-receptacle-to-mini-A-plug adapter violates, by 1 nsec, the 26-nsec limitation. However, when operating as peripherals, OTG devices have an only 1-nsec delay between TP3 and TP4, and, when operating as OTG hosts, a 1-nsec delay between TP1 and TP2. Therefore, the 30-nsec delay between host and peripheral silicon is preserved.

Compliance program

A compliance-specification parallel to the OTG specification is under development. The document will define a compliance program that includes OTG-device role-exchange-support testing, OTG-host signal-quality testing, session-start-protocol-support testing, peripheral-only-device power-constraint testing and end-user-experience testing. The USB-IF's (USB Interface Forum's) current USB 2.0 peripheral-compliance program is a precursor to the future compliance program. Because OTG devices are USB peripherals with the additional ability to directly communicate with other OTG devices, they must pass both the USB-IF-compliance program and the OTG-compliance program to be considered OTG-compliant.

The USB OTG specification introduces new mechanisms to enable new applications for USB peripherals. Only the drivers that the OTG dual-role device contains limit the number of combinations of OTG devices that users can connect. The introduction of OTG will not result in every OTG dual-role device communicating with all other OTG devices. Initially, it will support only a small number of devices. However, the list of supported OTG dual-role devices will quickly grow. In the future, vendors of OTG dual-role devices will likely include a mechanism for downloading drivers to their devices to expand the number of supported devices.





The author acknowledges the work and contributions of the following people, who helped to draft and edit the USB OTG specification: David Murray of TransDimension; David Wooten of Cypress Semiconductor; Zong Liang Wu, PhD, of TransDimension; and Mark Yi of Opti Inc.

Author Information
Kosta Koeman is a staff software engineer with Cypress Semiconductor (Woodinville, WA), where he has worked for more than a year. He holds a BSEE from the University of Washington (Seattle) and an MSEE from the Oregon Graduate Institute (Beaverton, OR).