Dynamically determining a primary or slave assignment based on receiving a power signal from the cable at the port of a device

Methods, apparatuses, and computer program products for dynamically determining a primary or slave assignment based on an order of cable connection between two devices are provided. Embodiments include detecting, by a first device, insertion of one end of a cable into a port of the first device; determining, by the first device, whether a power signal is received from the cable at the port of the first device; if the power signal is received, performing, by the first device, a data transfer operation over the cable as a slave device to a second device that is coupled to the other end of the cable; and if the power signal is not received, performing, by the first device, a data transfer operation over the cable as a primary device to the second device that is coupled to the other end of the cable.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The field of the invention is data processing, or, more specifically, methods, apparatuses, and computer program products for dynamically determining a primary or slave assignment based on an order of cable connection between two devices.

2. Description of Related Art

In a primary/slave model of communication, one device or process has unidirectional control over one or more of the other devices. In some systems, a primary device is elected from a group of eligible devices with the other devices acting in the role of slaves. The standard Universal Serial Bus (USB) specification is an example of a primary/slave architecture in which the USB host (also known as a primary device) acts as the protocol master and a USB device acts as a peripheral device (also known as a slave device). According to the USB specification, only the primary device can schedule the configuration and data transfers over the link. The USB slave devices cannot initiate data transfers, they only respond to requests given by the primary device. In the USB On-The-Go (USB OTG) specification, USB devices such as digital audio players or mobile phones may also act as a primary device that hosts another USB device. That is, USB OTG enables a USB device to perform both the primary device and slave device roles. The default link configuration is that the device connected to the ‘A’ end of the cable (known as A-device) acts as the USB host and the device coupled to the ‘B’ end of the cable (known as B-device) acts as the USB Peripheral device. That is, the A-device acts as the primary device, while the B-device acts as the slave device. The OTG A-device is a power supplier and an OTG B-device is a power consumer. If a user connects the A and B devices in the wrong direction for the task they want to perform, the USB OTG specification includes protocols that enable the devices to switch roles. That is, devices using this protocol rely on additional configuration transfers between the devices to determine which device will act as primary device and which will act as a slave device. In a datacenter with hundreds or even thousands of cables and devices with limited device user interfaces, it may be difficult for an administrator to determine if the devices are coupled correctly.

SUMMARY OF THE INVENTION

Methods, apparatuses, and computer program products for dynamically determining a primary or slave assignment based on an order of cable connection between two devices are provided. Embodiments include detecting, by a first device, insertion of one end of a cable into a port of the first device; determining, by the first device, whether a power signal is received from the cable at the port of the first device; if the power signal is received, performing, by the first device, a data transfer operation over the cable as a slave device to a second device that is coupled to the other end of the cable; and if the power signal is not received, performing, by the first device, a data transfer operation over the cable as a primary device to the second device that is coupled to the other end of the cable.

DETAILED DESCRIPTION OF EXEMPLARY EMBODIMENTS

Exemplary methods, apparatus, and products for dynamically determining a primary or slave assignment based on an order of cable connection between two devices in accordance with the present invention are described with reference to the accompanying drawings, beginning withFIG. 1. Dynamically determining a primary or slave assignment based on an order of cable connection between two devices in accordance with the present invention is generally implemented with computers, that is, with automated computing machinery.FIG. 1sets forth a block diagram of automated computing machinery comprising an exemplary computer (152) useful in dynamically determining a primary or slave assignment based on an order of cable connection between two devices according to embodiments of the present invention. The computer (152) ofFIG. 1includes at least one computer processor (156) or ‘CPU’ as well as random access memory (168) (‘RAM’) which is connected through a high speed memory bus (166) and bus adapter (158) to processor (156) and to other components of the computer (152).

Stored in RAM (168) is an assignment module (193) that includes computer program instructions for dynamically determining a primary or slave assignment based on an order of cable connection between two devices according to embodiments of the present invention. Specifically, the assignment module (193) includes computer program instructions that when executed by the processor (156) cause the first device (152) to carry out the steps of: detecting, by a first device, insertion of one end of a cable into a port of the first device; determining, by the first device, whether a power signal is received from the cable at the port of the first device; if the power signal is received, performing, by the first device, a data transfer operation over the cable as a slave device to a second device that is coupled to the other end of the cable; and if the power signal is not received, performing, by the first device, a data transfer operation over the cable as a primary device to the second device that is coupled to the other end of the cable.

Also stored in RAM (168) is an operating system (154). Operating systems useful dynamically determining a primary or slave assignment based on an order of cable connection between two devices according to embodiments of the present invention include UNIX™, Linux™, Microsoft XP™, AIX™, IBM's i5/OS™, and others as will occur to those of skill in the art. The operating system (154) and the assignment module (193) in the example ofFIG. 1are shown in RAM (168), but many components of such software typically are stored in non-volatile memory also, such as, for example, on a disk drive (170).

The computer (152) ofFIG. 1includes disk drive adapter (172) coupled through expansion bus (160) and bus adapter (158) to processor (156) and other components of the computer (152). Disk drive adapter (172) connects non-volatile data storage to the computer (152) in the form of disk drive (170). Disk drive adapters useful in computers for dynamically determining a primary or slave assignment based on an order of cable connection between two devices according to embodiments of the present invention include Integrated Drive Electronics (‘IDE’) adapters, Small Computer System Interface (‘SCSI’) adapters, and others as will occur to those of skill in the art. Non-volatile computer memory also may be implemented for as an optical disk drive, electrically erasable programmable read-only memory (so-called ‘EEPROM’ or ‘Flash’ memory), RAM drives, and so on, as will occur to those of skill in the art.

In the example ofFIG. 1, the I/O adapter (178) is coupled to a port (191) that is in turn is coupled to a second device (188) via a cable (185). The port (191) may be any type of I/O port. For example, the port (191) may be a USB port and the second device (188) may be a USB device such as a printer. According to embodiments of the present invention, the order in which the cable (185) is plugged into the devices (192,188) determines the assignment of the primary device and the slave device roles among the devices (192,188). For example, if the first device (152) is plugged into the cable (185) first and then the second device (188) is coupled to the cable (185), the first device (152) will assume the role of primary device and the second device (188) will assume the role of slave device. In this example, if a user desired to reassign those roles, the user would disconnect the cable (185) from the devices (152,188) and plug the cable first into the second device (188) and then into the first device (152). By assigning the roles of primary device and slave device in accordance with an order of cable connection, a user may immediately know the role assignments without examining a user interface. In addition, switching the roles simply involves switching the order of cable connection—not transmitting additional configuration information between the two devices.

The exemplary computer (152) ofFIG. 1includes a communications adapter (167) for data communications with other computers (182) and for data communications with a data communications network (100). Such data communications may be carried out serially through RS-232 connections, through external buses such as a Universal Serial Bus (‘USB’), through data communications networks such as IP data communications networks, and in other ways as will occur to those of skill in the art. Communications adapters implement the hardware level of data communications through which one computer sends data communications to another computer, directly or through a data communications network. Examples of communications adapters useful for dynamically determining a primary or slave assignment based on an order of cable connection between two devices according to embodiments of the present invention include modems for wired dial-up communications, Ethernet (IEEE 802.3) adapters for wired data communications network communications, and 802.11 adapters for wireless data communications network communications.

FIG. 2sets forth a diagram of an apparatus that includes a first device (152) and a second device (188) connected by a cable (185) with a visual indicator (250) that dynamically indicates a primary device or slave device assignment based on an order of cable connection between the two devices according to embodiments of the present invention. In the example ofFIG. 2, on each of the cable is a plug (260) that includes a dynamically variable visual indicator (250). A plug is used to couple a cable with a port of a device. For example, when the cable is a USB cable, the plug may be a Standard-A plug type USB, a B-plug, mini-A plug, a mini-B plug, or any other type of plug compatible with the specific cable type.

A visual indicator may be any type of indicator capable of indicating to a user of the cable a particular status corresponding to slave device and primary device assignments. Examples of visual indicators include a light emitting diode (LED), a light bulb, a switch, and many others aw will occur to those of skill in the art. The visual indicator (250) ofFIG. 2is configured to determine which end of the cable (185) received power first from one of the first device (152) and the second device (188). For example the cable (185) may include a latch that switches based on current direction within the cable, thus determining which end received power first. The visual indicator (250) ofFIG. 2is also configured to indicate whether the particular end of the cable (185) is coupled to a slave device or to a primary device. This enables a user to quickly examine the cable (185) to determine if the devices (152,188) are properly connected. If the cable (185) is not connected properly, a user would simply decouple the cable (185) from the devices (152,188) and plug the cable (185) into the devices (152,188) in an order that would establish the desired slave device and primary device assignments. For example, as illustrated inFIG. 2, the visual indicator (250) on the end of the cable plugged into the first device (152) is ‘on’ and the visual indicator (250) on the end of the cable plugged into the second device (188) is ‘off,’ thus indicating that the first device (152) is assigned the primary device role and the second device (188) is assigned the slave device role. If a user desired to change those assignments, the user could unplug both ends of the cable (185) from the devices (152,188) and plug in one end of the cable (185) to the second device (188) and plug in the other end of the cable (185) to the first device (152). As a result, the visual indicator attached to the end of the cable (185) inserted into the second device (188) would be ‘on’ and the other visual indicator (250) attached to the end of the cable (185) inserted into the first device (152) would be ‘off.’ In the example ofFIG. 2, the visual indicator (250) is attached to each end of the cable (185) at a plug. However, according to embodiments of the present invention, a visual indicator may be attached anywhere on a cable and may include one or more visual indications to indicate the primary device and slave device assignments.

For further explanation,FIG. 3sets forth a flow chart illustrating an exemplary method for dynamically determining a primary or slave assignment based on an order of cable connection between two devices according to embodiments of the present invention. The method ofFIG. 3includes detecting (302), by a first device (152), insertion of one end of a cable (185) into a port (191) of the first device (152). Detecting (302) insertion of one end of a cable (185) into a port (191) of the first device (152) may be carried out by receiving a message indicating that a hardware change corresponding to the port (191) has occurred; and periodically measuring a capacitance on the port (191) to determine whether there is another device attached.

The method ofFIG. 3also includes determining (304), by the first device (152), whether a power signal is received from the cable (185) at the port (191) of the first device (152). Determining (304) whether a power signal is received from the cable (185) at the port (191) of the first device (152) may be carried out by detecting a change in voltage level at one or more pins within the port (191).

The method ofFIG. 3includes if the power signal is received, performing (306), by the first device (152), a data transfer operation over the cable (185) as a slave device to a second device (188) that is coupled to the other end of the cable (185). Performing (306) a data transfer operation over the cable (185) as a slave device to a second device (188) that is coupled to the other end of the cable (185) may be carried out by receiving via the cable (185), a data transfer request from the second device (188); and transmitting via the cable (185), a data transfer request response to the second device (188).

The method ofFIG. 3also includes if the power signal is not received, performing (308), by the first device (152), a data transfer operation over the cable (185) as a primary device to the second device (188) that is coupled to the other end of the cable (185). Performing (308) a data transfer operation over the cable (185) as a primary device to the second device (188) that is coupled to the other end of the cable (185) may be carried out by transmitting via the cable (185), a data transfer request to the second device (188); and receiving via the cable (185), a data transfer request response from the second device (188).

For further explanation,FIG. 4sets forth a flow chart illustrating a further exemplary method for dynamically determining a primary or slave assignment based on an order of cable connection between two devices according to embodiments of the present invention. The method ofFIG. 4is similar to the method ofFIG. 3in that the method ofFIG. 4also includes detecting (302), by a first device (152), insertion of one end of a cable (185) into a port (191) of the first device (152); determining (304), by the first device (152), whether a power signal is received from the cable (185) at the port (191) of the first device (152); if the power signal is received, performing (306), by the first device (152), a data transfer operation over the cable (185) as a slave device to a second device (188) that is coupled to the other end of the cable (185); and if the power signal is not received, performing (308), by the first device (152), a data transfer operation over the cable (185) as a primary device to the second device (188) that is coupled to the other end of the cable (185).

The method ofFIG. 4, however, also includes if the power signal is received, setting (402) a connection status (450) of the first device (152) to indicate that the first device (152) is a slave device to the second device (188). A connection status is a data value indicating whether the first device (152) is to act as a primary device or a slave device. Based on the connection status, the first device (152) may implement one or more slave device specific protocols or series of data transfer operations. For example, the first device (152) acting as a slave device may wait to receive data transfer requests and may not initiate data transfer requests. In addition, the assignment module (193) of the first device (152) may provide the connection status (450) to other applications, such as the operating system (154) ofFIG. 1. Setting (402) a connection status (450) of the first device (152) to indicate that the first device (152) is a slave device to the second device (188) may be carried out by storing a value within the first device (152).

The method ofFIG. 4also includes if the power signal is not received, setting (404) the connection status (450) of the first device (152) to indicate that the first device (152) is a primary device to the second device (188). Based on the connection status, the first device (152) may implement one or more primary device specific protocols or series of data transfer operations. For example, the first device (152) acting as a primary device may supply the cable with power and initiate data transfer operations over the cable. Setting (404) the connection status (450) of the first device (152) to indicate that the first device (152) is a primary device to the second device (188) may be carried out by storing a value within the first device (152).