CN101800695A - Method for realizing synchronous communication and asynchronous communication by software - Google Patents

Method for realizing synchronous communication and asynchronous communication by software Download PDF

Info

Publication number
CN101800695A
CN101800695A CN200910312582A CN200910312582A CN101800695A CN 101800695 A CN101800695 A CN 101800695A CN 200910312582 A CN200910312582 A CN 200910312582A CN 200910312582 A CN200910312582 A CN 200910312582A CN 101800695 A CN101800695 A CN 101800695A
Authority
CN
China
Prior art keywords
message
communication
module
software
asynchronous communication
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.)
Pending
Application number
CN200910312582A
Other languages
Chinese (zh)
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.)
Sichuan Changhong Electric Co Ltd
Original Assignee
Sichuan Changhong Electric Co 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 Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN200910312582A priority Critical patent/CN101800695A/en
Publication of CN101800695A publication Critical patent/CN101800695A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The invention discloses a method for realizing synchronous communication and asynchronous communication by software, relating to the technical field of specific method which realizes communication between software functional modules. The invention provides a method for realizing the synchronous communication and asynchronous communication between software functional modules by a relative independent module algorithm, realizing synchronous communication by a registered callback function, and realizing asynchronous communication by a cyclic message array; and the invention occupies less system resource, does not base on other middleware, can be used for various development platforms and has strong transportability.

Description

A kind of software is realized the method for synchronous communication and asynchronous communication
Technical field
The present invention relates to the specific implementation method and technology field of communicating by letter between a kind of software function module, particularly a kind of software is realized the method for synchronous communication and asynchronous communication.
Background technology
At present, in the embedded product exploitation, because the continuous increase of user function demand, independently software module is more and more, and function is also more and more independent, so the intercommunication mutually of intermodule is absolutely necessary.For example: when the user came gui menu on the operating display by remote controller, can be divided into two independently modules when realizing in software: one was the remote controller receiving processing module, and one is that GUI shows and processing module.The communication of two intermodules can be divided into two kinds, i.e. asynchronous communication and synchronous communication.When for synchronous communication, the user must wait until just can carry out ensuing straighforward operation after the operation in the gui menu is finished, require real-time than higher in this case; And during asynchronous communication, can the limit operating and remote controlling, the processing in the gui menu also can be carried out on the backstage, does not have the requirement of very high real-time in this case.And in general product development, these two kinds of communication modes all are service or the interfaces (as: minigui, DirectFB etc.) that is provided by third-party middleware, not only relate to the mandate cost issues of software development, and take more system resources.Approaching prior art comprises the implementation method of CN200610154794.2 based on the interprocess asynchronous communication of Java, relates to the inter-process communication techniques field, aims to provide a kind of implementation method of the interprocess asynchronous communication based on Java.This method may further comprise the steps: the realization of (1) communication service process; (2) in-process communication service process realizes; (3) design of message; (4) realization of communication process.The present invention has adopted centralized communication mode, and with upper layer application mutual in introduced message trigger mechanism, the message of receiving is responsible for calling call back function by communication system handles.Simultaneously, message is packaged into object, utilizes the direct transmission object of serializing mechanism of Java, simplify upper layer application message encapsulation and parsing; Process only and the service interprogram communication, between process with service routine as intermediary's exchange message; Process is understood the position of service routine, and service routine keeps the information of all processes.
Summary of the invention
The objective of the invention is to propose a kind of method of utilizing software approach to realize synchronous communication and these two kinds of communication modes of asynchronous communication, and not based on any other middleware.
A kind of software is realized the method for synchronous communication and asynchronous communication, may further comprise the steps: the realization of (1) synchronous communication: 1. registration message is handled function; 2. after sending synchronization message, wait for the processing that receives message module; 3. receive message module and carry out Message Processing; 4. send message module and return result, carry out next step operation; (2) realization of asynchronous communication: 1. initial message formation, distributing system resource, the message count that initialization is read and write are 0; 2. send a message to and preserve in the message queue and ordering, make the message count that writes add 1; 3. send message module return results immediately, can carry out next step operation; 4. receive message module and regularly check the current state of message queue; 5. as when not having message readable, then wait for; 6. exist if any message, then therefrom read a piece of news, and make the message count of reading add 1; 7. receiving message module carries out the message read and handles operation.
Beneficial effect of the present invention:
A kind of software of the present invention is realized the method for synchronous communication and asynchronous communication, a more independently modular algorithm is proposed, realize the synchronous communication between each software function module and the method for asynchronous communication, utilize the call back function of a registration to realize synchronous communication, adopt the message queue of a circulation to realize the method for asynchronous communication, not only take less system resource, not based on any other middleware, and can be used for various development platform, portable strong.
Description of drawings
The present invention will illustrate by example and with reference to the mode of accompanying drawing, wherein:
Fig. 1 is the schematic flow sheet of synchronous communication of the present invention;
Fig. 2 is the schematic flow sheet of asynchronous communication of the present invention.
Embodiment
Disclosed all features in this specification, or the step in disclosed all methods or the process except mutually exclusive feature and/or step, all can make up by any way.
Disclosed arbitrary feature in this specification (comprising any accessory claim, summary and accompanying drawing) is unless special narration all can be replaced by other equivalences or the alternative features with similar purpose.That is, unless special narration, each feature is an example in a series of equivalences or the similar characteristics.
The realization of synchronous communication as shown in Figure 1: 1. registration message is handled function; 2. after sending synchronization message, wait for the processing that receives message module; 3. receive message module and carry out Message Processing; 4. send message module and return result, carry out next step operation;
The data structure of definition module is as follows:
struct__module
{
HANDLE handle; The initial address of this module of/* in internal memory, promptly label */
... the out of Memory of/* module and attribute */
WNDPROC * WindowProc; / * message processing function */
}MODULE;
The implementation method of synchronous communication SendMessage function:
SendMessage (HANDLE handle/* resource label */,
Int nType/* type of message */,
The data 1* that DWORD nData1/* transmits/,
The data 2* that DWORD nData2/* transmits/
);
Register self-defining message processing function callbackFun;
Carry out CallbackFun=GetModuleProc (handle) function: the message processing function callbackFun that finds corresponding receiver module by handle;
Directly carry out the call back function CallbackFun of this registration;
Return.
The realization of asynchronous communication as shown in Figure 2: 1. initial message formation, distributing system resource, the message count that initialization is read and write are 0; 2. send a message to and preserve in the message queue and ordering, make the message count that writes add 1; 3. send message module return results immediately, can carry out next step operation; 4. receive message module and regularly check the current state of message queue; 5. as when not having message readable, then wait for; 6. exist if any message, then therefrom read a piece of news, and make the message count of reading add 1; 7. receiving message module carries out the message read and handles operation.
The data structure of module is as follows:
struct__module
{
HANDLE handle; The initial address of this module of/* in internal memory, promptly label */
... the out of Memory of/* module and attribute */
WNDPROC * WindowProc; / * message processing function */
PMSGQUEUE pMessages; The message queue management * of this module of/*/
}MODULE;
The message queue data structure definition:
Struct__MSGQUEUE
{
Pthread_mutex_t lock; / * synchronization mechanism */
MSG msgData; / * message content and data */
Int readPos; The current position * that in message queue, can read of/*/
Int writePos; / * current in message queue writeable position */
};
The implementation method of asynchronous communication PostMessage function:
The initial message formation, the storage allocation space is initialized as 0 reading with writeable message count;
Register self-defining message processing function;
Obtain the message queue address of this module by parameter handle;
Corresponding message data is put in this message queue sorts;
Writing position in the message queue is added 1.
The present invention is not limited to aforesaid embodiment.The present invention expands to any new feature or any new combination that discloses in this manual, and the arbitrary new method that discloses or step or any new combination of process.

Claims (1)

1. a software is realized the method for synchronous communication and asynchronous communication, it is characterized in that, may further comprise the steps: the realization of (1) synchronous communication: 1. registration message is handled function; 2. after sending synchronization message, wait for the processing that receives message module; 3. receive message module and carry out Message Processing; 4. send message module and return result, carry out next step operation; (2) realization of asynchronous communication: 1. initial message formation, distributing system resource, the message count that initialization is read and write are 0; 2. send a message to and preserve in the message queue and ordering, make the message count that writes add 1; 3. send message module return results immediately, can carry out next step operation; 4. receive message module and regularly check the current state of message queue; 5. as when not having message readable, then wait for; 6. exist if any message, then therefrom read a piece of news, and make the message count of reading add 1; 7. receiving message module carries out the message read and handles operation.
CN200910312582A 2009-12-30 2009-12-30 Method for realizing synchronous communication and asynchronous communication by software Pending CN101800695A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910312582A CN101800695A (en) 2009-12-30 2009-12-30 Method for realizing synchronous communication and asynchronous communication by software

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910312582A CN101800695A (en) 2009-12-30 2009-12-30 Method for realizing synchronous communication and asynchronous communication by software

Publications (1)

Publication Number Publication Date
CN101800695A true CN101800695A (en) 2010-08-11

Family

ID=42596197

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910312582A Pending CN101800695A (en) 2009-12-30 2009-12-30 Method for realizing synchronous communication and asynchronous communication by software

Country Status (1)

Country Link
CN (1) CN101800695A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102495755A (en) * 2011-11-03 2012-06-13 深圳市开立科技有限公司 Ultrasonic measurement system and module interaction method thereof
CN108958903A (en) * 2017-05-25 2018-12-07 北京忆恒创源科技有限公司 Embedded multi-core central processing unit method for scheduling task and device
CN111310638A (en) * 2019-12-31 2020-06-19 深圳云天励飞技术有限公司 Data processing method and device and computer readable storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102495755A (en) * 2011-11-03 2012-06-13 深圳市开立科技有限公司 Ultrasonic measurement system and module interaction method thereof
CN102495755B (en) * 2011-11-03 2013-04-17 深圳市开立科技有限公司 Ultrasonic measurement system and module interaction method of ultrasonic measurement system
CN108958903A (en) * 2017-05-25 2018-12-07 北京忆恒创源科技有限公司 Embedded multi-core central processing unit method for scheduling task and device
CN108958903B (en) * 2017-05-25 2024-04-05 北京忆恒创源科技股份有限公司 Embedded multi-core central processor task scheduling method and device
CN111310638A (en) * 2019-12-31 2020-06-19 深圳云天励飞技术有限公司 Data processing method and device and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN103902390B (en) Inter-process communication method based on Android application layer and basis application communication system
JP6076480B2 (en) Service processing method and apparatus
CN102331935A (en) Embedded cross-system software development platform
CN104317661A (en) Intersystem communication method and device of dual embedded systems
CN111414265B (en) Service framework and method for calling system resources
CN101800695A (en) Method for realizing synchronous communication and asynchronous communication by software
EP2538744B1 (en) Method, device and system for communication between double central processing units
CN106896956B (en) The implementation method of multi-point touch under one kind " road " system
CN103809979A (en) Man-machine interaction software module integration system and implementing method thereof
CN101404656A (en) Software interface design method for communicating with third party intelligent equipment protocol
CN102323892A (en) Data processing method of mobile broadband device and drive device
CN104063285A (en) Message broadcast communication method based on vehicle-mounted software among modules in platform process
CN110515662A (en) Long-range control method, system, equipment and the readable storage medium storing program for executing of dual-system device
CN101355548A (en) Method and system for processing terminal data on PC side
CN101349975B (en) Method for implementing interrupt bottom semi-section mechanism in embedded operation system
CN103150162B (en) Improve the method for embedded software code degree of share
CN103077078A (en) Method of defining state transitions in a software and application control management object
CN102857705B (en) Setting and calling method for presetting bits of video equipment based on multi-channel mapping of aggregation matrix
WO2021057351A1 (en) Apparatus and method for controlling android bluetooth in glibc environment, and terminal device
CN209216131U (en) A kind of electronic tag base station and electronic labelling system
CN102694774A (en) A design method of an IPv6 micro protocol stack
CN101710951A (en) Method and system for displaying 3D menus and TV set
CN101505543A (en) Method and system for parallel processing AT command
CN101256489A (en) System and method for implementing AT command interaction with Apple computer
CN111400281A (en) GIS data quality inspection and storage method for OSS object storage

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Open date: 20100811