CN102902542B - Virtual interface configuration method and device - Google Patents
Virtual interface configuration method and device Download PDFInfo
- Publication number
- CN102902542B CN102902542B CN201210367102.8A CN201210367102A CN102902542B CN 102902542 B CN102902542 B CN 102902542B CN 201210367102 A CN201210367102 A CN 201210367102A CN 102902542 B CN102902542 B CN 102902542B
- Authority
- CN
- China
- Prior art keywords
- message
- interface
- linked list
- data
- data object
- 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.)
- Expired - Fee Related
Links
Landscapes
- Computer And Data Communications (AREA)
Abstract
一种虚拟接口配置方法,包括以下步骤:获取虚拟接口传递的消息的基本参数;将所述消息的基本参数赋给预定义的通用接口中的头对象结构中消息对应的基本参数变量;将指向所述消息的虚拟接口的指针作为链表节点添加在预定义的通用接口中的数据对象结构中的链表结构中;获取包含所述消息的链表结构的校验码的数据对象校验结构;获取预定义的通用接口的通用参数,将预定义的通用接口的通用参数、包含消息的基本参数的头对象结构、包含所述消息的链表结构和包含所述消息的数据对象校验结构进行组合构成传递所述消息的虚拟接口。此外还提供了一种虚拟接口配置装置。上述虚拟接口配置方法和装置,减少了大量重复的代码数据,节省了存储空间,且操作方便。
A method for configuring a virtual interface, comprising the steps of: obtaining basic parameters of messages delivered by a virtual interface; assigning the basic parameters of the messages to the corresponding basic parameter variables in the header object structure of the predefined general interface; pointing to The pointer of the virtual interface of the message is added as a linked list node in the linked list structure in the data object structure in the predefined general interface; obtain the data object verification structure containing the verification code of the linked list structure of the message; obtain the pre-defined The general parameters of the defined general interface, the general parameters of the predefined general interface, the header object structure containing the basic parameters of the message, the linked list structure containing the message, and the data object verification structure containing the message are combined to form a transfer The virtual interface for the message. In addition, a virtual interface configuration device is provided. The above virtual interface configuration method and device reduce a lot of repeated code data, save storage space, and are easy to operate.
Description
技术领域 technical field
本发明涉及计算机技术,特别是涉及一种虚拟接口配置方法和装置。The invention relates to computer technology, in particular to a virtual interface configuration method and device.
背景技术 Background technique
随着计算机技术的发展,消费类电子产品的功能越来越丰富,极大的满足了人们的需求。传统的消费类电子产品底层设计一般是基于各种代码架构的软件层,不同的软件层之间的模块之间的接口主要是以函数的方式实现的。不同功能业务的处理,其控制参数和需要传递的数据格式也不同,需要通过不同的函数接口来实现上下层之间、模块之间的通信,不同的函数接口通过大量不同的代码实现。With the development of computer technology, the functions of consumer electronic products are becoming more and more abundant, which greatly meets the needs of people. The underlying design of traditional consumer electronics products is generally based on software layers of various code architectures, and the interfaces between modules between different software layers are mainly implemented in the form of functions. The processing of different functional services has different control parameters and data formats that need to be transmitted. It is necessary to implement communication between the upper and lower layers and between modules through different function interfaces. Different function interfaces are implemented through a large number of different codes.
然而,很多函数接口仅仅在参数上存在少许的差异,却采用大量的不同代码来维护,需要存储大量的代码数据,占用存储空间,且针对不同的模块之间的通信需要调用不同的接口,操作繁琐。However, many function interfaces have only a few differences in parameters, but use a large number of different codes to maintain, need to store a large amount of code data, occupy storage space, and need to call different interfaces for communication between different modules. cumbersome.
发明内容 Contents of the invention
基于此,有必要针对占用大量存储空间且调用不同的接口操作繁琐的问题,提供一种能节省存储空间且操作方便的虚拟接口配置方法。Based on this, it is necessary to provide a virtual interface configuration method that can save storage space and is easy to operate, aiming at the problem of occupying a large amount of storage space and calling different interfaces is cumbersome.
一种虚拟接口配置方法,包括以下步骤:A virtual interface configuration method, comprising the following steps:
获取虚拟接口传递的消息的基本参数;Obtain the basic parameters of the message passed by the virtual interface;
将所述消息的基本参数赋给预定义的通用接口中的头对象结构中消息对应的基本参数变量;assigning the basic parameters of the message to the basic parameter variables corresponding to the message in the header object structure in the predefined general interface;
将指向所述消息的虚拟接口的指针作为链表节点添加在预定义的通用接口中的数据对象结构中的链表结构中;Adding the pointer to the virtual interface of the message as a linked list node in the linked list structure in the data object structure in the predefined common interface;
获取包含所述消息的链表结构的校验码的数据对象校验结构;Obtain a data object verification structure of the verification code of the linked list structure containing the message;
获取预定义的通用接口的通用参数,将预定义的通用接口的通用参数、包含所述消息的基本参数的头对象结构、包含所述消息的链表结构和包含所述消息的数据对象校验结构进行组合构成传递所述消息的虚拟接口。Obtain the general parameters of the predefined general interface, combine the general parameters of the predefined general interface, the header object structure containing the basic parameters of the message, the linked list structure containing the message and the data object verification structure containing the message Combining constitutes a virtual interface for passing said messages.
在其中一个实施例中,在所述获取虚拟接口传递的消息的类型标识的步骤之前,包括步骤:In one of the embodiments, before the step of obtaining the type identification of the message delivered by the virtual interface, the steps include:
预定义通用接口;Predefined common interface;
所述预定义通用接口的步骤包括:The steps of the predefined common interface include:
预定义通用接口的通用参数,所述通用参数包括头对象变量、数据对象指针和数据对象校验指针;Predefine the common parameters of the common interface, the common parameters include header object variable, data object pointer and data object verification pointer;
预定义通用接口的头对象结构;The header object structure of the predefined common interface;
预定义通用接口的数据对象结构,所述数据对象结构中包括链表结构,所述链表结构中包括链表节点;Predefining the data object structure of the general interface, the data object structure includes a linked list structure, and the linked list structure includes linked list nodes;
预定义通用接口的数据对象校验结构,所述数据对象校验结构存储链表结构的校验码。The data object verification structure of the general interface is predefined, and the data object verification structure stores the verification code of the linked list structure.
在其中一个实施例中,所述消息的基本参数变量包括消息的类型标识变量、消息长度变量、数据对象校验长度变量。In one of the embodiments, the basic parameter variables of the message include a message type identification variable, a message length variable, and a data object check length variable.
在其中一个实施例中,所述获取虚拟接口传递的消息的基本参数的步骤之后,还包括:In one of the embodiments, after the step of obtaining the basic parameters of the message delivered by the virtual interface, it further includes:
检测所述虚拟接口传递的消息的数据长度是否为0,若是,则所述消息为控制消息;若否,则所述消息为控制加数据消息。Detecting whether the data length of the message transmitted by the virtual interface is 0, if yes, the message is a control message; if not, the message is a control plus data message.
在其中一个实施例中,所述校验码为循环冗余校验码。In one of the embodiments, the check code is a cyclic redundancy check code.
一种虚拟接口配置装置,包括:A virtual interface configuration device, comprising:
获取模块,用于获取虚拟接口传递的消息的基本参数;The obtaining module is used to obtain the basic parameters of the message passed by the virtual interface;
赋值模块,用于将所述消息的基本参数赋给预定义的通用接口中的头对象结构中消息对应的基本参数变量;An assignment module, configured to assign the basic parameters of the message to the basic parameter variables corresponding to the message in the header object structure in the predefined general interface;
添加模块,用于将指向所述消息的虚拟接口的指针作为链表节点添加在预定义的通用接口中的数据对象结构中的链表结构中;Adding a module for adding the pointer to the virtual interface of the message as a linked list node in the linked list structure in the data object structure in the predefined general interface;
校验获取模块,用于获取包含所述消息的链表结构的校验码的数据对象校验结构;A verification acquisition module, configured to obtain a data object verification structure containing a verification code of a linked list structure of the message;
组合模块,用于获取预定义的通用接口的通用参数,将预定义的通用接口的通用参数、包含所述消息的基本参数的头对象结构、包含所述消息的链表结构和包含所述消息的数据对象校验结构进行组合构成传递所述消息的虚拟接口。The combination module is used to obtain the general parameters of the predefined general interface, and combine the general parameters of the predefined general interface, the head object structure containing the basic parameters of the message, the linked list structure containing the message and the The data object check structure is combined to form a virtual interface for passing the message.
在其中一个实施例中,还包括:In one of the embodiments, it also includes:
预定义模块,用于预定义通用接口;Predefined modules for predefining common interfaces;
所述预定义模块包括:The predefined modules include:
通用参数定义单元,用于预定义通用接口的通用参数,所述通用参数包括头对象变量、数据对象指针和数据对象校验指针;The general parameter definition unit is used to predefine the general parameters of the general interface, and the general parameters include header object variables, data object pointers and data object verification pointers;
头对象定义单元,用于预定义通用接口的头对象结构;The header object definition unit is used to predefine the header object structure of the common interface;
数据对象结构定义单元,用于预定义通用接口的数据对象结构,所述数据对象结构中包括链表结构,所述链表结构中包括链表节点;The data object structure definition unit is used to predefine the data object structure of the general interface, the data object structure includes a linked list structure, and the linked list structure includes linked list nodes;
校验结构定义单元,用于预定义通用接口的数据对象校验结构,所述数据对象校验结构存储链表结构的校验码。The verification structure definition unit is used to predefine the data object verification structure of the general interface, and the data object verification structure stores the verification code of the linked list structure.
在其中一个实施例中,所述消息的基本参数变量包括消息的类型标识变量、消息长度变量、数据对象校验长度变量。In one of the embodiments, the basic parameter variables of the message include a message type identification variable, a message length variable, and a data object check length variable.
在其中一个实施例中,还包括:In one of the embodiments, it also includes:
检测模块,用于检测所述虚拟接口传递的消息的数据长度是否为0,若是,则所述消息为控制消息;若否,则所述消息为控制加数据消息。The detection module is used to detect whether the data length of the message transmitted by the virtual interface is 0, if yes, the message is a control message; if not, the message is a control plus data message.
在其中一个实施例中,所述校验码为循环冗余校验码。In one of the embodiments, the check code is a cyclic redundancy check code.
上述虚拟接口配置方法和装置,通过将获取的消息的基本参数赋给通用接口中的消息基本参数变量,并添加该消息对应的虚拟接口的指针,构成了虚拟接口,对不同的消息所对应的虚拟接口只需修改部分变量值,不需重新设计接口,减少了大量重复的代码数据,节省了存储空间,且操作方便。The above virtual interface configuration method and device, by assigning the basic parameters of the obtained message to the message basic parameter variable in the general interface, and adding the pointer of the virtual interface corresponding to the message, a virtual interface is formed, and different messages correspond to The virtual interface only needs to modify some variable values without redesigning the interface, which reduces a lot of repeated code data, saves storage space, and is easy to operate.
附图说明 Description of drawings
图1为一个实施例中虚拟接口配置方法的流程示意图;Fig. 1 is a schematic flow diagram of a virtual interface configuration method in an embodiment;
图2为一个实施例中预定义通用接口的具体流程示意图;Fig. 2 is a specific schematic flow diagram of a predefined general interface in an embodiment;
图3为一个实施例中成员封装结构示意图;Fig. 3 is a schematic diagram of member encapsulation structure in an embodiment;
图4为一个实施例中消息格式示意图;Fig. 4 is a schematic diagram of a message format in an embodiment;
图5为虚拟接口配置方法可应用在不同结构层之间的消息传递的示意图;5 is a schematic diagram of a virtual interface configuration method applicable to message transmission between different structural layers;
图6为平台层与中间件层传递消息的示意图;Fig. 6 is a schematic diagram of message delivery between the platform layer and the middleware layer;
图7为系统结构示意图;Figure 7 is a schematic diagram of the system structure;
图8为一个实施例中虚拟接口配置装置的内部结构示意图;FIG. 8 is a schematic diagram of the internal structure of a virtual interface configuration device in an embodiment;
图9为另一个实施例中虚拟接口配置装置的内部结构示意图;Fig. 9 is a schematic diagram of the internal structure of a virtual interface configuration device in another embodiment;
图10为一个实施例中预定义模块的内部结构示意图。Fig. 10 is a schematic diagram of the internal structure of a predefined module in an embodiment.
具体实施方式 detailed description
下面结合具体的实施例及附图对虚拟接口配置方法和装置的技术方案进行详细的描述,以使其更加清楚。The technical solution of the virtual interface configuration method and device will be described in detail below in conjunction with specific embodiments and accompanying drawings, so as to make it more clear.
如图1所示,在一个实施例中,一种虚拟接口配置方法,包括以下步骤:As shown in Figure 1, in one embodiment, a kind of virtual interface configuration method comprises the following steps:
步骤S110,获取虚拟接口传递的消息的基本参数。Step S110, acquiring the basic parameters of the message transmitted by the virtual interface.
具体的,因业务逻辑增加新的虚拟接口时,先获取虚拟接口传递的消息的基本参数。基本参数包括类型标识、消息长度、消息分组、数据对象校验位长度等。类型标识包括主类型标识和子类型标识,可采用1个字节,以十六进制表示。例如,主类型可为播放类,子类型为播放控制、播放暂停、播放停止或播放快进等。Specifically, when a new virtual interface is added due to business logic, the basic parameters of the message transmitted by the virtual interface are obtained first. Basic parameters include type identification, message length, message grouping, data object parity length, etc. The type identifier includes a main type identifier and a subtype identifier, and can be represented by 1 byte in hexadecimal notation. For example, the main type may be a playback class, and the subtypes may be playback control, playback pause, playback stop, or playback fast-forward.
在步骤S110之后,检测消息的数据长度是否为0,若是,则该消息为控制消息;若否,则该消息为附带有数据内容的消息,即控制加数据消息;在具体应用中,可针对不同的消息做不同的处理。具体的,传递的消息可仅包括控制位,而不包括数据内容,则该消息为控制消息,在应用时仅需解析该控制消息,完成相应的控制操作;传递的消息也可同时包括数据内容和控制位,则该消息为控制加数据消息,在应用时需要进入消息处理流程,例如消息解析,消息分组或者消息转发等。After step S110, detect whether the data length of message is 0, if so, then this message is a control message; Different messages are processed differently. Specifically, the transmitted message may only include control bits, but not data content, then the message is a control message, and only need to parse the control message to complete the corresponding control operation during application; the transmitted message may also include data content at the same time and control bits, the message is a control plus data message, which needs to enter the message processing flow during application, such as message parsing, message grouping, or message forwarding.
步骤S120,将该消息的基本参数赋给预定义的通用接口中的头对象结构中消息对应的基本参数变量。Step S120, assigning the basic parameters of the message to the basic parameter variables corresponding to the message in the header object structure in the predefined common interface.
具体的,首先预先定义通用接口。如图2所示,预定义通用接口的步骤包括:Specifically, a common interface is firstly defined in advance. As shown in Figure 2, the steps of predefining a common interface include:
步骤S210,预定义通用接口的通用参数,该通用参数包括头对象变量、数据对象指针和数据对象校验指针。Step S210, predefine general parameters of the general interface, the general parameters include header object variables, data object pointers and data object verification pointers.
具体的,通用接口的通用参数以数据结构方式定义,如下描述:Specifically, the general parameters of the general interface are defined in a data structure, as described below:
其中,typedefHeader对象是定义头对象变量,typedef*数据对象是定义数据对象指针,typedef*数据校验对象是定义数据对象校验指针。Among them, the typedefHeader object is the definition header object variable, the typedef* data object is the definition data object pointer, and the typedef* data verification object is the definition data object verification pointer.
步骤S220,预定义通用接口的头对象结构。Step S220, predefine the header object structure of the common interface.
具体的,通用接口的头对象结构中包括若干消息基本参数变量,该消息基本参数变量主要包括消息的类型标识变量、消息长度变量、数据对象校验长度变量。进一步,消息基本参数变量还可包括消息是否分组、分组数量等,但不限于此。Specifically, the header object structure of the general interface includes several message basic parameter variables, and the message basic parameter variables mainly include a message type identification variable, a message length variable, and a data object check length variable. Further, the basic parameter variable of the message may also include whether the message is grouped, the number of groups, etc., but is not limited thereto.
可采用如下定义头对象结构,但不限于此:The header object structure can be defined as follows, but not limited to:
步骤S230,预定义通用接口的数据对象结构,该数据对象结构中包括链表结构,该链表结构中包括链表节点。Step S230, predefine the data object structure of the general interface, the data object structure includes a linked list structure, and the linked list structure includes linked list nodes.
具体的,通用接口的数据对象结构中包括链表结构,链表结构中每一个链表节点是一个结构体指针,该结构体指针指向一个数据结构,即表示一个虚拟接口的参数。例如虚拟接口有3个参数,则链表结构中有3个相应的结构体指针。链表结构中的链表节点数随着消息的不同而不同。如此可以完成不同功能接口的消息传递。Specifically, the data object structure of the general interface includes a linked list structure, and each linked list node in the linked list structure is a structure pointer, and the structure pointer points to a data structure, which represents a parameter of a virtual interface. For example, if the virtual interface has 3 parameters, then there are 3 corresponding structure pointers in the linked list structure. The number of linked list nodes in the linked list structure varies with different messages. In this way, the message delivery of different functional interfaces can be completed.
可采用如下定义,但不限于此:The following definitions may be used, but are not limited to:
其中,成员封装结构是一个链接结构,链表结构中存放若干与消息相关的数据结构指针。如图3所示,成员封装结构中包括数据结构1的地址至数据结构N的地址。Among them, the member encapsulation structure is a link structure, and several data structure pointers related to the message are stored in the linked list structure. As shown in FIG. 3 , the member encapsulation structure includes the address of data structure 1 to the address of data structure N.
步骤S240,预定义通用接口的数据对象校验结构,该数据对象校验结构存储链表结构的校验码。Step S240, predefine the data object verification structure of the common interface, and the data object verification structure stores the verification code of the linked list structure.
具体的,通用接口的数据对象校验结构可采用如下定义,但不限于此。Specifically, the data object verification structure of the general interface can be defined as follows, but is not limited thereto.
其中,数据校验成员是用于存储数据对象的链接结构的校验码和消息分组。校验码可为循环冗余校验码。Wherein, the data verification member is a verification code and a message group used to store the link structure of the data object. The check code can be a cyclic redundancy check code.
预定义了通用接口,通过通用接口传递的消息的格式包括头数据、数据内容和校验数据,如表1。The general interface is predefined, and the format of the message transmitted through the general interface includes header data, data content and verification data, as shown in Table 1.
表1Table 1
如图4所示,头数据包括主消息类型、子消息类型、消息长度、消息校验控制、控制位1至控制位N;数据包括数据1至N。As shown in FIG. 4 , header data includes main message type, sub-message type, message length, message check control, control bit 1 to control bit N; data includes data 1 to N.
步骤S130,将指向该消息的虚拟接口的指针作为链表节点添加在预定义的通用接口中的数据对象结构中的链表结构中。Step S130, adding the pointer to the virtual interface of the message as a linked list node in the linked list structure in the data object structure in the predefined common interface.
具体的,将指向该消息的虚拟接口的指针以链表节点方式添加在通用接口的数据对象结构中的链表结构中,该链表节点成为一个指向虚拟接口的结构体指针。Specifically, the pointer to the virtual interface of the message is added to the linked list structure in the data object structure of the general interface in the form of a linked list node, and the linked list node becomes a structure pointer pointing to the virtual interface.
步骤S140,获取包含所述消息的链表结构的校验码的数据对象校验结构。Step S140, acquiring a data object verification structure including the verification code of the linked list structure of the message.
具体的,重新计算包含了该消息的链表结构的校验码,将其保存在数据对象校验结构中。Specifically, the check code of the linked list structure including the message is recalculated, and stored in the data object check structure.
步骤S150,获取预定义的通用接口的通用参数,将预定义的通用接口的通用参数、包含所述消息的基本参数的头对象结构、包含所述消息的链表结构和包含所述消息的数据对象校验结构进行组合构成传递所述消息的虚拟接口。Step S150, obtain the general parameters of the predefined general interface, and combine the general parameters of the predefined general interface, the header object structure containing the basic parameters of the message, the linked list structure containing the message, and the data object containing the message The check structures are combined to form a virtual interface for passing the message.
具体的,将消息的基本参数赋给通用接口中定义的消息的基本参数变量,并在链表结构中添加链表节点后,构成了传递该消息的虚拟接口。Specifically, the basic parameter of the message is assigned to the basic parameter variable of the message defined in the general interface, and after adding the linked list node in the linked list structure, a virtual interface for transmitting the message is formed.
上述虚拟接口配置方法,通过将获取的消息的基本参数赋给通用接口中的消息基本参数变量,并添加该消息对应的虚拟接口的指针,构成了虚拟接口,对不同的消息所对应的虚拟接口只需修改部分变量值,不需重新设计接口,减少了大量重复的代码数据,节省了存储空间,且操作方便。The above virtual interface configuration method, by assigning the basic parameters of the obtained message to the message basic parameter variable in the general interface, and adding the pointer of the virtual interface corresponding to the message, constitutes a virtual interface, and the virtual interface corresponding to different messages Only need to modify part of the variable value, no need to redesign the interface, reduce a lot of repeated code data, save storage space, and easy to operate.
上述虚拟接口配置方法可应用在不同结构层之间的消息传递,如图5所示,具体包括:The above virtual interface configuration method can be applied to message transmission between different structural layers, as shown in Figure 5, specifically including:
步骤S310,获取第二结构层向第三结构层传递第一结构层消息的请求,所述第一结构层、第二结构层相邻,所述第二结构层与第三结构层相邻。Step S310, obtaining a request from the second structural layer to transmit the first structural layer message to the third structural layer, the first structural layer and the second structural layer are adjacent, and the second structural layer is adjacent to the third structural layer.
具体的,例如第一结构层为MiddleWare(中间件)层,第二结构层为平台层,第三结构层为驱动层。平台层获取中间件层消息。中间件层消息包括MiddleWare层头数据(MiddleWare层Header)、MiddleWare层数据和MiddleWare层校验数据。Specifically, for example, the first structural layer is a MiddleWare (middleware) layer, the second structural layer is a platform layer, and the third structural layer is a driver layer. The platform layer gets the middleware layer messages. The middleware layer message includes MiddleWare layer header data (MiddleWare layer Header), MiddleWare layer data and MiddleWare layer verification data.
步骤S320,将第一结构层消息加在第二结构层的头数据和第二结构层的数据之间组装为第二结构层消息。In step S320, the first structural layer message is assembled between the header data of the second structural layer and the data of the second structural layer to form a second structural layer message.
具体的,如图6所示,平台层将MiddleWare层消息加在平台层Header(头对象结构)和平台层数据。平台层消息包括平台层Header、MiddleWare层消息、平台层数据和平台层校验数据。Specifically, as shown in Figure 6, the platform layer adds the MiddleWare layer message to the platform layer Header (header object structure) and platform layer data. Platform layer messages include platform layer Header, MiddleWare layer messages, platform layer data and platform layer verification data.
步骤S330,将所述第二结构层消息发送给第三结构层。Step S330, sending the second structural layer message to the third structural layer.
例如,将平台层消息发送给驱动层。For example, sending platform layer messages to the driver layer.
上述虚拟接口配置方法中,第二结构层向第一结构层传输消息时,以平台层和MiddleWare层为例,平台层的消息包括平台层头数据、数据和校验数据,平台层将平台层消息发送给MiddleWare层后,MiddleWare层接收到消息后按MiddleWare层消息格式解析该平台层的消息。In the above virtual interface configuration method, when the second structural layer transmits messages to the first structural layer, taking the platform layer and MiddleWare layer as an example, the message of the platform layer includes platform layer header data, data and verification data, and the platform layer transfers the platform layer After the message is sent to the MiddleWare layer, the MiddleWare layer parses the message of the platform layer according to the message format of the MiddleWare layer after receiving the message.
此外,上述虚拟接口配置方法还可应用于配置LinuxKernel层与平台层之间的接口,平台层与MiddleWare层之间的接口,以及MiddleWare层与应用层之间的接口。In addition, the above virtual interface configuration method can also be applied to configure the interface between the LinuxKernel layer and the platform layer, the interface between the platform layer and the MiddleWare layer, and the interface between the MiddleWare layer and the application layer.
如图7所示,LinuxKernel层用于提供Linux系统组件驱动服务,该层涉及多种硬件驱动。As shown in Figure 7, the LinuxKernel layer is used to provide driver services for Linux system components, and this layer involves various hardware drivers.
平台层包括提供OS相关的组件,提供C/C++库来支持上层(中间件层)。包括可以定制的C/C++库,标准的核心C库和运行环境,例如虚拟机。平台层设有硬件抽象层接口(接口A)和开发语言适配接口(接口B)。硬件抽象层接口提供各种与硬件相关的接口,完成平台层与不同硬件接口的消息通信。开发语言适配接口用于完成高级语言与本地语言的转换,使高级语言可以使用本地语言,例如JNI,在Java代码中嵌入NativeC/C++。The platform layer includes providing OS-related components and providing C/C++ libraries to support the upper layer (middleware layer). Including customizable C/C++ library, standard core C library and operating environment, such as virtual machine. The platform layer has a hardware abstraction layer interface (interface A) and a development language adaptation interface (interface B). The hardware abstraction layer interface provides various hardware-related interfaces to complete the message communication between the platform layer and different hardware interfaces. The development language adaptation interface is used to complete the conversion between high-level language and local language, so that high-level language can use local language, such as JNI, and embed NativeC/C++ in Java code.
MiddleWare层用于提供系统核心应用服务的APIApplicationProgrammingInterface,应用程序接口)框架,处理不同的业务逻辑,可以在该层开发用户自己的服务应用,可提供接口C。MiddleWare层还提供多种服务功能,例如数据共享服务、即时消息通信服务等。The MiddleWare layer is used to provide the APIApplicationProgrammingInterface (application programming interface) framework of the core application services of the system, and handle different business logics. Users can develop their own service applications in this layer and provide interface C. The MiddleWare layer also provides a variety of service functions, such as data sharing services, instant messaging services, and so on.
应用层包括系统初始应用和用户自行开发的应用。The application layer includes the initial application of the system and the application developed by the user.
如图8所示,在一个实施例中,一种虚拟接口配置装置,包括获取模块110、赋值模块120、添加模块130、校验获取模块140和组合模块150。其中:As shown in FIG. 8 , in one embodiment, a virtual interface configuration device includes an acquisition module 110 , an assignment module 120 , an addition module 130 , a verification acquisition module 140 and a combination module 150 . in:
获取模块110用于获取应用程序接口中的消息的基本参数。具体的,因业务逻辑增加新的虚拟接口时,先获取虚拟接口传递的消息的基本参数。基本参数包括类型标识、消息长度、消息分组、数据对象校验位长度等。类型标识包括主类型标识和子类型标识,可采用1个字节,以十六进制表示。例如,主类型可为播放类,子类型为播放控制、播放暂停、播放停止或播放快进等。The obtaining module 110 is used for obtaining the basic parameters of the message in the API. Specifically, when a new virtual interface is added due to business logic, the basic parameters of the message transmitted by the virtual interface are obtained first. Basic parameters include type identification, message length, message grouping, data object parity length, etc. The type identifier includes a main type identifier and a subtype identifier, and can be represented by 1 byte in hexadecimal notation. For example, the main type may be a playback class, and the subtypes may be playback control, playback pause, playback stop, or playback fast-forward.
赋值模块120用于将该消息的基本参数赋给预定义的通用接口中的头对象结构中消息对应的基本参数变量。The assignment module 120 is configured to assign the basic parameters of the message to the basic parameter variables corresponding to the message in the header object structure in the predefined common interface.
添加模块130用于将指向该消息的虚拟接口的指针作为链表节点添加在预定义的通用接口中的数据对象结构中的链表结构中。具体的,将指向该消息的虚拟接口的指针以链表节点方式添加在通用接口的数据对象结构中的链表结构中,该链表节点成为一个指向虚拟接口的结构体指针。The adding module 130 is used for adding the pointer pointing to the virtual interface of the message as a linked list node in the linked list structure in the data object structure in the predefined common interface. Specifically, the pointer to the virtual interface of the message is added to the linked list structure in the data object structure of the general interface in the form of a linked list node, and the linked list node becomes a structure pointer pointing to the virtual interface.
校验获取模块140用于获取包含所述消息的链表结构的校验码的数据对象校验结构。具体的,重新计算包含了该消息的链表结构的校验码,将其保存在数据对象校验结构中。The verification obtaining module 140 is configured to obtain a data object verification structure including a verification code of the linked list structure of the message. Specifically, the check code of the linked list structure including the message is recalculated, and stored in the data object check structure.
组合模块150用于获取预定义的通用接口的通用参数,将预定义的通用接口的通用参数、包含所述消息的基本参数的头对象结构、包含所述消息的链表结构和包含所述消息的数据对象校验结构进行组合构成传递该消息的虚拟接口。The combination module 150 is used to obtain the general parameters of the predefined general interface, and combine the general parameters of the predefined general interface, the head object structure containing the basic parameters of the message, the linked list structure containing the message and the The data object verification structure is combined to form a virtual interface for passing the message.
具体的,将消息的基本参数赋给通用接口中定义的消息的基本参数变量,并在链表结构中添加链表节点后,构成了传递该消息的虚拟接口。Specifically, the basic parameter of the message is assigned to the basic parameter variable of the message defined in the general interface, and after adding the linked list node in the linked list structure, a virtual interface for transmitting the message is formed.
上述虚拟接口配置装置,通过将获取的消息的基本参数赋给通用接口中的消息基本参数变量,并添加该消息对应的虚拟接口的指针,构成了虚拟接口,对不同的消息所对应的虚拟接口只需修改部分变量值,不需重新设计接口,减少了大量重复的代码数据,节省了存储空间,且操作方便。The above-mentioned virtual interface configuration device forms a virtual interface by assigning the basic parameters of the obtained message to the basic parameter variable of the message in the general interface, and adding the pointer of the virtual interface corresponding to the message, and the virtual interface corresponding to different messages Only need to modify part of the variable value, no need to redesign the interface, reduce a lot of repeated code data, save storage space, and easy to operate.
如图9所示,在一个实施例中,上述虚拟接口配置装置,除了包括获取模块110、赋值模块120、添加模块130、校验获取模块140和组合模块150,还包括预定义模块160和检验模块170。其中:As shown in Figure 9, in one embodiment, the above-mentioned virtual interface configuration device, in addition to including the acquisition module 110, the assignment module 120, the addition module 130, the verification acquisition module 140 and the combination module 150, also includes a predefined module 160 and a verification module Module 170. in:
预定义模块160用于预定义通用接口。The predefinition module 160 is used to predefine common interfaces.
如图10所示,在一个实施例中,预定义模块160包括通用参数定义单元161、头对象定义单元163、数据对象结构定义单元165和校验结构定义单元167。其中:As shown in FIG. 10 , in one embodiment, the predefined module 160 includes a general parameter definition unit 161 , a header object definition unit 163 , a data object structure definition unit 165 and a check structure definition unit 167 . in:
通用参数定义单元161用于预定义通用接口的通用参数,所述通用参数包括头对象变量、数据对象指针和数据对象校验指针。The general parameter definition unit 161 is used to predefine the general parameters of the general interface, and the general parameters include header object variables, data object pointers and data object verification pointers.
具体的,通用接口的通用参数以数据结构方式定义,如下描述:Specifically, the general parameters of the general interface are defined in a data structure, as described below:
其中,typedefHeader对象是定义头对象变量,typedef*数据对象是定义数据对象指针,typedef*数据校验对象是定义数据对象校验指针。Among them, the typedefHeader object is the definition header object variable, the typedef* data object is the definition data object pointer, and the typedef* data verification object is the definition data object verification pointer.
头对象定义单元163用于预定义通用接口的头对象结构。The header object definition unit 163 is used to predefine the header object structure of the common interface.
具体的,通用接口的头对象结构中包括若干消息基本参数变量,该消息基本参数变量主要包括消息的类型标识变量、消息长度变量、数据对象校验长度变量。进一步,消息基本参数变量还可包括消息是否分组、分组数量等,但不限于此。Specifically, the header object structure of the general interface includes several message basic parameter variables, and the message basic parameter variables mainly include a message type identification variable, a message length variable, and a data object check length variable. Further, the basic parameter variable of the message may also include whether the message is grouped, the number of groups, etc., but is not limited thereto.
可采用如下定义头对象结构,但不限于此:The header object structure can be defined as follows, but not limited to:
数据对象结构定义单元165用于预定义通用接口的数据对象结构,所述数据对象结构中包括链表结构,所述链表结构中包括链表节点。The data object structure definition unit 165 is used to predefine the data object structure of the general interface, the data object structure includes a linked list structure, and the linked list structure includes linked list nodes.
具体的,通用接口的数据对象结构中包括链表结构,链表结构中每一个链表节点是一个结构体指针,该结构体指针指向一个数据结构,即表示一个虚拟接口的参数。例如虚拟接口有3个参数,则链表结构中有3个相应的结构体指针。链表结构中的链表节点数随着消息的不同而不同。如此可以完成不同功能接口的消息传递。Specifically, the data object structure of the general interface includes a linked list structure, and each linked list node in the linked list structure is a structure pointer, and the structure pointer points to a data structure, which represents a parameter of a virtual interface. For example, if the virtual interface has 3 parameters, then there are 3 corresponding structure pointers in the linked list structure. The number of linked list nodes in the linked list structure varies with different messages. In this way, the message delivery of different functional interfaces can be completed.
可采用如下定义,但不限于此:The following definitions may be used, but are not limited to:
其中,成员封装结构是一个链接结构,链表结构中存放若干与消息相关的数据结构指针。如图3所示,成员封装结构中包括数据结构1至N地址。Among them, the member encapsulation structure is a link structure, and several data structure pointers related to the message are stored in the linked list structure. As shown in FIG. 3 , the member encapsulation structure includes addresses of data structures 1 to N.
校验结构定义单元167用于预定义通用接口的数据对象校验结构,所述数据对象校验结构存储链表结构的校验码。The verification structure definition unit 167 is used to predefine the data object verification structure of the general interface, and the data object verification structure stores the verification code of the linked list structure.
具体的,通用接口的数据对象校验结构可采用如下定义,但不限于此。Specifically, the data object verification structure of the general interface can be defined as follows, but is not limited thereto.
其中,数据校验成员是用于存储数据对象的链接结构的校验码和消息分组。校验码可为循环冗余校验码。Wherein, the data verification member is a verification code and a message group used to store the link structure of the data object. The check code can be a cyclic redundancy check code.
预定义了通用接口,通过通用接口传递的消息的格式包括头数据、数据内容和校验数据,如表1。The general interface is predefined, and the format of the message transmitted through the general interface includes header data, data content and verification data, as shown in Table 1.
如图4所示,头数据包括主消息类型、子消息类型、消息长度、消息校验控制、控制位1至控制位N;数据内容包括数据1至N。As shown in Figure 4, header data includes main message type, sub-message type, message length, message check control, control bit 1 to control bit N; data content includes data 1 to N.
检测模块170用于检测该应用程序接口中的消息的数据长度是否为0,若是,则所述消息为控制消息;若否,则该消息为附带有数据内容的消息,即控制加数据消息;在具体应用中,可针对不同的消息做不同的处理。具体的,所述消息可仅包括控制位,而不包括数据内容,则该消息为控制消息,在应用时仅需解析该控制消息,完成相应的控制操作;所述消息也可同时包括数据内容和控制位,则该消息为控制加数据消息,在应用时需要进入消息处理流程,例如消息解析,消息分组或者消息转发等。The detection module 170 is used to detect whether the data length of the message in the API is 0, if so, the message is a control message; if not, the message is a message with data content, that is, a control plus data message; In specific applications, different processing may be performed for different messages. Specifically, the message may only include control bits, but not data content, then the message is a control message, and it is only necessary to parse the control message during application to complete the corresponding control operation; the message may also include data content at the same time and control bits, the message is a control plus data message, which needs to enter the message processing flow during application, such as message parsing, message grouping, or message forwarding.
上述虚拟接口配置装置可应用在不同结构层之间的消息传递,具体过程为:The above virtual interface configuration device can be applied to message transmission between different structural layers, and the specific process is:
获取模块110获取第二结构层向第三结构层传递第一结构层消息的请求,所述第一结构层、第二结构层相邻,所述第二结构层与第三结构层相邻。The acquiring module 110 acquires a request from the second structural layer to transmit the first structural layer message to the third structural layer, the first structural layer and the second structural layer are adjacent, and the second structural layer is adjacent to the third structural layer.
具体的,例如第一结构层为MiddleWare(中间件)层,第二结构层为平台层,第三结构层为驱动层。平台层获取中间件层消息。中间件层消息包括中间层头数据(MiddleWare层Header)、MiddleWare层数据和MiddleWare层校验数据。Specifically, for example, the first structural layer is a MiddleWare (middleware) layer, the second structural layer is a platform layer, and the third structural layer is a driver layer. The platform layer gets the middleware layer messages. The middleware layer message includes the middle layer header data (MiddleWare layer Header), MiddleWare layer data and MiddleWare layer verification data.
赋值模块120将第一结构层消息的基本参数赋给第二结构层的头对象结构中的消息对应的基本参数变量。The assignment module 120 assigns the basic parameters of the message at the first structure layer to the basic parameter variables corresponding to the messages in the head object structure of the second structure layer.
添加模块130将指向第一结构层消息的指针作为链表节点添加在第二结构层接口的数据对象结构中的链表结构中。The adding module 130 adds the pointer to the first structure layer message as a linked list node in the linked list structure in the data object structure of the second structure layer interface.
组合模块150用于将第一结构层消息加在第二结构层的头数据和第二结构层的数据之间组装为第二结构层消息。The combining module 150 is configured to add the first structure layer message between the header data of the second structure layer and the data of the second structure layer to assemble the second structure layer message.
具体的,如图6所示,平台层将MiddleWare层消息加在平台层Header(头对象结构)和平台层数据。平台层消息包括平台层Header、MiddleWare层消息、平台层数据和平台层校验数据。Specifically, as shown in Figure 6, the platform layer adds the MiddleWare layer message to the platform layer Header (header object structure) and platform layer data. Platform layer messages include platform layer Header, MiddleWare layer messages, platform layer data and platform layer verification data.
上述虚拟接口配置装置还包括传输模块,传输模块用于将所述第二结构层消息发送给第三结构层。The above virtual interface configuration device further includes a transmission module, configured to send the second structural layer message to the third structural layer.
例如,将平台层消息发送给驱动层。For example, sending platform layer messages to the driver layer.
上述虚拟接口配置装置中,第二结构层向第一结构层传输消息时,以平台层和MiddleWare层为例,平台层的消息包括平台层头数据、数据和校验数据,平台层将平台层消息发送给MiddleWare层后,MiddleWare层接收到消息后按MiddleWare层消息格式解析该平台层的消息。In the above-mentioned virtual interface configuration device, when the second structural layer transmits a message to the first structural layer, taking the platform layer and MiddleWare layer as an example, the message of the platform layer includes platform layer header data, data and verification data, and the platform layer transfers the platform layer After the message is sent to the MiddleWare layer, the MiddleWare layer parses the message of the platform layer according to the message format of the MiddleWare layer after receiving the message.
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation modes of the present invention, and the description thereof is relatively specific and detailed, but should not be construed as limiting the patent scope of the present invention. It should be pointed out that those skilled in the art can make several modifications and improvements without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent for the present invention should be based on the appended claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210367102.8A CN102902542B (en) | 2012-09-27 | 2012-09-27 | Virtual interface configuration method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210367102.8A CN102902542B (en) | 2012-09-27 | 2012-09-27 | Virtual interface configuration method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102902542A CN102902542A (en) | 2013-01-30 |
CN102902542B true CN102902542B (en) | 2016-06-01 |
Family
ID=47574789
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210367102.8A Expired - Fee Related CN102902542B (en) | 2012-09-27 | 2012-09-27 | Virtual interface configuration method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102902542B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112463255B (en) * | 2020-12-10 | 2024-06-07 | 广州极飞科技股份有限公司 | Virtual interface loading method and device, physical network card and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1549108A (en) * | 2003-05-07 | 2004-11-24 | 中兴通讯股份有限公司 | Method for realizing communication process zero copy information queue |
CN1811717A (en) * | 2006-01-10 | 2006-08-02 | 杭州东信灵通电子实业公司 | Universal interprocess communication achieving method |
US7146618B1 (en) * | 1997-11-10 | 2006-12-05 | Microsoft Corporation | Simple object access protocol |
CN101441566A (en) * | 2008-11-18 | 2009-05-27 | 腾讯科技(深圳)有限公司 | Embedded type platform and method for dynamically linking program on the same |
CN101582031A (en) * | 2009-06-16 | 2009-11-18 | 中兴通讯股份有限公司 | Linked list management system based on structured language and method |
-
2012
- 2012-09-27 CN CN201210367102.8A patent/CN102902542B/en not_active Expired - Fee Related
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7146618B1 (en) * | 1997-11-10 | 2006-12-05 | Microsoft Corporation | Simple object access protocol |
CN1549108A (en) * | 2003-05-07 | 2004-11-24 | 中兴通讯股份有限公司 | Method for realizing communication process zero copy information queue |
CN1811717A (en) * | 2006-01-10 | 2006-08-02 | 杭州东信灵通电子实业公司 | Universal interprocess communication achieving method |
CN101441566A (en) * | 2008-11-18 | 2009-05-27 | 腾讯科技(深圳)有限公司 | Embedded type platform and method for dynamically linking program on the same |
CN101582031A (en) * | 2009-06-16 | 2009-11-18 | 中兴通讯股份有限公司 | Linked list management system based on structured language and method |
Also Published As
Publication number | Publication date |
---|---|
CN102902542A (en) | 2013-01-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108965484B (en) | Internet of things data transmission method, system and terminal | |
CN106603394B (en) | Method and device for realizing subscription notification | |
CN101571811B (en) | Information transmission method and device thereof | |
CN113867732A (en) | Message information processing method, system and storage medium | |
CN116703518A (en) | Virtual package transmitting method, device, equipment and storage medium | |
CN111294235A (en) | Data processing method, device, gateway and readable storage medium | |
CN113419772A (en) | Response data packing and unpacking method, response data packing device, response data unpacking device and response data unpacking medium | |
CN110708360A (en) | An information processing method, system and electronic device | |
CN101854401A (en) | Data transmission equipment and method and data synchronization method | |
CN110324722B (en) | Method, device, equipment and storage medium for acquiring data in live broadcast room | |
EP3598720A1 (en) | Method and device for generating forwarding information | |
CN102902542B (en) | Virtual interface configuration method and device | |
JP2022136267A (en) | Message generation method and apparatus, and message processing method and apparatus | |
CN112887227B (en) | Method, system and related device for receiving messages in solid state disk | |
CN102438048B (en) | Method and system for calling remote service from Internet | |
CN111245702B (en) | Data transmission method and device based on 5GS, forwarding equipment and UPF communication equipment | |
CN109525550B (en) | Data message processing method, device and system | |
CN113630404B (en) | Protocol message transmission method, device, storage medium and terminal | |
CN117354867A (en) | Data transmission method, device and storage medium | |
CN102404215B (en) | Synchronization method for filtering database table forms, device and network equipment | |
CN113439418A (en) | Method, system, terminal and storage medium for changing resource state | |
CN109582481B (en) | Transmission method, device and equipment of call result and storage medium | |
US20160277280A1 (en) | Flow entry delivery method and communication system | |
CN114513792A (en) | Remote network control method and device based on eSIM card | |
CN113032705A (en) | Method, device, equipment and medium for processing browser page data |
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 | ||
CP03 | Change of name, title or address |
Address after: 516006 community 37, Zhongkai high tech Zone, Huizhou, Guangdong Patentee after: Tongli Technology Co.,Ltd. Address before: 516006 Guangdong province Huizhou Zhongkai hi tech Development Zone No. 19 district Patentee before: TONLY ELECTRONICS HOLDINGS Ltd. |
|
CP03 | Change of name, title or address | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20160601 |
|
CF01 | Termination of patent right due to non-payment of annual fee |