Peripheral device and control method for the same

Abstract: Disclosed is a device adapted to be connected as a peripheral device to a host (12) and comprising a status transmission section (32, 33) for obtaining status information indicative of an operating condition of the device and for sending status information to the host, and an interface (14) for establishing a communication link via a bus type communication medium with the host, the interface being adapted to send and receive data by means of either one of at least a first and a second transfer mode, wherein, in said first transfer mode, data sending and receiving are enabled in response to an on-demand type input/output command from the host, and, in said second transfer mode, data sending and receiving are enabled in response to a periodic input/output command from the host. The status transmission section (32, 33) comprises first sending means (34) for transmitting status information by means of the first transfer mode, second sending means (35) for transmitting status information by means of the second transfer mode, and means for selecting said first or said second sending means according to the type of status information.

Description: The present invention relates to a peripheral device such as a printer or scanner capable of being connected to and communicating with a host device, and to a control method for the peripheral device. The Universal Serial Bus (simply referred to as "USB" hereafter) is an interface for connecting peripheral devices, such as printers and scanners, and a host such as a personal computer with one another and for enabling the exchange of user and control data between the peripheral devices and the host. The USB is rapidly becoming the standard interface for connecting such peripheral devices (simply called "device" below) to personal computers (simply called "PC" below). More specifically, USB is a bus standard for a serial cable connection enabling a PC to simultaneously access numerous devices with high data reliability while also enabling "hot swapping", i.e., the ability to insert a device into or remove a device from the USB chain while the host and/or other devices are operating without losing access to the devices that remain on the bus. Because of this combination of high data reliability and hot swapability, USB is expected to be become the industry-standard interface for PC peripheral connections. Data transmission between USB interface devices begins with the host sending a token packet to a device. To enable simultaneous access to a plurality of devices, the token packet contains a unique device address and device endpoint. The address identifies which device on the USB is being addressed, and the endpoint identifies the source of the data or data transfer, or the data recipient or consumer (sink). Following the token packet comes a data packet containing the data being communicated, and a handshake packet indicating the transfer status. USB uses the following four data transfer types, and transfers data by establishing a corresponding logical "pipe" between the host and device. Bulk transfers and the bulk transfer pipe are used for sending relatively large amounts of data, such as print and display data. Interrupt transfers and the interrupt transfer pipe are used for small amounts of data with a short service period. Control transfers and the control transfer pipe are used when a device is first connected to the bus to construct a logical device presence. Isochronous transfers and the isochronous transfer pipe are used for audio and other types of data requiring data to be delivered within certain time constraints. Sending a data stream in any of these transfer modes is called a "transaction", and comprises the above-described packet sequence. Frames sent at 1 ms intervals contain a plurality of transactions. Simultaneous communication between a host and multiple devices is achieved by sending these frames in succession. The handshake packet provides a retry function for the case an error occurs during transmission, thereby enabling large amounts of data to be reliably transferred at high speed. When the USB device communicating with the host is a printer, for example, data communicated between the host and device includes status information indicating the operating status of the printer, in addition to process data like bitmap data or other print data and control commands for controlling the printing mechanism. Typical status Information includes the on-line or off-line status of the printer, whether there is paper, whether the cover is open, if the buffer is full, whether there is ink, and any error status. The status information is normally sent from the printer to the host in response to a status request command, and is therefore sent to the host using the same bulk transfer type that is used to send print and command data from the host to the printer. A USB bulk transfer pipe is opened, however, only on demand, i.e., when (1) the host wants to send data to or receive data from the device and (2) the bus capacity (bandwidth) needed to transfer the data within a specific unit time is available. This means there is no way to assure when the data will be sent. This also means that information may not be transferred immediately when status information is transferred using a bulk transfer pipe, and various problems can result. For example, the host may continue sending process data even though the buffer is full, and data may therefore be lost. The host may also continue sending data even though the printer cover is open, and printing delays may thus occur. The interrupt transfer pipe, on the other hand, is periodically opened at regular short intervals, enabling a device to send data to the host immediately if there is data to send when the device is polled. The interrupt transfer pipe is thus given the highest level of service, providing good real-time performance. Data reliability is also extremely high because the transfer is retried at the next period if a bus error occurs and a transaction is lost. It is therefore possible to send status information using the interrupt transfer type, and thereby assure both immediacy and data reliability. However, the size of the data packets that can be sent by interrupt transfer is limited in order to assure bandwidth availability. It is also preferable to reserve bandwidth for bulk transfers in order to maintain an acceptable transfer speed for process data. As a result, it is also desirable to limit data transfers using the interrupt transfer pipe. An object of the present invention is therefore to provide a peripheral device and a control method therefor whereby the immediacy of status information transfers can be assured, bandwidth sufficient for efficient transfer of process data and commands can be assured, and a high data transfer rate can be assured. This object is achieved with a device as claimed in claim 1, a method as claimed in claim 5 and a storage medium as claimed in claim 9. Preferred embodiments of the invention are subject-matter of the dependent claims. To achieve the above object, a peripheral device according to the present invention assures immediate, virtually real-time response while maximizing bandwidth available for such transfers as the bulk transfers of the USB by selectively transferring status information using a first transfer mode such as a bulk transfer pipe of the USB or a second transfer mode such as an interrupt transfer pipe of the USB, rather than simply sending all status information by either the first or the second transfer mode. The selection between these two transfer modes is made according to the type of status information or the cause of the transmission of status information. Most cases in which status information is sent in response to a request from the host, are cases in which the next process is executed after the requested status information is confirmed by the host, and immediate response is not as necessary. Furthermore, when the requested status information is urgently required, the host knows that the status information is urgent, and can therefore obtain the required status information at the appropriate timing using the first transfer mode such as a bulk transfer pipe in case of the USB. On the other hand, the host does not know when status information is autonomically generated by the peripheral device, and this autonomic status information is therefore urgent. The urgency and timely transfer of such autonomic status information can be assured in this case by sending it to the host using the second transfer mode such as an interrupt transfer pipe in case of the USB. When status information is thus communicated through an interface using at least two different transfer pipes, as does the USB, a peripheral device and peripheral device control method according to the present invention transfers only status information of the greatest urgency (immediacy) using the second transfer mode, that is, the transfer mode having the shortest service period (like the USB interrupt transfer pipe), and uses the second transfer mode (like the USB bulk transfer pipe) to send status information in all other cases. It is therefore possible to transfer status information using a transfer mode appropriate to the immediacy of the information, thereby transferring status information without occupying unnecessary USB bandwidth, and thus assuring sufficient transmission speed for process data using a bulk transfer pipe. It is likewise possible to sufficiently assure the immediacy of status information without impairing the performance of a peripheral device having processing means such as a printing mechanism or reading mechanism for outputting data to or inputting data from an external source, and a controller for sending or receiving process data processed by this processing means by means of the first transfer mode. Other objects and attainments together with a fuller understanding of the invention will become apparent and appreciated by referring to the following description of preferred embodiments taken in conjunction with the accompanying drawings, in which: Fig. 1 is a block diagram of a POS system according to a preferred embodiment of the present invention; Fig. 2 is a typical block diagram of the printer shown in Fig. 1; Fig. 3 shows the typical USB packet structure, (a) showing a token packet, (b) showing a data packet, and (c) showing a handshake packet; Fig. 4 shows the typical USB frame structure; and Fig. 5 is a flow chart of the basic status information transmission process of the printer shown in Fig. 1. Fig. 1 is a block diagram of a typical POS system 11 (forming one example of a data processing system) in which (peripheral) devices according to the present invention are interconnected and connected to a host using USB Interfaces. As shown in Fig. 1, this exemplary POS system 11 comprises a printer 15, customer display 16, card reader 17, and bar code scanner 18 connected to a personal computer host 12 through a hub 13. The printer 15, customer display 16, card reader 17, and bar code scanner 18 each have a USB interface 14 enabling data communication with the host 12 via a USB. A preferred embodiment of the invention is described below using the printer 15 as exemplary of any connectable device. The typical configuration of a printer 16 in this preferred embodiment is described further below with reference to the block diagram in Fig. 2. This printer 15 comprises a printing mechanism 31 for printing, and a program-controlled control device 32 for controlling the printing mechanism 31. The control device 32 typically includes a CPU, a ROM for storing the program and/or various printer setting information, and a RAM as a working buffer for print data and control commands. The CPU, ROM, and RAM are not shown in the figures. The USB interface 14 is connected by way of a client driver 33 to the control device 32. The USB interface 14 comprises a port 21, universal controller 22, and USB driver 23. The port 21 provides the hardware connection environment of the USB interface. The universal controller 22 is for hardware control of communications through the port 21 such as driving of signal lines in a predetermined sequence. The USB driver 23 is for software control of the communications such as packetizing of the communicated data. The USB driver 23 includes a CPU, a ROM for storing the program for controlling the CPU, and a RAM as a working memory The control device 32 thus receives print data and control commands from the host 12 via the client driver 33 and USB driver 23. Note that the client driver is implemented as software running on hardware included in the control device 32. The USB driver 23 comprises a first transfer unit 24 for supporting a bulk transfer pipe; a second transfer unit 25 for supporting an interrupt transfer pipe; a third transfer unit 26 for supporting a control transfer pipe; and a fourth transfer unit 27 for supporting an isochronous transfer pipe. These transfer pipes are opened by a token packet 51 which is sent from the host 12. As shown in Fig. 3, this token packet 51 comprises: a packet ID (PID) 61 indicative of the packet type, that is, whether the host is to send or receive the data in the data packet; an address 62 for identifying a particular device on the USB; an endpoint 63 indicative of the destination in the device where the data is used or from which it originates; and a cyclic redundancy code (CRC) 64 for error checking. By thus declaring the address and endpoint in a token packet, and assigning a device to each pipe, data can be communicated substantially simultaneously between the host 12 and a plurality of devices using USB interfaces. Data communication is in units of frames, each frame including a plurality of pipes. The way of performing transactions through pipes is described next. When the host 12 wants to send data to a device, it sends from its USB interface 14 a token packet 51 containing a PID 61 indicating that the host is sending, the address 62 of the device to which the host 12 is sending data (the address of the printer 15 in this example), and an endpoint 63 indicating the end point of the data in the addressed device, here the control device 32. The USB interface 14 of the printer 15 then decodes the information in the token packet 51. If the address 62 is the address (number) assigned to the printer 15 and the endpoint 63 in the token packet 51 designates the control device 32 of the printer 15, the printer 15 accepts the token packet 51 and the data packet 52 following the token packet 51. A data packet 52 contains a PID 61, data 65, and a CRC 64. When the host 12 wants to receive data from a device, e.g., the printer 15, the host 12 sends to the printer 15 a token packet 51 containing a PID 61 indicating that data may be sent (hereafter an "IN token"). When this IN token is received by the USB driver 23, it sends the output data readied by the control device 32. Thus, the token packet 51 used by the host to establish a communication with a device may be regarded as an input/output command instructing the device to input (receive) data from or output (send) data to the host. When data packet 52 sending or receiving is completed, a handshake packet 53 is exchanged. The handshake packet 53 contains only a PID 61, enabling one of three states to be returned: ACK, acknowledging that the data was received without error; NAK, indicating that the data was not received; and STALL, indicating that the receiving side has stalled (i.e., that data communication is not possible because of some error). When the host 12 detects NAK in the handshake packet 53, it is possible to retry sending the same data packet 52 and thus increase the reliability of data transfers. When STALL is detected, the host can attempt to resolve the cause of the stall through the device. As shown in Fig. 4, the host 12 transfers data in frames F at a 1 ms interval, which is the frame period of the USB standard (USB time). A frame F starts with a start of frame (SOF) token 54. Following the SOF token 54, interrupt transfer transactions 55, if any, are run. The interrupt transfer period can be set for each device. If it is set to the shortest period for each device, an interrupt transfer transaction 55 is included for each device (four devices in the described example) in each frame, and if there is sufficient room left in the frame F, a bulk transfer transaction 56 is included. If the transfer of data requiring isochrony is required, an isochronous transfer transaction follows the interrupt transfer transaction 55. Packets are exchanged in an interrupt transfer transaction 55 in the same manner as described above for bulk transfers. That is, an IN token 61 is first issued from the host 12, and if a device has data to be sent in response to the IN token 51, it is immediately packed into a data packet 52 and sent. The host responds by sending a handshake packet 53, enabling the device to determine whether the data was received without error. If there is no data to send, the device returns an NAK handshake packet 53 to the host 12, and the host 12 then releases the interrupt transfer pipe opened for that device. As a result, each device is polled by an interrupt transfer transaction 55 at the frame period timing, when the polling period is shortest, and can thus immediately send any data required to the host 12. Returning to Fig. 2, a printer 15 according to this preferred embodiment receives print data and control commands from the host and sends status information indicative of a printer status to the host 12 through the USB interface 14. Status information detected by the control device 32 is passed to the client driver 33, and sent via the USB interface 14 to the host 12 at an appropriate time. Of the four pipes used by the USB interface and described above, status information can conceivably be sent by each of the following three: bulk transfer, interrupt transfer, and isochronous transfer. A dedicated part of the USB bandwidth (frame) is reserved for isochronous transfers because of the need to minimize delay in order to assure isochrony. However, resending the data is not attempted even when data is lost, and data reliability is therefore not great. The isochronous transfer pipe is therefore not desirable for sending status information. The bulk transfer pipe is well suited to communicating large amounts of data, but can only be opened when there is sufficient USB bandwidth available. Data transfer speed and timing are therefore not assured. Data reliability is high, however, because data receipt is confirmed by the handshake packet, and resending the data is attempted again at the next bulk transfer period when data is lost. If the interrupt transfer period is set to the shortest possible interval for a respective device, that device will be polled every frame F. Data can therefore be sent substantially immediately from the device to the host 12. The device also retries sending at the next period if data is lost, and data reliability is therefore high. It should be noted, however, that the USB standard gives priority to periodic access attempts such as interrupt transfers and isochronous transfers. This means that if the bandwidth allocated to interrupt transfers occupies too much of a frame F, it may not be possible to assure sufficient bandwidth for bulk transfer transactions. Print data transmission speed may therefore drop. The client driver 33 in this exemplary printer 15 is, therefore, adapted to selectively use either the bulk transfer mode or the interrupt transfer mode. The client driver 33 can thus be thought of as comprising two different transfer means or transfer functions: a first transfer function 34 for sending status information by the bulk transfer mode, i.e., in response to an on-demand type input/output command from the host, and a second transfer function 36 for sending status information by the interrupt transfer mode, i.e., a periodic input/output command from the host. Status information is allocated to a particular transfer mode (pipe) for transmission to the host 12 according to the type of the status information, thus achieving both immediate status information transmission when needed while assuring sufficient bandwidth for bulk transfers. There are three reasons (causes) for the printer 15 to send status information to the host 12. First, the printer 15 sends status information in response to a status request command, i.e., a control command from the host. This status request command is temporarily buffered, similarly to print data and other normal control commands, and processed In the order received. Status information sent in response to this status request command is therefore of relatively low urgency, that is, immediacy, and can therefore be sent by the bulk transfer mode without causing any problems. Furthermore, because the status request command is sent from the host 12 to the printer 15, the host 12 is expecting the status information from the printer 15. As a result, the host 12 can, as necessary, obtain the status information at an appropriate timing by specifying the printer 16 address and sending an IN token 51. As a result, this exemplary printer 15 uses the bulk transfer mode, that is, first transfer function 34, for status information transmission. Second, the printer 15 sends status information in response to a real-time status request command. A real-time command sent from the host 12 and received by the printer 15 is processed before or instead of being stored in a buffer. Real-time commands are thus of high urgency, and are processed with priority over other commands and print data. It is therefore necessary for the printer 15 to send the status information to the host 12 at the earliest possible time. Because the status request command is sent from the host 12, however, the host 12 in this case, too, can issue frequent IN tokens 51 to the USB in an attempt to obtain the status information. The host 12 can therefore control the transmission timing or speed even for status information sent by a device in response to an urgent real-time status request command. As a result, this exemplary printer 15 uses the bulk transfer mode, that is, first transfer function 34, even in response to real-time status request commands. Third, the printer 15 initiates status information sending. This function for initiating status information transfer is called an Auto Status Back function (ASB), and enables the printer 15 to automatically send specific status information to the host 12 when conditions (a particular change in printer status) predefined by the host 12 are met. For example, if a printer cover open status is a predefined condition, the printer generates the status information when the printer cover is opened for some reason, and sends this status information to the host 12. This type of status information can lead to an unrecoverable error such as a loss of print data. Printing cannot continue if the cover is opened while printing is in progress or while print data is being sent from the host 12, for example, and it is therefore necessary to interrupt the print job. However, if the host continues to send print data while the job is interrupted, a print buffer overflow can occur, and data may be lost. It is therefore preferable for the printer 15 to send autonomically generated status information to the host 12 in real-time. Moreover, the host 12 has no way of knowing when such autonomic status information may be generated, and therefore cannot send an IN token 51 at a suitable timing to fetch this status information from the printer 15. An exemplary printer 15 according to this preferred embodiment therefore uses a second transfer function 35 to send such autonomic status information to the host 12 via an interrupt transfer pipe. As described above, the interrupt transfer pipe polls the device every frame, if set to the shortest possible timing, and the printer 15 can therefore send such status information to the host 12 in substantially real-time. Fig. 5 is a flow chart of the major steps in a process whereby this exemplary printer 15 sends status information to the host. When the process starts and the control device 32 produces status information (step 71 ), it is determined in step 72 whether the status information was autonomically generated, that is, if the status information was generated by the ASB function. If it is, the process waits for an IN token for an interrupt transfer (step 73). Upon detection of such IN token, when an interrupt transfer pipe has been established, the status information is sent (step 74). As described above, the interrupt transfer period can be set to the shortest possible service period, that is, the frame period. With such setting, every frame is a chance of sending status information which virtually means ASB status information can be sent to the host as soon as it is generated, i.e., in real-time. However, if step 72 reveals the status information was not generated by the ASB function, the process advances to step 75, which waits for a bulk transfer IN token. Upon detection of such IN token and establishment of a bulk transfer pipe, the status information is sent in step 76. Printer 15 using a USB interface to send status information to a host according to this exemplary embodiment thus uses an interrupt transfer pipe to send autonomically generated (ASB function) status information to the host, and uses a bulk transfer pipe to send status information in response to status request commands from the host. Urgent status information that is autonomically generated by the printer and that the host has no way of knowing when it will occur, can therefore be sent in real-time by the printer to the host. On the other hand, status information that is not urgent and for which the host can control the transfer timing can be sent using the bulk transfer pipe, thereby reducing the interrupt transfer load, preventing excess bandwidth from being occupied for interrupt transfers, and assuring sufficient bandwidth for bulk transfers. It is therefore possible to provide by means of the present invention a printer and a printer control method whereby the immediate, real-time communication of status information can be assured while also assuring sufficient bandwidth capacity and a fast data transfer rate. The control method shown in the flow chart in Fig. 5 is preferably implemented as a control program for controlling the CPU of the printer. The program may be stored on a magnetic disk or other machine-readable storage medium including ROM. When loaded in the printer, the printer will execute the program and, thereby, perform the process explained above. Loading such program from a storage medium, depending on the type of storage medium, may be performed in any of various ways well known to those skilled in the art. As has been mentioned before, a printer represents only one example of a device according to the present invention. The teachings of the invention can be applied to various other devices adapted to be connected to a data processing system. More specifically, the processes and configurations described above for printer 15 can also be used to send status (or comparable) information to a host from other devices such as the customer display 16, the card reader 17, and bar code scanner 18. Status information requested by the host has been described above as being sent by the bulk transfer mode, but it is also possible to send status information in response to urgent real-time status request commands by the interrupt transfer mode to the host, and to send only status information in response to normal (non-urgent) status request commands by the bulk transfer mode. This method of sending status information still leaves significantly more bandwidth for bulk transfers than would be left if the interrupt transfer pipe were used to send all status information, while assuring a real-time transfer of status information in response to real-time status request commands. The USB, however, is a bus in which both the sending and the receiving timing are controlled by the host. Even if the bulk transfer mode is used for a device to send status information to the host it is, therefore, possible to send status information at an appropriate timing in response to a request command from the host. The USB can therefore be optimally controlled to assure the immediacy of status information and maximize the transfer efficiency of other data by using an interrupt transfer pipe only for sending autonomic status information, the timing of which cannot be controlled by the host, and using a bulk transfer pipe for all other status information, the timing of which can be controlled by the host. As will be appreciated from the above description, whenever a host and a peripheral device are connected by a bus having a plurality of transfer modes for communication between the host and the peripheral device, the structure and method according to the present invention can be employed so as to send status information (or comparable information) to the host using either a first or a second transfer mode selected according to the nature of the information to be sent. It is, thus, to be understood, that the USB has been described only as an example of such a bus type connection between a peripheral device and a host device.

Claims: A device adapted to be connected as a peripheral device to a host (12) and comprising: a status transmission section (32, 33) for obtaining status information indicative of an operating condition of the device and for sending status information to the host, and an interface (14) for establishing a communication link via a bus type communication medium with the host, the interface being adapted to send and receive data by means of either one of at least a first and a second transfer mode, wherein, in said first transfer mode, data sending and receiving are enabled in response to an on-demand type input/output command from the host, and, in said second transfer mode, data sending and receiving are enabled in response to a periodic input/output command from the host, characterized in that said status transmission section (32, 33) comprises first sending means (34) for transmitting status information by means of the first transfer mode, second sending means (35) for transmitting status information by means of the second transfer mode, and means for selecting said first or said second sending means according to the cause of the status information transmission. The device as set forth in claim 1, wherein the first sending means (34) is adapted to send status information in response to a request from the host (12), and the second sending means (35) is adapted to send autonomous status information. The device as set forth in claim 1 or 2, comprising: processing means (32) for outputting data to or inputting data from an external source; and a controller (32) for sending or receiving by means of the first transfer mode process data processed by the processing means. The device as set forth in any one of claims 1 to 3, wherein said bus type communication medium is the Universal Serial Bus and the interface is a USB interface, the first transfer mode being the bulk transfer mode and the second transfer mode being the interrupt transfer mode. A method of controlling a device as defined in any one of claims 1 to 4 comprising: (a) detecting status information of the device, (b) selecting one of said first and second transfer modes depending on the cause of the status information transmission, and (c) sending the status information to the host (12) in the transfer mode selected in step (b). The method as set forth in claim 5, wherein said first transfer mode comprises sending said status information in response to a request from the host (12), and said second transfer mode comprises sending said status information autonomously. The method as set forth in claim 5 or 6, further comprising: generating process data and sending them by means of said first transfer mode to the host (12) and/or receiving process data by means of said first transfer mode from the host and processing the received process data. The method as set forth in claim 5, 6 or 7, wherein the first transfer mode is the bulk transfer mode and the second transfer mode is the interrupt transfer mode as supported by a USB interface. A storage medium carrying in machine-readable form a control program which when executed in the device according to any one of claims 1 to 4 implements the method as defined in any one of claims 5 to 8.

Inventors: EJIRI KEIGO, EJIRI, KEIGO
Applicants: SEIKO EPSON CORP, SEIKO EPSON CORPORATION
Application year: 1999
Main classification: G06F13
IPC codes: G06F13, G06F3