Buffer memory managing method and printing apparatus adopting the method

Abstract: In a printing apparatus which performs printing operation in an emulation mode designated by a host computer, data necessary for the designated emulation mode is down-loaded. First, a fixed data buffer size is reserved in accordance with the emulation mode which requires the maximum amount of data to be down-loaded. Then, a ring buffer for receiving data is assigned next to the fixed data buffer. After the data size to be down loaded is determined, portions of area reserved for the fixed data buffer which becomes unnecessary is reassigned as print data buffer. Since the print data buffer is a ring buffer, if no received data is stored at an address which is at the border between the fixed data buffer and the print data buffer, it is possible to move the border. Therefore, the printing apparatus waits until a state of the print data buffer changes to a state in which no received data is stored at the address at the border, then expands the print data ring buffer.

Description: The present invention relates to a buffer memory managing method in, for example, a printing apparatus and, more particularly, to a method of managing a print buffer for storing data transmitted from a host computer, and the like, and a printing apparatus adapting the method. A printing apparatus which can be controlled by a plurality of different printer control language is known. In such the printing apparatus, an emulation mode corresponding to the printer control language to be used is informed by a host computer, and data necessary for the emulation is loaded down from the host computer. Thereafter, the printing apparatus receives print data written in the printer control language and performs a printing operation in accordance with the emulation mode by using the down-loaded data for the emulation. For example, there are cases where a plurality of application softwares correspond to respective printing apparatuses. In such cases, the printing apparatus actually connected to a host computer emulates other printing apparatuses used by respective applications. Therefore, the data which is necessary for the emulation has to be loaded down to the actually connected printing apparatus. In order to register the data which is necessary for the emulation, e.g., symbols and special fonts, in the printing apparatus from an application software, a memory area, called fixed data buffer, is reserved in the printing apparatus. The size of the fixed data buffer depends upon emulation modes. Such a printing apparatus which emulates two or more printing apparatuses and automatically switches emulation modes for the emulations must reserve the maximum fixed data buffer size required by the emulation modes in a memory of the printing apparatus when the apparatus is powered on. However, when the fixed data buffer size is set to the maximum size required by the emulation modes, more than necessary memory area may be reserved as the fixed data buffer in an emulation mode which does not require a large fixed data buffer size, which greatly wastes a memory area. Further, the larger the size of a print data buffer provided in a printing apparatus for receiving data transmitted from a host computer, the larger the amount of data which can be transmitted in one operation from a host computer. Accordingly, a large print data buffer in the printing apparatus is preferred since a host computer can be released early. However, a large print data buffer requires increase in the capacity of memory, which is a disadvantage in terms of cost. The present invention has been made in consideration of the above situation, and has as its object to eliminate a wasted area in a limited memory area in a printing apparatus and effectively use the memory by reassigning the wasted area as a print data buffer, thereby providing a buffer managing method capable of increasing the print data buffer size in the memory of the printing apparatus without increasing a manufacturing cost and providing a printing apparatus adapting the method. A buffer managing method as defined independent claim 1 is provide in accordance with one aspect of the present invention for managing a data storage area, assigned in a memory of a predetermined size, and a ring buffer which is sequentially addressable to the data storage area, the method comprising: a calculation step of calculating a size which can be reduced from the data storage area; a determination step of determining no received data is stored at the end of the ring buffer; and an expansion step of expanding the ring buffer by the size which is calculated at the calculation step by moving a border between the ring buffer and the data storage area if it is determined at the determination step that no received data is stored at the end of the ring buffer. Further, another aspect of the present invention as defined in independent claim 6 provides a printing apparatus capable of executing an emulation mode designated by a host device out of a plurality of emulation modes, the apparatus comprising: a memory having a predetermined size of storage area; assigning means for assigning an area of the memory corresponding to a maximum fixed data buffer size required by the plurality of emulation modes as a fixed data buffer, and assigning the rest of an area of the memory as a ring buffer which stores data received from the host device; receiving means which receives data from the host device; determination means for determining an emulation mode in accordance with data received by the receiving means; calculation means for calculating a difference between the fixed data buffer size which is required by the determined emulation mode and the maximum fixed data buffer size assigned by the assigning means; judging means for judging whether or not no received data is stored at the end of the ring buffer; and an expansion means for expanding the ring buffer by the size calculated by the calculation means by moving a border between the ring buffer and the fixed data buffer if it is determined that no received data is stored at the end of the ring buffer by the judging means. Furthermore, a further aspect of the present invention provides a storage medium as defined in claim 10 comprising a computer usable medium having computer readable program code means embodied in the medium for managing a data storage area, assigned in a memory of a predetermined size, and a ring buffer which is sequentially addressable to the data storage area, the product including: first computer readable program code means for calculating a size which can be reduced from the data storage area; second computer readable program code means for determining no received data is stored at the end of the ring buffer; and third computer readable program code means for expanding the ring buffer by the size which is calculated at the calculation step by moving a border between the ring buffer and the data storage area if it is determined at the determination step that no received data is stored at the end of the ring buffer. With the aforesaid configurations, when a plurality of different emulation modes are switched automatically, the fixed data buffer size necessary in each emulation mode can be individually set, thereby effectively utilizing a memory area. Further, since the remaining memory area is used as a print data buffer, it is possible to increase the print data buffer size without increasing the capacity of the memory. Embodiments of the present invention will ow be described with reference to the accompanying drawings, in which: Figs. 1A to 1C are drawings for explaining a buffer size management according to a first embodiment of the present invention; Fig. 2 is a flowchart illustrating a sequence for changing the buffer sizes according to the first embodiment of the present invention; Figs. 3A to 3C are drawings for explaining a buffer size management according to a second embodiment of the present invention; Fig. 4 is a flowchart illustrating a sequence for changing the buffer sizes according to the second embodiment of the present invention; Fig. 5 is a block diagram illustrating a printing apparatus according to the embodiments; Fig. 6 is a cross sectional view of a printer adapting laser beam method; Fig. 7 is an oblique view showing a printer adapting ink-jet method; Fig. 8 is a flowchart of a processing sequence for reading data from a print data buffer; and Fig. 9 is a flowchart of a processing sequence for writing data to a print data buffer. A configuration of printers according to a first embodiment of the present invention are shown in Figs. 5 to 7, and a sequence of buffer managing adapted by the printers is shown in Figs. 1 and 2. Configuration of the Printer Fig. 5 is a block diagram illustrating a configuration of a printer. Referring to Fig. 5, a CPU 51 controls the entire apparatus by executing a program stored in a ROM 53 or a RAM 52, and performs a printing operation. In the RAM 52, a print data buffer 521 and a fixed data buffer 522 are reserved in addition to an area for programs. Further, in the ROM 53, a program 531, font data, and so on, are stored. An interface 54 is connected to a host computer, and the printer receives data through the interface 54 as well as transmits a state of the printer to the host computer. An operation unit 55 includes a display panel for displaying the state of the printer to an operator and a keyboard, or the like, for the operator to input instructions. A printing unit 56 prints data developed as an image on a printing medium, such as a paper sheet. Fig. 6 is a cross sectional view of a printer when the printing unit 56 adapts laser beam method. In Fig. 6, reference numeral 740 denotes a main body of a laser beam printer (LBP), which forms an image on a recording paper sheet as a recording medium on the basis of provided character patterns, and the like. Reference numeral 700 denotes an operation panel on which switches for operation and a liquid crystal display (LCD) are provided; and 701, a printer control unit for controlling the entire operation of the LBP 740 and analyzing character pattern information. The printer control unit 701 primarily performs conversion from character pattern information into video signals, then outputs the video signals to a laser driver 702. The laser driver 702 is a circuit for driving a semi-conductor laser 703, and turns on and off the laser beam 704 emitted from the semi-conductor laser 703 on the basis of the input video signal. The laser beam 704 is reflected by a rotational polygon mirror 705 so as to scan an electrostatic drum 706 in the right-and-left direction. Accordingly, a latent image of character patterns is formed on the electrostatic drum 706. The latent image is developed by a developing unit 707 which is placed around the electrostatic drum 706, thereafter transferred to recording paper. Here, a cut sheet is used. The recording paper sheet is. set in a paper feed tray 708 which is set to the LBP 740, and fed into the printer by a paper-feed roller 709 and a conveying rollers 710 and 711, then provided to the electrostatic drum 706. Fig. 7 is an oblique view of the printing unit 56 when ink-jet method is adapted. Referring to Fig. 7, a carriage HC engages with a spiral groove 5004 of a lead screw 5005, which rotates via driving force transmission gears 5009 to 5011 upon forward/reverse rotation of a driving motor 5013. The carriage HC has a pin (not shown), and is reciprocally scanned in the directions of arrows a and b in Fig. 7. An ink-jet cartridge IJC is mounted on the carriage HC. Reference numeral 5002 denotes a sheet pressing plate, which presses a paper sheet against a platen 5000, ranging from one end to the other end of the scanning path of the carriage. Reference numerals 5007 and 5008 denote photocouplers which serve as a home position detector for recognizing the presence of a lever 5006 of the carriage in a corresponding region, and used for switching, e.g., the rotating direction of the motor 5013. Reference numeral 5016 denotes a member for supporting a cap member 5022, which caps the front surface of the printing head IJH; and 5015, a suction device for sucking ink residue through the interior of the cap member. The suction device 5015 performs suction recovery of the printing head via an opening 5023 of the cap member 5015. Reference numeral 5017 denotes a cleaning blade; 5019, a member which allows the blade to be movable in the back-and-forth direction of the blade. These members are supported on a main unit support plate 5018. The shape of the blade is not limited to this, but a known cleaning blade can be used in this embodiment. Reference numeral 5021 denotes a lever for initiating a suction operation in the suction recovery operation. The lever 5021 moves upon movement of a cam 5020, which engages with the carriage, and receives a driving force from the driving motor via a known transmission mechanism such as clutch switching. The capping, cleaning, and suction recovery operations are performed at their corresponding positions upon operation of the lead screw 5005 when the carriage reaches the home-position side region. However, the present invention is not limited to this arrangement as long as desired operations are performed at known timings. Buffer Management In the RAM 52 of the printer as described above, a consecutive memory area is reserved for the fixed data buffer 522 and the print data buffer 521. Fig. 2 is a flowchart showing a processing sequence for reserving areas for the fixed data buffer and the print data buffer and the processing sequence starts at the time when the printer is turned on. This processing sequence is realized by executing a predetermined program by the CPU 51. It should be noted that, in the following explanation, the print data buffer is read and write in the ascending order of the address. When the processing sequence shown in Fig. 2 starts right after the printer is turned on (step S1), a fixed data buffer having the maximum size required by any of a plurality of emulation modes is assigned from reserved memory area. The remaining memory area is assigned as a print data buffer in the form of a ring buffer (step S2). The fixed data buffer is assigned the higher memory addresses and the print data buffer the lower memory addresses. Note, data received from a host computer is stored in the print data buffer at addresses designated by a write pointer in an ascending order. Further, the data written in the print data buffer is read out in the write order in accordance with a read pointer. The sequences of write and read operations are respectively shown in Figs. 8 and 9. Therefore, the read pointer and the write pointer designates an address between the high end address (minimum address) and the low end address (maximum address) of the ring buffer formed by connecting the high end address and the low end address of an area assigned as the print data buffer. Fig. 1A shows the print data buffer (ring buffer for reception) and the fixed data buffer which are set as above. The host computer designates the emulation mode to be used in the printer, and, when an emulation mode is determined in accordance with an application, it notifies the designated mode to the printer. The printing device automatically determines the emulation in accordance with the transmitted data from the host computer, and determines the emulation mode (step S3). After the emulation mode is determined, when the fixed data buffer size required by the determined emulation mode is smaller than the fixed data buffer size initially set at step S2 just after the printer is turned on, the excess fixed data buffer area is reassigned as the print data buffer area. In this case, data which is already written in the print data buffer must be read out in the write order in accordance with the read pointer. At this point, the relationship between the read pointer and the write pointer of the print data buffer addresses is either the state shown in Fig. 1A or the state shown in Fig. 1B. Accordingly, there is a possibility that the read-out operation may not be performed correctly. In the state shown in Fig. 1B, i.e., in a case where received data is not stored in an end portion of the print data buffer, since the low end address of the print data buffer is not used, the print data buffer can be expanded by increasing the low end address of the print data buffer. In this case, the write pointer is incremented until it hits the new low end address expanded by changing the setting of the print data buffer so that data is written until the low end address. Further, after the read pointer designates the addresses at which data has already written before the print data buffer is expanded, it proceeds to data addresses in the expanded area toward the low end address of the expanded print data buffer. Accordingly, the received data can be read out correctly in the received order. In contrast, in a state in which received data is stored in the end of the print data buffer, as shown in Fig. 1A, i.e., in a state where data is written in the low end address of the print data buffer, there is no problem to the write pointer to increase the low end address of the print data buffer, since the write pointer points to store received data at an address which succeeds to the largest address where data has already been stored and moves toward the new low end address of the expanded print data buffer. However, in this case, the read pointer also moves toward the new low end address of the expanded print data buffer. As a result, data is read from an expanded area where no data has been written. Accordingly, reassignment of the print data buffer and the fixed data buffer has to be performed during in the state shown in Fig. 1B. Accordingly, the initial fixed data buffer size is compared to the fixed data buffer size determined after the emulation mode determination (steps S4 and S5), then, if the fixed data buffer size can be reduced, the address value of the write pointer and the address value of the read pointer of the print data buffer are compared prior to expanding the fixed data buffer size (step S6). If the address value of the read pointer is smaller than the address value of the write pointer, since the relationship between the read pointer and the write pointer is in the state shown in Fig. 1B, the low end address of the print data buffer is increased by the amount A which is equal to the fixed data buffer area which became unnecessary (step S7). Whereas, if the address value of the read pointer is not smaller than the address value of the write pointer, i.e., when in the state shown in Fig. 1A, the process waits while the writing and reading operation of the data proceeds until the address value of the read pointer becomes smaller than the address value of the write pointer, then the low end address of the print data buffer is increased. Accordingly, received data can be correctly read out. At step S6 in Fig. 2, when the relationship between the write pointer and the read pointer is in the state shown in Fig. 1A, the process waits until the values of the write pointer and the read pointer becomes the state shown in Fig. 1B. Meanwhile, the values of the read pointer or the write pointer are updated as data is read or written from/to the print data buffer in the sequences shown in Figs. 8 and 9 in order to realize a ring buffer. Fig. 8 shows an operational sequence for reading data from the print data buffer. First, the values of the read pointer and the write pointer are compared (step S801), and if they are the same, then the value of flag op, which indicates that the last operation performed is writing of data, is checked (step 3802). If the value of the read pointer and the value of the write pointer is equal, then the print data buffer is either full or empty. In this case, if writing of data is performed most recently, then it means that the print data buffer is full, while if reading of data is performed most recently, then it means that the print data buffer is empty. Therefore, the flag op which indicates that the last operation performed is writing of data is tested, and if it is 0, then it is determined that the print data buffer is empty, and the determination result is transmitted to a caller of the reading procedure shown in Fig. 8. If the buffer is not empty, then data stored at an address where the read pointer is pointing is read (step S803), and the read pointer proceeds to the next address (step S804). Next, whether the value of the proceeded read pointer is over the low end address of the print data buffer or not is determined (step S805), and if it is, the read pointer is returned to the top of the print data buffer (step S806). It should be noted that, in a case where the processes shown in Fig. 2 is performed in parallel to the processes shown in Fig. 8, with the completion of the process at step S806, the state of the ring buffer changes from the state shown in Fig. 1A to the state shown in Fig. 1B. Accordingly, with the completion of the process at step S806, the condition tested at step S6 in Fig. 2 is satisfied, and the low end address of the print data buffer is increased. Lastly, the flag op indicating that writing of data is performed is set to 0, and the process is completed. Fig. 9 shows an operational sequence for writing data to the print data buffer. First, the values of the read pointer and the write pointer are compared (step S901), and if they are the same, then the value of flag op is checked (step S902). If the value of the read pointer and the value of the write pointer is equal, then the print data buffer is either full or empty. In this case, if writing of data is performed most recently, then it means that the print data buffer is full, while if reading of data is performed most recently, then it means that the print data buffer is empty. Therefore, the flag op which indicates that the last operation performed is writing of data is tested, and if it is 1, then it is determined that the print data buffer is full, and the determination result is transmitted to a caller of the writing procedure shown in Fig. 9. If the buffer is not full, then data is written at the address where the write pointer is pointing (step S903), and the write pointer proceeds to the next address (step S904). Next, whether the value of the proceeded write pointer is over the low end address of the print data buffer or not is determined (step S905), and if it is, the write pointer is returned to the top of the print data buffer (step S906). Lastly, the flag op indicating that writing of data is performed is set to 1, and the process is completed. As described above, the pointers are controlled so that after the low end address the pointer returns to the high end address, thereby realizing a ring buffer. It should be noted that to expand the print data buffer is to increase the low end address of the ring buffer. More specifically, as shown in Figs. 8 and 9, since the pointers are incremented as writing and reading data to/from the print data buffer, whether the addresses of the pointers after they are incremented exceed the low end address or not is determined, and if it is, the pointers are moved back to the high end address of the print data buffer. The low end address is changed at step S7. As a result, the memory has the memory areas as shown in Fig. 1C. By performing the aforesaid operation, it is possible to correctly read out received data which has been stored. Further, by reassigning a conventionally wasted memory area as a print data buffer area, it is possible to expand the print data buffer size without increasing the memory size provided in a conventional printing apparatus. Figs. 3 and 4 are an explanatory view and a flowchart of another buffer management sequence of a printer shown in Figs. 5 to 7. In the first embodiment, the fixed data buffer is assigned the higher memory addresses of a memory area saved in advance. In the second embodiment, in contrast, the fixed data buffer is assigned the lower memory addresses of a memory area. When an emulation mode is determined in the automatic emulation determination operation, the state of the saved area in the memory which stores data received from the host computer is either in the state shown in Fig. 3A or the state shown in Fig. 3B. Therefore, if the saved memory area is in the state shown in Fig. 3B, similarly to the case of Fig. 1B in the first embodiment, the necessary fixed data buffer size is reserved from the top of the area, thereafter, a fixed data buffer area which becomes unnecessary is reassigned as print data buffer area in front of the top (minimum) address of the print data buffer to expand it. In a case of Fig. 3A, the process waits until the address value of the read pointer becomes smaller than the address value of the write pointer, i.e., until the state changes to that in Fig. 3B, then the print data buffer size is expanded. Figs. 3A to 3C show how assignment of areas of the memory is changed, and they differ from Figs. 1A to 1C in that the point where the positions of the print data buffers and the fixed data buffers are switched. Further, Fig. 4 is a flowchart showing processing for expanding the print data buffer, and step S7' in Fig. 4 and step S7 in Fig. 2 are different. More specifically, at step S7' in Fig. 4, it is not the low end address of the print data buffer that is changed but the high end address of the print data buffer to expand it. As a result, the print data buffer is expanded as shown in Fig. 3C. Accordingly, it is possible to achieve the same effects as those in the first embodiment. The present invention can be applied to not only a printer but also any apparatuses, such as a copying machine and a facsimile, which require a fixed data buffer and a print data buffer. Further, the object of the present invention can be also achieved by providing a storage medium storing program codes for performing the aforesaid processes to a system or an apparatus, reading the program codes with a computer (e.g., CPU, MPU) of the system or apparatus from the storage medium, then executing the program. In this case, the program codes read from the storage medium realize the functions according to the embodiments, and the storage medium storing the program codes constitutes the invention. Further, the storage medium, such as a floppy disk, a hard disk, an optical disk, a magneto-optical disk, CD-ROM, CD-R, a magnetic tape, a non-volatile type memory card, and ROM can be used for providing the program codes. Furthermore, besides aforesaid functions according to the above embodiments are realized by executing the program codes which are read by a computer, the present invention includes a case where an OS (operating system) or the like working on the computer performs a part or entire processes in accordance with designations of the program codes and realizes functions according to the above embodiments. Furthermore, the present invention also includes a case where, after the program codes read from the storage medium are written in a function expansion card which is inserted into the computer or in a memory provided in a function expansion unit which is connected to the computer, CPU or the like contained in the function expansion card or unit performs a part or entire process in accordance with designations of the program codes and realizes functions of the above embodiments. According to the buffer managing method and a printing apparatus adapting the method according to the present invention as described above, when switching between a plurality of different emulation modes automatically, it is possible to set the fixed data buffer size necessary for each emulation mode, thereby a memory area can be effectively used without waste. Further, since the remaining memory area is assigned as a print data buffer area, it is possible to increase the print data buffer size without increasing the capacity of the memory. The present invention is not limited to the above embodiments and various changes and modifications can be made within the scope of the present invention as claimed. Therefore to appraise the public of the scope of the present invention, the following claims are made.

Claims: A buffer managing method for managing a data storage area (522) and a ring buffer (521) assigned in a memory of a predetermined size, said ring buffer (521) being sequentially addressable to the data storage area (522), said method comprising: a calculation step (S4) of calculating a size which can be reduced from the data storage area, said calculated step, being based on the initially assigned size of said data storage area commonly necessary for a plurality of emulations and the size of said data storage area effectively required for a particular one of said plurality of emulations; a determination step (S6) of determining no received data is stored at the end of the ring buffer; and an expansion step (S7;S7') of expanding the ring buffer by the size which is calculated at said calculation step (S4) by moving a border between the ring buffer (521) and the data storage area (522) if it is determined at said determination step (S6) that no received data is stored at the end of the ring buffer (521). The buffer managing method according to claim 1, wherein, if it is determined that received data is stored at the end of the ring buffer (521) at said determination step (S6), then at said expansion step (S7;S7'), the process waits until the memory becomes a state in which no received data is stored at the end of the ring buffer (521). The buffer managing method according to claim 1, wherein, at said determination step (S6), whether or not no received data is stored at the end of the ring buffer (521) is determined by comparing a write pointer which indicates a writing position in the ring buffer (521) and a read pointer which indicates a reading position in the ring buffer (521). The buffer managing method according to claim 1, wherein the ring buffer (521) is a print data buffer which stores received data from a host device, and the data storage area (522) is a fixed data buffer which stores down-loaded data from the host device. The buffer managing method according to claim 4 further comprising a step (S3) of recognizing a size to be reserved as the data storage area (522) in accordance with data received from the host device before said calculation step (S4). A printing apparatus capable of executing an emulation mode designated by a host device out of a plurality of emulation modes, said apparatus comprising: a memory (52) having a predetermined size of storage area; assigning means (S2) for assigning an area of the memory corresponding to a maximum fixed data buffer size required by the plurality of emulation modes as a fixed data buffer (522), and assigning the rest of an area of the memory as a ring buffer (521) which stores data received from the host device; receiving means (54) which receives data from the host device; determination means (S3) for determining an emulation mode in accordance with data received by said receiving means (54); calculation means (S4) for calculating a difference between the fixed data buffer size which is required by the determined emulation mode and the maximum fixed data buffer size assigned by said assigning means (S2); judging means (S6) for judging whether or not no received data is stored at the end of the ring buffer (521); and an expansion means (S7;S7')for expanding the ring buffer (521) by the size calculated by said calculation means (S4) by moving a border between the ring buffer (521) and the fixed data buffer (522) if it is determined that no received data is stored at the end of the ring buffer (521) by said judging means (S6). The printing apparatus according to claim 6, wherein, if it is determined that received data is stored at the end of the ring buffer (521) by said determination means (S3), then said expansion means (S7;S7') waits until the memory becomes a state in which no received data is stored at the end of the ring buffer (521). The printing apparatus according to claim 6, wherein said determination means (S3) determines whether or not no received data is stored at the end of the ring buffer (521) by comparing a write pointer which indicates a writing position in the ring buffer (521) and a read pointer which indicates a reading position in the ring buffer (521). The printing apparatus according to claim 6, wherein the ring buffer (521) is a print data buffer which stores received data from the host device, and the fixed data buffer (522) stores down-loaded data from the host device. A storage medium comprising a computer readable storage medium containing computer code for controlling a processor to carry out the method of any one of claims 1 to 5, when said computer code is run on a computer.

Inventors: IKEDA TETSUHITO, IKEDA, TETSUHITO
Applicants: CANON KK, CANON KABUSHIKI KAISHA
Application year: 1996
Main classification: G06F5
IPC codes: G06F5, G06F3, G06F12, G06K15