A kind of multi-process serial port communication method
Technical field
The present invention relates to a kind of communication means, especially relate to a kind of multi-process serial port communication method.
Background technology
In prior art; often have multiple program to run on computers simultaneously; sometimes need multiple process to operate computer serial port simultaneously; and when multiple process operates computer serial port simultaneously; there will be a process take serial ports handle and other processes cannot be accessed serial ports, cause other programs normally to run.
Summary of the invention
In view of this, the object of the invention is for the deficiencies in the prior art, provide a kind of multi-process serial port communication method, the method can realize multiple program and operate same serial ports.
For achieving the above object, the present invention by the following technical solutions:
A kind of multi-process serial port communication method, comprises the steps:
Step 1, the same serial ports program of N number of procedure operation, sends operation serial port command, and N is natural number, N >=1;
Step 2, N number of operation serial port command that N number of program sends is ranked wait in serial ports interprogram communication module;
Step 3, serial communication modular transmit operation serial port command, after serial ports of computers response, access serial ports interprogram communication module, the N number of operation serial port command waited in line in serial communication modular responds successively, performs corresponding N number of program by the order of response.
As preferably, the time order and function order that N number of operation serial port command of described N number of program sends by operational order in serial ports interprogram communication module is ranked wait.
The invention has the beneficial effects as follows:
When the program of multiple operation serial ports is run, multi-process serial communication program, using the middle layer as procedure operation serial ports, communicates with the serial ports of computing machine, and gives corresponding program by the responsive feedback of serial ports.The invention solves when multiple program needs to access same serial equipment, when the process of a program obtains serial ports handle, cause the problem that other program cannot operate this serial ports, multi-process serial port communication technology can make all programs access a serial equipment simultaneously.
Accompanying drawing explanation
Fig. 1 is process flow diagram of the present invention.
Embodiment
Below in conjunction with drawings and Examples, the invention will be further described.
As shown in Figure 1, the present invention includes following steps:
Step 1, the same serial ports program of N number of procedure operation, each program sends 1 operation serial port command, and N number of program sends N number of operation serial port command altogether, accesses same serial ports, and N is natural number, N >=1.
Step 2, N number of operation serial port command to be ranked wait by the time order and function order sent in serial ports interprogram communication module; Here serial ports interprogram communication module is the multi-process serial ports interprogram communication module software module built.
Step 3, serial communication modular sends serial port command to serial ports of computers, after serial ports of computers response, and access serial ports interprogram communication module, the N number of operation serial port command waited in line in serial communication modular responds successively, performs corresponding N number of program by the order of response.When order 1 responds, perform corresponding program 1, after program 1 is finished, order 2 response, perform corresponding program 2, program N is to the last finished.
The multiple process in prior art that the invention solves there will be a process and takes serial ports handle and other processes cannot be accessed serial ports when operating serial ports of computers, cause the technical barrier that other programs cannot normally be run.The present invention can realize multiple process and operate serial ports of computers simultaneously, and the program of avoiding normally cannot be run and cause deadlock problem.The invention solves a computer and dispose the inconvenience that multiple serial equipment brings and the problem of saving hardware purchase expense.
What finally illustrate is, above embodiment is only in order to illustrate technical scheme of the present invention and unrestricted, other amendments that those of ordinary skill in the art make technical scheme of the present invention or equivalently to replace, only otherwise depart from the spirit and scope of technical solution of the present invention, all should be encompassed in the middle of right of the present invention.