Detailed Description
The following describes a specific embodiment of the present invention with reference to the drawings.
The invention utilizes RTI Next DDS to construct a distributed real-time communication middleware on a VxWorks6.6 embedded real-time operating system, and the construction method comprises the following steps:
step S1: compiling source codes related to data distribution service in the RTI context DDS to generate a DDS link library file matched with an embedded RTOS (real-time operating system) VxWorks6.6 system.
Step S1.1: modifying RTI Context DDS root directory makefile
A makefile exists in the root directory of the DDS source code, and the makefile is used for compiling and generating a DDS link library. This file makes a deployment of the structure of the DDS source file to be compiled and requires that a set of modules exist in the form of a folder. The DDS runs in the VxWorks system in C/C + + language, see fig. 2, and at the API level, the contents other than DDS _ c.1.0 and DDS _ cpp.1.0 are annotated away. As such, the compiled linked library will include files at dds _ c.1.0 and dds _ cpp.1.0 in addition to the files at core folder core.1.0. For embedded platforms supporting other languages, the API in the relevant link library file can be selected according to the adopted programming language when in use.
Step S1.2, modifying related configuration file personal
Step S1.2.1: mk file records various environment variables used for compilation. The value of the environment variable OS _ ARCH corresponds to an operating system matched with the link library, the default environment is ia86linux 2.6, the default environment can be annotated, and a statement is added:
export OS_ARCH=pentiumVx6.6gcc4.1.2
the OS _ ARCH identifies environment information in which the compiled linked library runs. After the source code is compiled successfully, a compiled file will be generated under the/core.1.0/lib/$ (OS _ ARCH) directory. Where Pentium vx6.6gccc 4.1.2 represents that the link library runs on the vxworks6.6 platform, using a Pentium type BSP with a gcc version of 4.1.2.
Step S1.2.2: the environment variable WAVEWORKSHOME represents the path of the DDS source code and modifies the path into the actual path of the DDS source code, such as
export WAVEWORKSHOME=/home/admin/ndds500-buildsrc。
Step S1.3, modifying the source code generation file pentium Vx6.6gCC4.1.2.mk
Step S1.3.1: the source code generation file pentium Vx6.6gCC4.1.2.mk is located in resource.2.0\ makehome folder under the source code directory. It can be seen in the Makefile of BSP that the CPU corresponding to the BSP used in the present invention is Pentium4, and there is no corresponding source generated file in the target, so in the Pentium vx6.6gccc 4.1.2.mk file, the CPU type needs to be modified from the original Pentium to Pentium 4.
Step S1.3.2: and modifying variables WIND _ BASE and WIND _ HOME related to the VxWorks development environment workbench. The default values are:
export WIND_HOME=/local/VxWorks/GPP-3.6
export WIND_BASE=/local/VxWorks/GPP-3.6/vxworks-6.6
and modifying the default value into an actual installation directory of the workbench.
And then adding a compiling head file path under the C and C + + compilers:
-I/home/admin/WindRiver/gnu\4.1.2-vxworks-6.6\lib\gcc\i586-wrs-vxworks\4.1.2\include
s1.4, building a cross compiling environment based on a Linux operating system
In the invention, compiling environment configuration is carried out according to a source code generation file pentium Vx6.6gCC4.1.2. mk. And in a Linux operating system environment, compiling according to the modified makefile to generate a DDS link library.
And installing a Linux operating system in the VMware, decompressing the DDS source code, installing a VxWorks system Development environment, and starting a VxWorks Development shell, namely completing the construction of the cross-compiling environment.
Step S1.5, compiling DDS link library
The following instructions are entered in the VxWorks653Development shell:
Cd/home/admin/WindRiver
./wienv.sh–p vxworks6.6
Cd/home/admin/ndds500-buildsrc
Make PentiumVx6.6gcc4.1.2
and a first sentence of the instructions switches the current directory to the folder where the installed VxWorks is located, and then the second sentence is used for opening the wrenv. And next, switching the directory to a folder where a DDS source code is located, and finally executing a make instruction on a source generation file pentium Vx6.6gccc 4.1.2.mk to generate a DDS link library file which can be used in a VxWorks6.6 system.
The generated link library file has a core part positioned in a source code directory core.1.0\ lib \ pentium Vx6.6gCC4.1.2 and API parts positioned in dds _ c.1.0\ lib \ pentium Vx6.6gCC4.1.2 and dds _ cpp.1.0\ lib \ pentium Vx6.6gCC4.1.2.
And step S2, importing the link library file of the DDS by utilizing the development environment Wind River Workbench of VxWorks6.6, and completing the configuration of the related kernel component and the environment variable.
In the invention, the VxWorks6.6 development environment is Wind River Workbench, and corresponding configuration needs to be carried out in the VxWorks system when a DDS is used in the VxWorks system.
Step S2.1: adding macro definitions
Referring to fig. 3, a makefile is found in the BSP corresponding to the embedded platform, and a macro definition is added thereto:
EXTERN_DEFINE=-DFAST_REBOOT–DRTI_VXWORKS
as shown in FIG. 4, the BSP is recompiled, the property dialog box is opened according to the project built by the compiled BSP, and whether the macro definition is correctly added is checked at Build Properties, namely Build Tools.
Step S2.2: adding a Linked library File Path
In the project created in step S2.1, as shown in fig. 5, the property page is opened, and the directory where the LINK library generated above is located is added at the Build Properties — Build robots — LD _ LINK _ PATH. The edge button is clicked at LD _ LINK _ PATH, and then the address is added thereto.
Step S2.3 adding library file directory
And opening the property page of the project established in the step S2.1, and adding the address of the DDS library file at the Build Properties-Build pages as shown in the attached figure 6. An example of an address is:
D:\RTI\ndds.5.0.0\include
D:\RTI\ndds.5.0.0\include\ndds
s0604 adding VxWorks component
Step S2.4: adding kernel components
Referring to FIG. 7, the Kernel Configuration page of the project built in S0601 is opened, and the operating system components- -Real Time Process components are selected, and the components are added to the project.
Step S3: the QoS strategy in the DDS is configured by utilizing an XML file, and two transmission modes are realized: a sampling mode and a queue mode. The sampling mode is applied under the condition that the requirement on whether the data packet is lost is not high by taking transmission efficiency as priority; the queue mode ensures that all data sent can be received, and is suitable for the condition with higher requirement on data integrity.
And parameter configuration is carried out on Domain participators (Domain participants), topics (Topic), publishers (publishers) and Data writers (Data writers) entities, receivers (subscribers) and Data writers (Data readers) in the Domain participators, and Data structures corresponding to the topics are registered.
Step S3.1: setting QoS parameters
QoS policies are methods used by applications to control, manage and optimize the flow of data transmitted in a network, which can be viewed as a contract between a data provider and a receiver. The entities in the DDS all have default QoS policies, and when not modified, the application will implement communication between the entities according to the default QoS policies.
The corresponding functions are realized through corresponding settings of History, Reliability and Resource _ limits:
the History (History) policy describes the number of data samples that should be kept in the buffer when the DDS is used to effect the transfer of data. The reserved category is set by the kid parameter, ALL reservations (DDS _ KEEP _ ALL _ HISTORY _ QOS) can be selected, and the LAST N reservations in the HISTORY data (DDS _ KEEP _ LAST _ HISTORY _ QOS) can be selected, wherein the N is determined by the depth parameter. The default setting of the history policy is to keep the last history data, i.e. the value of N is set to 1.
Historical policies in QoS dictate the number of sample data retained. For data writers, these samples will be stored until the publisher sends them to the opposing data writer. For a data reader, after receiving the data, the data will be retained until the application retrieves the data. The policy applies to the subject, data reader and data writer entities through the history member of the QoS structure.
The reliability (reliability) policy describes the reliability of data transmission using DDS, and includes two sub-parameters, reliability category and duration, respectively. Wherein kind is divided into a reusable and a best effort.
If the reliability type kid is set as the default best effort, the transmission of the data takes the transmission efficiency as the primary factor, and the method is suitable for data transmission with high real-time requirement on the data. If the data requiring transmission cannot be missed, the kid value should be set to valid.
The persistence (duration) is effective only when the kind of reliability kind is set to enable. In this case, the data writer will retain the message that has been sent until notified by the data reader to confirm that the message has been received, and will not remove the retained message. If not notified by the data reader, the data is retransmitted until received.
The reliability policy applies to the subject, data reader and data writer entities.
The RESOURCE restriction (RESOURCE _ LIMITS) policy describes the local storage space that needs to be consumed when using DDS to pass through, and the declaration of the RESOURCE amount is implemented by the RESOURCE _ LIMITS member.
The resource restriction policy applies to topics, data readers, and data writers.
The functions are realized through corresponding settings of History, Reliability and Resource _ limits. Under the QoS default setting, the transmission of data can implement the sampling mode, and to implement the queue mode, the QoS policies of the subject, the data writer, and the data reader need to be set, as shown in table 1 and table 2.
TABLE 1 topic and data reader QoS policies
TABLE 2 data writer QoS policies
Step S3.2: setting DDS-related entity parameters
DDS related entities include Domain Participant (Domain Participant), Topic (Topic), Publisher (Publisher) and Data Writer (Data Writer) entities, recipient (Subscriber) and Data Writer (Data Reader). And configuring the parameters of each entity by using the XML file, and registering a data structure corresponding to each Topic.
Step S3.2.1: the data structure is registered by using an XML file, and the data format needs to be rewritten according to a certain format, for example:
step S3.2.2: binding of data structures is done for related Topic (topics) in domains, for example:
step S3.2.3: data structure binding is performed on datareader and datawriter, for example:
and S4, importing the XML file in the step S3 by using a Code Generator tool of Utilities in an RTI Launcher, automatically generating related codes, and adding the codes into a development environment of a Wind River Workbench, wherein related function APIs such as sending and receiving can be called by other function modules.
Step S4.1: as shown in FIG. 8, the XML file written in step S3 is placed in a Code Generator tool using Utilities in RTI Launcher, and the relevant Code can be automatically generated after running.
Step S4.2: and copying and pasting the code generated in the step S4.1 into a corresponding project directory, refreshing a resource panel in the development environment of the Wind River Workbench, and finding the generated code.
Step S4.3: and modifying the generated code, exposing the function interface to the outside, and declaring the function. The cycle monitoring function of the DDS needs to be set as a task, and occupies a process space independently, otherwise unexpected errors such as insufficient memory space, task blockage and the like easily occur.
After the above steps are deployed, the DDS can be sent and received in other components by means of function call.