This application claims priority of Taiwanese Invention Patent Application No. 110140288, filed on Oct. 29, 2021.
The disclosure relates to an adapter, and more particularly to a communication interface adapter that is electrically connected between a computer device and a peripheral device for controlling signal transmission between the computer device and the peripheral device.
Computer systems that are used in retail, transportation and public areas are usually composed of a terminal computer and one or more peripheral devices, such as a printer, a barcode scanner, a webcam, a programmable keyboard, etc. Most of these peripheral devices are connected to the terminal computer using communication interfaces, for example but not limited to, the universal serial bus (USB). The terminal computer is usually installed with various application programs that are self-developed by a manufacturer of the terminal computer or developed by independent software developers for commercial or industrial applications. When an application program executed by the terminal computer needs to control one of the peripheral devices, the application program needs an application programming interface (API) provided by a supplier of the peripheral device to command the peripheral device to perform power on, power off, restart, or other actions.
However, the above practice will make the program application unable to support some relevant peripheral devices on the market because supportability of the program application depends on whether the suppliers of the peripheral devices have provided corresponding APIs to the developer of the application program. An application program can only command those of the peripheral devices, the suppliers of which have provided corresponding APIs to the developer of the application program, to perform desired actions such as power on, power off or restart.
Therefore, an object of the disclosure is to provide a communication interface adapter (for example but not limited to, a USB adapter) that can control signal transmission from a computer device to a peripheral device, so a software program of the computer device can control, through the communication interface adapter, any peripheral device that adopts the same communication interface as the communication interface adapter, without being limited to whether a supplier of the peripheral device has provided a corresponding API for use by a developer of the software program.
According to the disclosure, the communication interface adapter includes a first communication interface to be electrically connected to the computer device, a second communication interface to be electrically connected to the peripheral device, a microcontroller, a communication interface hub electrically connected to the first communication interface and the microcontroller, and a switch unit electrically connected between the communication interface hub and the second communication interface. The switch unit is controlled by the microcontroller to make or break connection between the communication interface hub and the second communication interface.
Another object of the disclosure is to provide a method of dynamic product identification (PID) assignment, which is applicable when a computer device is connected to multiple communication interface adapters. The method can solve a problem that may occur when the communication interface adapters have the same default PID that are assigned during production. The problem may cause an application program executed by the computer device to submit instructions to wrong peripheral devices. In the method, each of the communication interface adapters includes a first communication interface electrically connected to the computer device, a second communication interface electrically connected to a peripheral device, a microcontroller storing a PID of the communication interface adapter, a communication interface hub electrically connected to the first communication interface and the microcontroller, and a switch unit electrically connected between the communication interface hub and the second communication interface. The switch unit is controlled by the microcontroller to make or break connection between the communication interface hub and the second communication interface.
According to the disclosure, the method includes steps of: by the computer device, reading a peripheral device list that is stored in the computer device, the peripheral device list containing the PID of each of the communication interface adapters; by an identification module of the computer device, obtaining the PIDs of the communication interface adapters based on the peripheral device list, and, upon determining that the PIDs of at least two of the communication interface adapters are identical, assigning a replacement PID which is different from the PIDs of said the communication interface adapters, to one of the at least two of the communication interface adapters through a control module executed by the computer device, so as to replace the PID stored in said one of the at least two of the communication interface adapters with the replacement PID; by the computer device, updating the peripheral device list by using the replacement PID to replace the PID of said one of the at least two of the communication interface adapters contained in the peripheral device list; and by the identification module, recording, based on the peripheral device list thus updated and with respect to each peripheral device among those of the peripheral devices that are each connected to one of the communication interface adapters, a correspondence between the peripheral device and the communication interface adapter in a correspondence table of the computer device.
Yet another object of the disclosure is to provide a method for automatically diagnosing a peripheral device and, when the peripheral device is found to be in abnormal operation, recovering the peripheral device. In the method, a computer is provided to be connected to a plurality of communication interface adapters, each of which includes a first communication interface electrically connected to the computer device, a second communication interface electrically connected to a peripheral device, a microcontroller storing a PID of the communication interface adapter, a communication interface hub electrically connected to the first communication interface and the microcontroller and a switch unit electrically connected between the communication interface hub and the second communication interface. The switch unit is controlled by the microcontroller to make or break connection between the communication interface hub and the second communication interface.
According to the disclosure, the method includes steps of: by the computer device, reading a peripheral device list that is stored in the computer device, wherein the peripheral device list contains the PIDs of the communication interface adapters, and device information of the peripheral devices that are connected to the communication interface adapters; by the computer device, establishing a correspondence table that records, for each of the communication interface adapters, a correspondence between the communication interface adapter and the peripheral device that is connected to the communication interface adapter; by a diagnosis module of the computer device, periodically monitoring a status of each of the peripheral devices that is recorded in the correspondence table; upon determining that one of the peripheral devices is operating abnormally, by the diagnosis module, finding out, based on the correspondence table, one of the communication interface adapters that is connected to the peripheral device which is operating abnormally, and transmitting, through a control module executed by the computer device to said one of the communication interface adapters, a control signal that includes a reset instruction and a computer-provided PID identical to the PID of said one of the communication interface adapters; and upon receiving the control signal and determining that the computer-provided PID is identical to the PID stored in said one of the communication interface adapters, by said one of the communication interface adapters, controlling, based on the reset instruction, the peripheral device that is connected to said one of the communication interface adapters and that is operating abnormally to restart.
Other features and advantages of the disclosure will become apparent in the following detailed description of the embodiment(s) with reference to the accompanying drawings, of which:
Before the disclosure is described in greater detail, it should be noted that where considered appropriate, reference numerals or terminal portions of reference numerals have been repeated among the figures to indicate corresponding or analogous elements, which may optionally have similar characteristics.
Referring to
The microcontroller 13 stores a product identification (PID) (referred to as “controller-stored PID”) of the communication interface adapter 1. The communication interface hub 14 receives, from the computer device 2, a first communication interface control signal (referred to as “first control signal” hereinafter) that contains a PID (referred to as “computer-provided PID”) and a reset instruction, and transmits the first control signal to the microcontroller 13. Upon receipt of the first control signal and upon determining that the computer-provided PID is identical to the controller-stored PID (which confirms that the communication interface adapter 1 is the intended recipient of the first control signal), the microcontroller 13 controls operation of the switch unit 15 based on the reset instruction included in the first control signal, so as to break at least one of the electrical connections between the communication interface hub 14 and second communication interface 12 and then re-establish the same in order to restart the peripheral device 3 that is electrically connected to the communication interface adapter 1.
The first communication interface 11 includes a power terminal VCC1, a ground terminal GND1 and at least one data signal terminal. The second communication interface 12 includes a power terminal VCC2, a ground terminal GND2 and at least one data signal terminal. In this embodiment, each of the first communication interface 11 and the second communication interface 12 is exemplified as a USB connector, and thus includes two data signal terminals (referred to as a first signal terminal D1+ and a second signal terminal D1- for the first communication interface 11, and as a first signal terminal D2+ and a second signal terminal D2- for the second communication interface 12), but this disclosure is not limited in this respect. The communication interface hub 14 is electrically connected to the power terminal VCC2, the first signal terminal D2+, the second signal terminal D2-and the ground terminal GND2 respectively through a power signal path L0, a first signal path L1, a second signal path L2 and a ground signal path L3. The switch unit 15 includes a power switch SW0, a first signal switch SW1 and a second signal switch SW2. The power switch SW0 is disposed on the power signal path L0, and is controlled by the microcontroller 13 to make or break signal transmission on the power signal path L0. The first signal switch SW1 is disposed on the first signal path L1, and is controlled by the microcontroller 13 to make or break signal transmission on the first signal path L1. The second signal switch SW2 is disposed on the second signal path L2, and is controlled by the microcontroller 13 to make or break signal transmission on the second signal path L2.
Based on the above-mentioned configuration, a power signal outputted by the computer device 2 will be supplied to the peripheral device 3 through the first communication interface 11, the communication interface hub 14, the power signal path L0 and the second communication interface 12 when the power switch SW0 is in a conducting state, and a communication interface signal (e.g., a USB signal) outputted by the computer device 2 will be provided to the peripheral device 3 through the first communication interface 11, the communication interface hub 14, the first and second signal paths L1, L2, and the second communication interface 12 when the first and second signal switches SW1, SW2 are in the conducting state, so operation of the peripheral device 3 can be controlled by the computer device 2. In addition, the power signal and the communication interface signal are also transmitted to the microcontroller 13 through the communication interface hub 14 and signal lines between the communication interface hub 14 and the microcontroller 13, as shown in
When a processor (e.g., a central processing unit (CPU), not shown) of the computer device 2 executes a control module 21 (e.g., a software program installed in the computer device 2) to reset the peripheral device 3 that is electrically connected to the communication interface adapter 1, the control module 21 generates the first control signal, and the reset instruction contained in the first control signal requests that a reset action be performed with respect to the power signal (i.e., stopping supply of the power signal and then resupplying the power signal to the peripheral device 3). Then, the control module 21 employs a driver program (e.g., a USB driver) that is installed or built in an operating system of the computer device 2 to transmit the first control signal to the microcontroller 13 through the first communication interface 11 and the communication interface hub 14 of the communication interface adapter 1. Upon determining that the reset instruction contained in the first control signal requests that the reset action be performed with respect to the power signal and that the computer-provided PID is identical to the controller-stored PID, the microcontroller 13 turns the power switch SW0 off and then on, so the power signal supplied to the peripheral device 3 is temporarily interrupted and then recovered, so as to restart the peripheral device 3. As a result, the peripheral device 3 is reset after restarting.
In another case where the peripheral device 3 that is electrically connected to the communication interface adapter 1 is powered by another power source instead of by the computer device 2 (for example, voltages required by some devices, such as a printer, may be higher than a voltage that can be provided through an USB interface), when the computer device 2 executes the control module 21 to reset the peripheral device 3, the reset instruction of the first control signal generated by the control module 21 may request that a reset action be performed with respect to the communication interface signal transmitted to the peripheral device 3 (i.e., stopping transmission of the communication interface signal and then retransmitting the same to the peripheral device 3). Upon receipt of the first control signal and upon determining that the reset instruction included in the first control signal requests that the reset action be performed with respect to the communication interface signal transmitted to the peripheral device 3 and that the computer-provided PID is identical to the controller-stored PID, the microcontroller 13 turns the first signal switch SW1 and the second signal switch SW2 off simultaneously and then on simultaneously, so as to restart the peripheral device 3, making the peripheral device 3 receive the communication interface signal through the first signal path L1 and the second signal path L2 again.
In this embodiment, if the peripheral device 3 is powered by the computer device 2, the first signal switch SW1 and the second signal switch SW2 may be omitted from the communication interface adapter 1 that is electrically connected to the peripheral device 3 because restarting the peripheral device 3 can be done by controlling only the power switch SW0; if the power of the peripheral device 3 is not supplied by the computer device 2, the power switch SW0 may be omitted from the communication interface adapter 1 that is electrically connected to peripheral device 3 because restarting the peripheral device 3 can be done by controlling only the first signal switch SW1 and the second signal switch SW2.
Therefore, when an application program developed by an independent software developer demands to restart a peripheral device 3 but the supplier of the peripheral device 3 did not provide an API to the software developer, the application program may be configured to include the control module 21, so the computer device 2 can execute the control module 21 to enable the application program to restart the peripheral device 3 through the communication interface adapter 1 that interconnects the computer device 2 and the peripheral device 3.
In this embodiment, when the microcontroller 13 detects that the communication interface adapter 1 is being electrically connected to the computer device 2 (e.g., detecting receipt of the power signal from the computer device 2), the microcontroller 13 automatically controls the power switch SW0, the first signal switch SW1 and the second signal switch SW2 to be in the conducting state, so as to ensure that the peripheral device 3 is electrically connected to the computer device 2 through the communication interface adapter 1 when the peripheral device 3 is electrically connected to the communication interface adapter 1.
In a case that the microcontroller 13 supports a monitoring mechanism, such as a watchdog mechanism (e.g., including a watchdog timer), the monitoring mechanism may issue a restart signal to the microcontroller 13 upon detecting that a main program that is being executed by the microcontroller 13 has an error, so as to restart the microcontroller 13 to recover the microcontroller 13 to a normal operation state. In order to ensure that the peripheral device 3 is electrically connected to the computer device 2 after the microcontroller 13 of the communication interface adapter 1 restarts, the microcontroller 13 is configured to automatically control the power switch SW0, the first signal switch SW1 and the second signal switch SW2 to be in the conducting state when the microcontroller 13 restarts.
Assuming that the PIDs stored in the microcontrollers 13 of the communication interface adapters 1A, 1B are “001” and “002”, respectively, when the control module 21 that is included in the application program is operated to control, for example, the peripheral device 3B that is connected to the communication interface adapter 1B to restart, the first control signal generated by the control module 21 should include the reset instruction and the computer-provided PID that is identical to the PID “002” stored in the microcontroller 13 of the communication interface adapter 1B. Upon receipt of the first control signal and upon determining that the computer-provided PID is identical to the controller-stored PID of the communication interface adapter 1B, the microcontroller 13 of the communication interface adapter 1B controls operation of the switch unit 15 of the communication interface adapter 1B based on the reset instruction included in the first control signal to restart the peripheral device 3B.
In practice, the communication interface adapters 1 may be assigned the same PID (e.g., a default PID) during production, so the microcontrollers 13 of the communication interface adapters 1 that are electrically connected to the computer device 2 may have identical PIDs. However, in order to correctly control operation of a specified one of the communication interface adapters 1 that is electrically connected to the computer device 2, each of the controller-stored PIDs of the communication interface adapters 1 should be unique (i.e., the PIDs of devices that are electrically connected to the computer device 2 should be different from each other).
Referring to
In step S31, after the computer device 2 is powered on and establishes the peripheral device list, the identification module 22 automatically reads the peripheral device list stored in the computer device 2, and thus obtains the PIDs (i.e., the controller-stored PIDs) of the communication interface adapters 1A, 1B, 1C based on the peripheral device list.
In step S32, the identification module 22 determines whether some of the PIDs of the communication interface adapters 1A, 1B, 1C are identical. The flow goes to step S33 when the identification module 22 determines that the PIDs of at least two of the communication interface adapters 1 are identical, and ends when otherwise. In
In step S33, the identification module 22 assigns replacement PIDs respectively to the communication interface adapters 1B, 1C, so that each of the communication interface adapters 1B, 1C uses the respective replacement PID to replace the original controller-stored PID, thereby making each of the communication interface adapters 1A, 1B, 1C have a unique PID. In this embodiment, the identification module 22 first assigns a replacement PID, which is different from the PIDs of the communication interface adapters 1A, 1B, 1C, to the communication interface adapter 1B, so as to replace the PID stored in the communication interface adapter 1B with the replacement PID, as shown in
Subsequently, the identification module 22 notifies the control module 21 to disable the microcontrollers 13 of the communication interface adapters 1A, 1B (i.e., disabling the communication interface adapters 1 except for the communication interface adapter 1C), so the communication interface adapters 1A, 1B are unable to receive any signal from the computer device 2. Then, the identification module 22 generates a replacement PID for the communication interface adapter 1C having at most the predetermined maximum number of bits by either the random manner or the predetermined manner. Herein, the replacement PID for the communication interface adapter 1C is exemplified as “002”, and the identification module 22 transmits, through the control module 21, the second control signal that includes a PID of a target device (i.e., the computer-provided PID, which is the same as the PID “123” of the communication interface adapter 1C herein), the control instruction, and computer-provided data that contains the replacement PID “002”, to the microcontroller 13 of the communication interface adapter 1C. Upon receiving the second control signal and determining that the computer-provided PID is identical to the controller-stored PID of the communication interface adapter 1C (i.e., both being “123” in this case), the microcontroller 13 of the communication interface adapter 1C stores the replacement PID “002” as the controller-stored PID (i.e., using the replacement PID “002” to replace the controller-stored PID “123”), as shown in
After the dynamic PID assignment, the operating system of the computer device 2 will find that the controller-stored PIDs of the communication interface adapters 1B, 1C have been changed, and then update the peripheral device list by using the replacement PIDs for the communication interface adapters 1B, 1C to replace the PIDs of the communication interface adapters 1B, 1C contained in the peripheral device list.
In step S34, the identification module 22 records, based on the peripheral device list thus updated and with respect to each peripheral device 3 that is connected to one of the communication interface adapters 1 (as opposed to a peripheral device 3 that is connected to the computer device 2 without a connection through a communication interface adapter 1), a correspondence between the peripheral device 3 and the communication interface adapter 1 in a correspondence table of the computer device 2. Table 1 illustrates an exemplary correspondence table for a case as shown in
Furthermore, as illustrated in
In step S81, the diagnosis module 23 periodically monitors a status of each of the peripheral devices 3 that is recorded in the correspondence table. For example, the diagnosis module 23 may read and detect operation information of the peripheral devices 3 through the operating system of the computer device 2. In step S82, with respect to each of the peripheral devices 3, the diagnosis module 23 determines whether the peripheral device 3 is operating abnormally. For example, the diagnosis module 23 may determine whether the peripheral device 3 cannot be detected, whether the peripheral device 3 cannot be identified, whether an error related to a driver program of the peripheral devices 3 has been detected, whether the peripheral device 3 is operating intermittently, etc. If any one of the abovementioned determinations is affirmative, the diagnosis module 23 determines that the peripheral device 3 is operating abnormally, and the flow goes to step S83 for the peripheral device 3.
In step S83, the diagnosis module 23 determines, based on the correspondence table, whether the peripheral device 3 that is operating abnormally has a corresponding communication interface adapter 1. The flow goes to step S84 when the determination of step S83 is affirmative (e.g., the peripheral device 3 that is operating abnormally is the peripheral device 3B, which has a corresponding communication interface adapter 1B), and goes to step S85 when otherwise, which means that the peripheral device 3 that is operating abnormally is a directly-connected peripheral device, which is exemplified as the peripheral device 3D hereinafter.
In step S84, the diagnosis module 23 finds out, based on the correspondence table, the communication interface adapter 1 that is connected to the peripheral device 3 which is operating abnormally. Hereinafter, the peripheral device 3 that is operating abnormally is exemplified as the peripheral device 3B, and the corresponding one of the communication interface adapters 1 is the communication interface adapters 1B. The diagnosis module 23 obtains the controller-stored PID of the communication interface adapter 1B from the peripheral device list, and transmits, through the control module 21 to the microcontroller 13 of the communication interface adapter 1B, the first control signal that contains the reset instruction and a computer-provided PID identical to the PID of the communication interface adapter 1B as recorded in the peripheral device list.
Upon receiving the first control signal and determining that the computer-provided PID is identical to the controller-stored PID of the communication interface adapter 1B, the microcontroller 13 of the communication interface adapter 1B controls, based on the reset instruction, the peripheral device 3B that is connected to the communication interface adapter 1B and that is operating abnormally to restart, so as to recover the peripheral device 3B.
In step S85, the diagnosis module 23 notifies the operating system of the computer device 2 to use a built-in reset function to reset the directly-connected peripheral device 3D that is operating abnormally, so as to recover the peripheral device 3D to the normal operation state.
In summary, the communication interface adapter 1 that is electrically connected between the computer device 2 and the peripheral device 3 enables the computer device 2 that executes the application program to submit instructions to the microcontroller 13 of the communication interface adapter 1, so as to control operation of the switch unit 15 to restart the peripheral device 3. As a result, the ability of the application program to control the peripheral device 3 is not limited to whether the supplier of the peripheral device 3 has provided a corresponding API for use by the developer of the application program. In addition, the embodiment of this disclosure further provides a method for automatically diagnosing the peripheral device 3, and, when the peripheral device 3 is found to be operating abnormally, the computer device 2 can make the peripheral device 3 perform hardware reset by restarting the peripheral device 3, thereby recovering the peripheral device 3 to the normal operation state.
In the description above, for the purposes of explanation, numerous specific details have been set forth in order to provide a thorough understanding of the embodiment(s). It will be apparent, however, to one skilled in the art, that one or more other embodiments may be practiced without some of these specific details. It should also be appreciated that reference throughout this specification to “one embodiment,” “an embodiment,” an embodiment with an indication of an ordinal number and so forth means that a particular feature, structure, or characteristic may be included in the practice of the disclosure. It should be further appreciated that in the description, various features are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of various inventive aspects, and that one or more features or specific details from one embodiment may be practiced together with one or more features or specific details from another embodiment, where appropriate, in the practice of the disclosure.
While the disclosure has been described in connection with what is (are) considered the exemplary embodiment(s), it is understood that this disclosure is not limited to the disclosed embodiment(s) but is intended to cover various arrangements included within the spirit and scope of the broadest interpretation so as to encompass all such modifications and equivalent arrangements.
Number | Date | Country | Kind |
---|---|---|---|
110140288 | Oct 2021 | TW | national |