CN101216810A - Progress and serial equipment communicating method and its device - Google Patents

Progress and serial equipment communicating method and its device Download PDF

Info

Publication number
CN101216810A
CN101216810A CNA2007100327530A CN200710032753A CN101216810A CN 101216810 A CN101216810 A CN 101216810A CN A2007100327530 A CNA2007100327530 A CN A2007100327530A CN 200710032753 A CN200710032753 A CN 200710032753A CN 101216810 A CN101216810 A CN 101216810A
Authority
CN
China
Prior art keywords
instruction
serial
client process
serial equipment
write
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CNA2007100327530A
Other languages
Chinese (zh)
Other versions
CN100570586C (en
Inventor
刘明华
朱建明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vtron Technologies Ltd
Original Assignee
Vtron Technologies Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Vtron Technologies Ltd filed Critical Vtron Technologies Ltd
Priority to CNB2007100327530A priority Critical patent/CN100570586C/en
Publication of CN101216810A publication Critical patent/CN101216810A/en
Application granted granted Critical
Publication of CN100570586C publication Critical patent/CN100570586C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Transfer Systems (AREA)

Abstract

The invention discloses a method for process and serial device communication, and a device thereof. The method comprises the steps as follows: a service process agent is responsible for the operation of opening a serial interface and executing an instruction of reading/writing serial device, and detects the state of the serial interface according to an inquiring instruction for detecting serial interface status messages sent by a client process; if the serial interface is opened, the instruction of reading/writing serial device is sent by the client process; the service process receives the instructions of reading/writing serial device sent by a plurality of client processes, one instruction operation of reading/writing serial device is executed first, and the next instruction of reading/writing serial device is processed after the operation is successfully completed. By adopting the method of the invention, a plurality of processes can fully utilize the serial interface and the serial device communication, and the idling of the serial device and the obstruction of the client process are avoided.

Description

The method of a kind of process and serial equipment communicating and device thereof
Technical field
The present invention relates to communication technical field, the method and the device thereof of particularly a kind of process and serial equipment communicating.
Background technology
Along with the application and the development of computer technology, various computer peripherals are used also more and more widely, and the communication mode between computing machine and the peripherals also becomes more diverse, and USB interface, infrared, bluetooth, serial ports, parallel port etc. are arranged.Consider design cost and environmental requirement in some commercial Application, serial ports is still very common in some commercial units are used, and runs into a plurality of processes through regular meeting and need a shared serial ports remove to handle same serial equipment.Suppose that client process A and client process B need to use serial equipment 1 simultaneously, if process A is earlier by serial ports and serial equipment communicating; Process A opens this serial ports earlier, waits it not re-use serial equipment and just closes this serial ports; After process A closed this serial ports, process B just can open serial ports, could communicate with serial equipment.After process A opens serial ports, may need to use for a long time this serial equipment, so this serial ports is in open mode always, because serial ports can only have a process of opening this serial ports to monopolize use in the section sometime, therefore process B may can not use this serial equipment for a long time like this, can cause the obstruction of process or reduces the utilization rate of serial ports even cause serial equipment idle.
Summary of the invention
The invention provides the method and the device thereof of a kind of process and serial equipment communicating, make a plurality of processes can be fully and serial equipment communicate, can not cause process blocking.
Technical scheme of the present invention is: the method for a kind of process and serial equipment communicating may further comprise the steps:
The query statement of step 1, the detection com-state information that sends according to client process, service processes detects the state of described serial ports, and the status information of described serial ports is sent to described client process;
If the described serial ports of step 2 is opened, described client process sends the instruction of read/write serial equipment;
Step 3, described service processes receive the instruction of described read/write serial equipment; If the instruction of the read/write serial equipment that receives is at least two, described service processes is carried out the operation of one of them read/write serial equipment instruction earlier;
After step 4, described service processes execute the operation of described one of them read/write instruction,, carry out the instruction of next read/write serial equipment simultaneously with writing the byte number of serial equipment or sending to described client process from the data that serial equipment reads.
The device of a kind of process and serial equipment communicating comprises:
Detection module is used for the instruction of the detection com-state sent according to communication module, detects described com-state, and the status information of described serial ports is sent to communication module;
Communication module is used to receive the instruction of the detection com-state that this locality or far-end client process send, and sends to described detection module, and described com-state information sent to the client process of this locality or far-end; When serial ports is opened, receive the read/write serial equipment instruction of the client process of this locality or far-end, and send to processing module, by described processing module serial equipment is carried out read/write operation, and described processing module is write the byte number of serial equipment or sends to described client process from the data that serial equipment reads; If serial ports is not opened, receive the instruction of opening serial ports that this locality or far-end client process send, and send to described processing module, remove to open serial ports by described processing module, and described serial ports is opened the client process that success or failed message send to this locality or far-end;
Processing module is used for according to described read/write serial equipment instruction successively to the serial equipment executable operations; Open serial ports instruction and remove to open serial ports according to described, and processing result information is sent to described communication module.
The method of process of the present invention and serial equipment communicating and device thereof, described service processes receives the read/write serial equipment instruction that client process sends, act on behalf of client process and carry out the operation of read/write serial equipment, by the time after one of them instruction process finishes, and then handle next read/write serial equipment instruction.This shows, other processes need not be waited for and go after this serial ports is closed to use again, after the read/write serial equipment instruction process that waits one of them client process to send finishes, described service processes can directly be handled the read/write serial equipment instruction that other client processes send, make a plurality of client processes can make full use of described serial equipment, can not cause the obstruction of the idle and client process of this serial equipment.
Below the description of drawings
Below in conjunction with the drawings and specific embodiments the present invention is done detailed elaboration.
Fig. 1 is the method flow diagram of process of the present invention and serial equipment communicating;
Fig. 2 is the method flow diagram of process of the present invention and long-range serial equipment communicating;
Fig. 3 is the synoptic diagram of an embodiment of the device of process of the present invention and serial equipment communicating;
Fig. 4 is the synoptic diagram of an embodiment of the device of process of the present invention and serial equipment communicating;
Fig. 5 is the synoptic diagram of an embodiment of the device of process of the present invention and serial equipment communicating.
Embodiment
Embodiment one
Present embodiment is the method for the serial equipment communicating of process and this locality, and Fig. 1 is the method flow diagram of present embodiment, and it may further comprise the steps:
The query statement of the detection com-state information that S101, service processes send according to client process detects the state of described serial ports, and the status information of described serial ports is sent to described client process.Described client process can have a plurality of.
Open or open mode if the described serial ports of S102 is in, described client process sends the instruction of read/write serial equipment.Described client process can have a plurality of.
S103, service processes receive the instruction of described read/write serial equipment.The instruction that a plurality of client processes can send the read/write serial equipment to service processes simultaneously, service processes can be handled the instruction of read/write serial equipment by the sequencing of the read/write serial equipment instruction that receives the client process transmission, also can handle by the order of importance and emergency of described read/write serial equipment instruction.
If S104, service processes receive the instruction of described read/write serial equipment when being a plurality of, earlier one of them read/write serial equipment instruction is taken out, according to this instruction serial equipment is carried out read/write operation.
Previous read/write serial equipment such as S105, service processes instruction manipulation is finished, and sends to the client process that sends command adapted thereto the data word joint number that writes serial equipment or from the data that serial equipment reads, and handles next read/write serial equipment instruction then.
If it is closed condition that service processes detects described serial ports, described client process can send to service processes and open the serial ports instruction; Service processes removes to open serial ports according to this instruction, if open success, opens success message to the client process transmission, and described client process sends the instruction of read/write serial equipment after receiving this message; If open failure, send to client process and to open failure, among the figure shown in step S1010, S1011, the S1012.
Described service processes receives described read/write serial equipment and instructs when being one, service processes is directly carried out the read/write operation of serial-port according to this instruction, the operation of wait read/write instruction is finished, send to client process the data word joint number that writes serial equipment or from the data that serial equipment reads, among the figure shown in the S1030.
In step S105, for the read/write serial equipment instruction that each client process is sent can not conflict, whether service processes detects each read/write instruction operation and finishes, and could carry out a next read/write instruction after finishing by the time in addition.
Wherein, described client process can send described query statement and the instruction of read/write serial equipment by pipeline or shared drive, and corresponding service processes sends it by pipeline or shared drive to client process and writes the data word joint number of serial equipment or the data that read from serial equipment.
Embodiment two
Present embodiment is the application example of embodiment one scheme: the GSM mobile handset that client process 1 and client process 2 visits and computing machine link, and telephone number and client process 2 that client process 1 will read mobile phone will send the tinkle of bells to mobile phone;
1, starts client process 1 and client process 2; Create a service processes, be responsible for acting on behalf of client process mobile phone is carried out read/write operation, described service processes is created and is received and send thread 1 and receive and send thread 2;
2, client process 1 sends inquiry serial ports status information to service processes, receive and send the state that thread 1 detects serial ports, and the result sent to client process 1 by receiving and send thread 1, client process 1 discovery serial ports is not opened, then send and open the serial ports instruction to service processes, receive and send and open serial ports after thread 1 is received instruction, and the result is sent to client process 1 by receiving and send thread 1; Client process 2 also can send inquiry serial ports status information to service module simultaneously, receive and send the state that thread 2 detects serial ports, and the result sent to client process 2 by receiving and send thread 2, client process 2 finds that serial ports open, and then no longer sends and opens the serial ports instruction;
3, client process 1 sends the instruction of reading phone number to service processes, receive and send thread 1 and receive instruction bag back identification bag command type, begin to lock, send the instruction of reading phone number to mobile phone by serial ports, and wait receives the result of serial equipment feedback, receive result or overtime then release, and the result is sent to client process 1; Client process 1 to service module send read the phone number instruction in, client process 2 can send to service processes and write the instruction of mobile phone the tinkle of bells, receive and send thread 2 and receive instruction bag back identification bag command type, begin to lock, beginning was write the tinkle of bells to serial equipment after it waited until client process 1 release, and wait for the result who receives the serial equipment feedback, receive result or overtime then release, and the result is sent to client process 2;
4, client process 1 and client process 2 withdraw from, and service processes is closed serial ports.
Embodiment three
Embodiment one and embodiment two method that to be client processes communicate with local serial equipment, present embodiment are the methods of client process and long-range serial equipment communicating, method flow diagram as described in Figure 2.The method of present embodiment may further comprise the steps:
S201, service processes detect the state of described serial ports according to the query statement of client process by the detection com-state information of network transmission, and the status information of described serial ports is sent to described client process by network.Described client process can be for a plurality of, and it sends the status command that detects described serial ports by network respectively.
If the described serial ports of S202 is in opening, described client process is to send the instruction of read/write serial equipment by network to long-range service processes, and described client process can have a plurality of.
S203, service processes receive described read/write serial equipment instruction.Service processes may only be received the read/write serial equipment instruction that a client process sends, and also may receive the read/write serial equipment instruction that a plurality of client processes send.
If S204, service processes receive the instruction of described read/write serial equipment when being a plurality of, earlier one of them read/write serial equipment instruction is taken out, according to instruction serial equipment is carried out read/write operation.
S205, service processes treat that the operation of previous read/write instruction finishes, and send to described client process the data word joint number that writes serial equipment or from the data that serial equipment reads by network, handle next read/write serial equipment then and instruct.
If it is closed condition that service processes detects described serial ports, described client process can send to service processes by network and open the serial ports instruction; Service processes removes to open serial ports according to this instruction, if open success, opens success message by network to the client process transmission, and described client process sends the instruction of read/write serial equipment by network to long-range service processes after receiving this message; If open failure, send to client process by network and to open failure, among the figure shown in step S2010, S2011, the S2012.
When the instruction that described service processes receives described read/write serial equipment is one, service processes is directly carried out the read/write operation of serial-port according to this instruction, the operation of wait read/write instruction is finished, and writing the data word joint number of serial equipment or send to client process by network, among the figure shown in the S1030 from the data that serial equipment reads.
In step S205, for the read/write serial equipment instruction that each client process is sent can not conflict, whether service processes can detect each read/write serial equipment instruction manipulation and finish, and could carry out read/write serial equipment instruction after finishing in addition.
Embodiment four
Present embodiment is the function of comprehensive embodiment one and embodiment three, and a plurality of client processes can communicate by the service processes and the serial equipment of this locality, as described in embodiment one; Can communicate by network and remote service process and long-range serial equipment again simultaneously, as described in embodiment three, concrete steps please refer to embodiment one and embodiment three is described, do not give unnecessary details at this.
Introduce the device of process of the present invention and serial equipment communicating below respectively
With the corresponding device of embodiment one method, as shown in Figure 3: the device of this process and serial equipment communicating comprises the service processes module of being made up of detection module and communication module and processing module, one end of service processes module is connected with serial equipment by serial ports, and the other end is connected with described native client process.
Detection module is used to handle the instruction of the detection com-state that native client process that communication module receives sends, and according to described command detection com-state, and the status information of described serial ports is sent to communication module;
Communication module is used to receive the instruction of the detection com-state that the native client process sends, and sends to described detection module, and described com-state information is sent to the native client process; When serial ports is opened, receive the read/write serial equipment instruction of native client process, and send to processing module, by described processing module serial equipment is carried out read/write operation, and described processing module is write the byte number of serial equipment or sends to described native client process from the data that serial equipment reads; If serial ports is not opened, receive the instruction of opening serial ports that the native client process sends, and send to described processing module, remove to open serial ports by described processing module, and described serial ports opened success or failed message sends to the native client process;
Processing module, be used for according to described read/write serial equipment instruction successively to the serial equipment executable operations, the read/write serial equipment instruction that receives when processing module is when a plurality of, described processing module is handled wherein read/write serial equipment instruction, handles next bar read/write instruction again after waiting this instruction read/write operation to finish; Open serial ports instruction and remove to open serial ports according to described, and processing result information is sent to described communication module.
With the corresponding device of three methods of enforcement, as shown in Figure 4:
This process is the device that communicates with long-range client process and serial equipment, comprise the service processes module of forming by detection module and communication module and processing module, one end of service processes module is connected with serial equipment by serial ports, and the other end is connected with described far-end client process by network.
Detection module is used to handle the instruction of the detection com-state that far-end client process that communication module receives sends, according to described command detection com-state, and with the status information of described serial ports by sending to communication module;
Communication module is used to receive the instruction of the detection com-state that the far-end client process sends, and sends to described detection module, and described com-state information is sent to the far-end client process; When serial ports is opened, receive the read/write serial equipment instruction of far-end client process, and send to processing module, by described processing module serial equipment is carried out read/write operation, and described processing module is write the byte number of serial equipment or sends to described far-end client process from the data that serial equipment reads; If serial ports is not opened, receive the instruction of opening serial ports that the far-end client process sends, and send to described processing module, remove to open serial ports by described processing module, and described serial ports opened success or failed message sends to the far-end client process;
Processing module, be used for according to described read/write serial equipment instruction the serial equipment executable operations, the read/write serial equipment instruction that receives when processing module is when a plurality of, described processing module is handled wherein read/write serial equipment instruction, handles next bar read/write instruction again after waiting this instruction read/write operation to finish; Open serial ports instruction and remove to open serial ports according to described, and processing result information is sent to described communication module.
With the corresponding device of embodiment four directions method, as shown in Figure 5:
The device of this client process and serial equipment process communication, comprise the service processes A that forms by first detection module, first communication module and first processing module, reach the service processes B that forms by second detection module, second communication module and second processing module, client process A links to each other with service processes A, can link to each other with service processes B by network again simultaneously, client process B links to each other with service processes B, can link to each other with service processes A by network again simultaneously, service processes A links to each other with serial equipment 1, and service processes B and serial equipment 2 are mutually repeatedly.
When client process A needs and serial equipment 1 or client process B to need communicate by letter with serial equipment 2, be equivalent to client process of this locality and the serial equipment of this locality and communicate, its principle is not given unnecessary details at this with the same with the corresponding device of embodiment one.
When client process A needs to communicate by letter with serial equipment 2 or client process B need communicate by letter with serial equipment 1 time, be equivalent to this locality client process will with long-range serial equipment communicating, its principle is the same with the device of answering with embodiment three, does not give unnecessary details at this.
Above-described embodiment of the present invention does not constitute the qualification to protection domain of the present invention.Any modification of being done within the spirit and principles in the present invention, be equal to and replace and improvement etc., all should be included within the claim protection domain of the present invention.

Claims (8)

1. the method for process and serial equipment communicating is characterized in that: may further comprise the steps,
The query statement of step 1, the detection com-state information that sends according to client process, service processes detects the state of described serial ports, and the status information of described serial ports is sent to described client process;
If the described serial ports of step 2 is opened, described client process sends the instruction of read/write serial equipment;
Step 3, described service processes receive the instruction of described read/write serial equipment; If the instruction of the read/write serial equipment that receives is at least two, described service processes is carried out the operation of one of them read/write serial equipment instruction earlier;
After step 4, described service processes execute the operation of described one of them read/write instruction,, carry out the instruction of next read/write serial equipment simultaneously with writing the byte number of serial equipment or sending to described client process from the data that serial equipment reads.
2. the method for process according to claim 1 and serial equipment communicating is characterized in that: described client process sends described query statement and the instruction of read/write serial equipment by shared drive.
3. the method for process according to claim 1 and serial equipment communicating is characterized in that:
In the step 1, described client process sends described query statement by network to described service processes, and described service processes sends to this client process to the status information of described serial ports by network;
In the step 2, described client process sends described read/write serial ports instruction by network to described service processes;
In the step 4, described service processes sends to described client process to the data that write the byte number of serial equipment or read by network.
4. the method for process according to claim 1 and 2 and serial equipment communicating, it is characterized in that, described step 2 also comprises: if described serial ports is not opened, described client process sends the instruction of opening serial ports to service processes, and described service processes removes to open described serial ports according to described instruction of opening serial ports; If open success, then send and open success message to described client process, described client process receive described successfully open message after, begin to send the instruction of read/write serial equipment.
5. the method for process according to claim 3 and serial equipment communicating, it is characterized in that: described step 2 also comprises: if described serial ports is not opened, described client process sends the instruction of opening serial ports by network to service processes, and described service processes removes to open described serial ports according to described instruction of opening serial ports; If open success, then send to described client process and open success message by network, described client process receive described successfully open message after, begin to send the instruction of read/write serial equipment by network.
6. the method for process according to claim 4 and serial equipment communicating is characterized in that: in the described step 2, if open the serial ports failure, send to described client process and open the serial ports failure.
7. the method for process according to claim 1 and 2 and serial equipment communicating, it is characterized in that, step 3 also comprises: if the instruction of described read/write serial equipment is one, described service processes will write the byte number of serial equipment or send to described client process from the data that serial equipment reads after executing this read/write serial equipment instruction.
8. the device of process and serial equipment communicating is characterized in that, comprising:
Detection module is used for the instruction of the detection com-state sent according to communication module, detects described com-state, and the status information of described serial ports is sent to communication module;
Communication module is used to receive the instruction of the detection com-state that this locality or far-end client process send, and sends to described detection module, and described com-state information sent to the client process of this locality or far-end; When serial ports is opened, receive the read/write serial equipment instruction of the client process of this locality or far-end, and send to processing module, by described processing module serial equipment is carried out read/write operation, and described processing module is write the byte number of serial equipment or sends to described client process from the data that serial equipment reads; If serial ports is not opened, receive the instruction of opening serial ports that this locality or far-end client process send, and send to described processing module, remove to open serial ports by described processing module, and described serial ports is opened the client process that success or failed message send to this locality or far-end;
Processing module is used for according to described read/write serial equipment instruction successively to the serial equipment executable operations; Open serial ports instruction and remove to open serial ports according to described, and processing result information is sent to described communication module.
CNB2007100327530A 2007-12-26 2007-12-26 The method of a kind of process and serial equipment communicating and device thereof Expired - Fee Related CN100570586C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2007100327530A CN100570586C (en) 2007-12-26 2007-12-26 The method of a kind of process and serial equipment communicating and device thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2007100327530A CN100570586C (en) 2007-12-26 2007-12-26 The method of a kind of process and serial equipment communicating and device thereof

Publications (2)

Publication Number Publication Date
CN101216810A true CN101216810A (en) 2008-07-09
CN100570586C CN100570586C (en) 2009-12-16

Family

ID=39623243

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2007100327530A Expired - Fee Related CN100570586C (en) 2007-12-26 2007-12-26 The method of a kind of process and serial equipment communicating and device thereof

Country Status (1)

Country Link
CN (1) CN100570586C (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107368301A (en) * 2017-06-27 2017-11-21 深圳市爱培科技术股份有限公司 A kind of serial ports framework agreement implementation method, storage medium and device
CN107945430A (en) * 2017-11-24 2018-04-20 上海动联信息技术股份有限公司 A kind of two-way concurrent means of communication based on serial ports for being used for intelligent POS machine
CN114500627A (en) * 2021-12-27 2022-05-13 南京南瑞继保电气有限公司 Method, device and equipment for remotely accessing serial port equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107368301A (en) * 2017-06-27 2017-11-21 深圳市爱培科技术股份有限公司 A kind of serial ports framework agreement implementation method, storage medium and device
CN107945430A (en) * 2017-11-24 2018-04-20 上海动联信息技术股份有限公司 A kind of two-way concurrent means of communication based on serial ports for being used for intelligent POS machine
CN114500627A (en) * 2021-12-27 2022-05-13 南京南瑞继保电气有限公司 Method, device and equipment for remotely accessing serial port equipment and storage medium

Also Published As

Publication number Publication date
CN100570586C (en) 2009-12-16

Similar Documents

Publication Publication Date Title
CN100401812C (en) Back-up method of application program in portable phone set
KR101596172B1 (en) Techniques for facilitating interoperation between an accessory and multiple devices
CN100471201C (en) Cellular phone and operating method thereof
EP2288102A1 (en) Method and system for wireless data communicatiopn in data processing system with a USB interface
CN101141742B (en) Application communication method of terminal
CN100570586C (en) The method of a kind of process and serial equipment communicating and device thereof
US20040132445A1 (en) Methods and systems of sharing mutual resources between an external device and a cordless telephone via a communications medium
CN103605529A (en) Method and device for processing application program
CN101202964A (en) Method and terminal for processing business
CN103514003A (en) Program installation method and device
CN101742701A (en) Device, method and system for treating AT command
CN103619053A (en) Method for using user identification cards and communication system
CN101430671B (en) Mobile terminal peripherals coexisting apparatus
CN102665298B (en) Wireless communication module multiple return state processing method in foreground-background design
CN102905261B (en) Contact information authentication requesting and receiving method and clients
CN106506709B (en) A kind of remote journal acquisition methods and system
CN1885963B (en) Device and method for carrying out configuration and operation on mobile terminal via short message
CN103136129A (en) Apparatus and method of a portable terminal for performing communication with a device supporting media transfer protocol
CN104766103B (en) Smart card issuing method and system
CN100405290C (en) Method for transmitting control command
CN104066156B (en) The method for automatically selecting communication network
JP2001078255A (en) Mobile terminal security system
JP3949792B2 (en) POS system
JP4513717B2 (en) Call center system and call center system setting processing method
CN102118524A (en) Communication method and communication device of data network transmission

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20091216

Termination date: 20161226

CF01 Termination of patent right due to non-payment of annual fee