Abstract:
The invention adopts the virtual COM port instead of the traditional real COM port in a PC host for communicating with a micro-controller in target host. In the prior art, we need to communicate and transfer data between a host and the other one using real COM port and execute the program in the micro-controller. But the present invention uses the Virtual COM port in the PC host to replace the real one and connect to the real COM port of micro-controller in the other PC host. Then it achieves the purpose of programming in the same host including PC host and target host simultaneously.

Description:
BACKGROUND OF THE INVENTION  
         [0001]    1. Field of the Invention  
           [0002]    The invention relates to a method and apparatus of virtual COM port, which adopts the virtual COM port instead of the traditional real COM port and achieves the purpose of programming in the same host including PC host and target host simultaneously.  
           [0003]    2. Description of Prior Art  
           [0004]    In the prior art, a 8051 micro-controller program in keyboard of personal computer desires to transfer register data or any logic signal and program to another built-in micro-controller of a target host through a real COM port. Then it needs some specific drivers of interface and a connector to link the COM ports between the source and target host. For convenient reason, the present invention downloads these signals and program to micro-controller through a virtual COM port to simulate the situation between two separate source and target hosts, but in the same host actually the program can do some execution locally without any awareness of the difference.  
         SUMMARY OF THE INVENTION  
         [0005]    The invention relates to a method and apparatus of virtual COM port, which adopts the virtual COM port instead of the traditional real COM port in a PC host for communicating with a micro-controller in target host. In brief, this invention replaces the connection mentioned in prior method between two separate hosts through a real COM ports or parallel port by a virtual COM port in one local host. Then the control host can proceed the debug program on itself by loading virtual COM port driver, it will seem like to connect the control host and another target host without any awareness of the difference between the virtual and real COM port. 
       
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0006]    The foregoing, as well as additional objects, features and advantages of the invention will be more readily apparent from the following detailed description, which proceeds with reference to the accompanying drawings.  
         [0007]    [0007]FIG. 1 is a block diagram showing the functional connection in accordance with one preferred embodiment of the present invention;  
         [0008]    [0008]FIG. 2 is a corresponding diagram of status bits of virtual COM port and micro-controller of the invention embodiment;  
         [0009]    [0009]FIG. 3 is a flow chart of the transferring from control host into micro-controller of the invention embodiment;  
         [0010]    [0010]FIG. 4 is a flow chart of the transferring from micro-controller into control host of the invention embodiment. 
     
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS  
       [0011]    Refer to FIG. 1 for the block diagram of functional connection of the embodiment in this invention. There is a control host program  102 , which adopts a standard COM port library  104  for communicating within a computer operating system  106 . As the system proceeds to load a virtual COM port driver  108  into the operating system in the control host for accessing the virtual COM port, then the data of control host transfers into micro-controller data buffer  110  by the virtual COM port. Further, the control host program will access the micro-controller in the control host  112 . The data mentioned above includes two interrupt signals and a byte data, and the detail description will be referred on FIG. 2. After the execution in control host, that will transfer the data including interrupt signals, status signals and program data into the register in micro-controller. The foregoing diagram of the invention is for the purpose of communication between the control host and micro-controller of embodiment of the invention.  
         [0012]    Refer to FIG. 2, it&#39;s showing a corresponding diagram of status bits of virtual COM port and micro-controller of the invention embodiment. The data transferred from the control host into the micro-controller includes two kinds of interrupt signal and data buffer, wherein that interrupt signals are received control signal and transmitted control signal. Furthermore, the data mentioned is stored in a COM port data byte  202  and a virtual COM port data byte  204 , which are located in the real COM port of the micro-controller and the virtual COM port of the control host respectively.  
         [0013]    According to the block diagram show in FIG. 2 , the status bits of COM port control flag M 1  (serial control register, SCON) and COM port data buffer M 2  (serial data buffer, SBUF) in the real COM port data byte  202  correspond to the virtual COM port control flag H 1  (virtual serial control register, PVSCON) and virtual COM port data buffer H 2  (virtual serial data buffer, PVSBUF) in the virtual COM port data byte  204 .  
         [0014]    The first two bits in COM port control flag M 1  are represented a COM port receive control flag  21  (SCON.RI), which is a bit status for indicating the micro-controller receiving a set of data and another COM port transmit control flag  22  (SCON.TI), which is a bit status for indicating the control host receiving a set of data. The two status bits are also indicating whether or not an interrupt event is happened in the micro-controller. When the control host accesses in the micro-controller, that will change the status of COM port control flag M 1  in the micro-controller, then the control host will transfer a set of data byte into the COM port data buffer M 2  of the micro-controller, at meantime, the COM port receive control flag  21  will be changed to 1. After the COM port data buffer M 2  of micro-controller has received the data byte, the COM port receive control flag  21  will be changed to 0, which is the original status.  
         [0015]    When the micro-controller transfers a set of data byte into control host, the COM port control flag M 1  will be changed. That means as control host is receiving the data byte from micro-controller, the COM port transmit control flag  22  will be 1. After the transmitssion ends, the COM port transmit control flag  22  is changed to 0, which is the original status.  
         [0016]    Further, referring to FIG. 2 for the block diagram of virtual COM port in control host, wherein the virtual COM port control flag H 1  includes a virtual COM port receive control flag  23 , which is a bit status for indicating the control host receiving a set of data and a virtual COM port transmit control flag  24 , which is a bit status also for indicating the micro-controller receiving a set of data. These first two status signals in virtual COM port control flag H 1  are by means of indicating the interrupt status signal in control host. When the micro-controller accesses to the control host, the micro-controller needs to acquire the interrupt, and set bit  1 , and  0  for finishing.  
         [0017]    The micro-controller transfers a set of data byte into the virtual COM port data buffer H 2  (PVSBUF) of control host, then the virtual COM port receive control flag  23  (PVSCON.RI) will be changed to 1. When the control host receives the data byte from virtual COM port data buffer H 2 , the virtual COM port receive control flag  23  (PVSCON.RI) will be set to 0, that is the initial status. When the control host transfers a set of data byte to the micro-controller, the virtual COM port transmit control flag  24  (PVSCON.TI) indicates to transmission status. After the micro-controller receives the data byte, the virtual COM port transmit control flag  24  will be set to 1, for indicating the byte data transmission has finished and received by the micro-controller.  
         [0018]    The COM port data buffer M 2  of micro-controller and the virtual COM port data buffer H 2  of control host are the data buffer made by a byte of register for transmitting and receiving a set of data and any other status information including the status of transferring in system respectively and these two data buffer occupy the same hardware register memory simultaneously. Meaningfully, the data written into COM port data buffer M 2  will be the same with written into virtual COM port data buffer H 2  and so will contrariwise.  
         [0019]    The detail steps of embodiment of transferring from the control host into the micro-controller of this invention are described below:  
         [0020]    Please refer to FIG. 3 , which is a flow chart of the transferring from control host into micro-controller of the invention embodiment. First, a control program launching, then the control program is written into the virtual COM port data buffer ( 302 ), and the control host starts transferring data byte ( 304 ) and gets connection access with the control host. Next, a virtual COM port driver is loaded through the control host ( 306 ), at meantime, the signal written into virtual COM port data buffer will set the COM port receive control flag of the micro-controller to 1 ( 308 ), and generate a micro-controller interrupt signal ( 310 ). This status indicates the interrupt signal of micro-controller is at status on and then has permission to access the micro-controller program. When the COM port receive control flag is set to 1, the micro-controller program will be informed the COM port data buffer has received the data bytes and read out the data byte from the COM port data buffer ( 312 ). After the micro-controller reads the data byte in COM port data buffer, the COM port receive control flag will be set to 0 ( 314 ), which indicates the initial status. Then the virtual COM port transmit control flag will be set ( 316 ), and transfer the data byte into micro-controller ( 318 ). That will go on the next transferring from the control host into micro-controller ( 302 ) if any other data byte needs to be sent next.  
         [0021]    Please refer to FIG. 4, that is a flow chart of the transferring from micro-controller into control host of the invention embodiment. First, a control program launching, then the micro-controller starts transferring the data byte ( 402 ). The micro-controller program writes a set of data byte into it&#39;s own COM port data buffer ( 404 ), then sets a virtual COM port receive control flag to 1 ( 406 ), and generates an interrupt signal in the control host ( 408 ), for indicating the interrupt signal is status on. Then the micro-controller has permission to access the control host by loading the virtual COM port driver ( 410 ). When the virtual COM port receive control flag is set to 1, the control host will be informed the virtual COM port data buffer has received the data byte, and read that out ( 412 ). The data byte received by virtual COM port data buffer is the data byte written from micro-controller into COM port data buffer. At meantime, the virtual COM port receive control flag will be set to 0 ( 414 ), which is the initial status, then the COM port transmit control flag will be set for informing the micro-controller about the control host has received the data byte ( 416 ), and transfer that into the control host ( 418 ). That will go on the next transferring from the micro-controller into control host ( 402 ) if any other data byte needs to be sent next.  
         [0022]    By means of the method and apparatus of virtual COM port set forth above, the invention of virtual COM port in the control host replaces the transferring method of traditional real COM port, thereby the invention achieves the objects of simplicity, convenience and portability.  
         [0023]    While the preferred embodiments of the invention have been set forth for the purpose of disclosure, modifications of the disclosed embodiments of the invention as well as other embodiments thereof may occur to those skilled in the art. Accordingly, the appended claims are intended to cover all embodiments which do not depart from the spirit and scope of the invention.