TRDP protocol stack application method based on Linux
By encapsulating the TRDP protocol stack into a library and providing API interfaces, the problems of insufficient development support for TRDP protocol stack and unsupported dual network ports in Linux operating systems are solved, and convenient integration and efficient development are achieved.
Patent Information
- Application Number
- CN202411705100.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-18
AI Technical Summary
In Linux operating systems, the development support of the TRDP protocol stack is insufficient and does not support dual network ports, which causes developers to face difficulties in porting and application.
The TRDP protocol stack is encapsulated into a library and provides an API interface to realize single-network and dual-network communication functions through configuration files, reducing development thresholds and improving programming efficiency.
It realizes convenient integration of the TRDP protocol stack on Linux operating system and dual network port support, reducing development difficulty, improving efficiency and reducing human errors.
Smart Images

Figure CN119652877A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of application of TRDP protocol stack, and in particular, to a TRDP protocol stack application method based on Linux. Background Art
[0002] According to GB / T 28029.4, TRDP is defined as a standard communication protocol for Ethernet trains, located above the transport layer (TCP / UDP), which allows devices to communicate process data and message data. Among them, UDP is used for TRDP process data communication, and UDP or TCP is used for message data communication.
[0003] When developing the TRDP protocol in the Linux operating system, the TRDP protocol stack open source software is generally used. The TRDP project of the open source code project TCNOpen provides TRDP protocol stack software for TCN developers by developing TRDP standardized communication components, supporting WINDOWS, VXWORKS and Linux platforms, aiming to promote the development of corresponding products. The embedded Linux operating system is widely used in terminal equipment of train communication networks due to its open source characteristics. Although the TRDP protocol stack provides an application interface, it was found in actual engineering applications that it lacks support for Linux operating system development and does not support dual network ports. How to more conveniently integrate the TRDP protocol stack software in the Linux operating system is a major problem facing developers.
[0004] TCNOpen's open source TRDP protocol stack software is a general protocol software that is targeted at a wide range of operating systems. It lacks support for Linux operating system porting and personalized application support for dual-port applications. You need to read a lot of instructions and software source code before using it. Summary of the invention
[0005] According to the technical problems proposed above, a kind of TRDP protocol stack application method based on Linux is provided. The present invention is for Linux operating system platform, TRDP protocol stack is encapsulated into library, as an independent software module, provides API interface for user, by real car verification test, has friendliness, ease of use characteristics;Meanwhile, the method is applied in the hardware core board of design, as a general hardware and software platform, is provided to user. After using the scheme, user only needs to write configuration file and simply modify program and can use TRDP protocol stack software, reduce development threshold, improve programming efficiency, reduce errors caused by human factors, solve the problem of developing TRDP protocol stack and TRDP protocol stack dual network ports in Linux operating system application.
[0006] The technical means adopted by the present invention are as follows:
[0007] A TRDP protocol stack application method based on Linux, comprising:
[0008] S1. Design a general hardware platform based on Linux operating system and implement the TRDP protocol stack at the TRDP layer;
[0009] S2. For the TRDP layer, encapsulate the TRDP protocol stack into a library, provide an API interface for users, and implement the TRDP single network port and dual network port communication functions by calling configuration files.
[0010] Furthermore, in step S1, the designed general hardware platform includes:
[0011] The MCU chip provides two Ethernet communication interfaces, two CAN communication interfaces, a COMe interface, an RS232 interface, an RS485 interface, a USB interface, a PCIe interface, an SPI interface, and an I2C interface. The MCU chip provides an extended protocol interface through the FPGA.
[0012] Furthermore, in step S2, the API interface provided to the user includes: an Ethernet sending function and an Ethernet receiving function, wherein:
[0013] The Ethernet sending function is used to modify the data packet being sent. The prototype is int process_data(). The inside of () is TRDP_APP_SESSION_T appHandle, TRDP_PUB_TpubHandle, const UINT8*pData, UINT32 dataSize; wherein appHandle represents the handle returned by the tlc_openSession() function; pubHandle represents the publisher handle; *pData represents the content of the message being sent; dataSize represents the size of the message being sent; the Ethernet sending function returns 0 if executed correctly and a return value of less than 0 if it is wrong;
[0014] The Ethernet receiving function is used to receive data packets until the last packet of valid data is received. The prototype is poll_data(), and the contents of () are TRDP_APP_SESSION_T appHandle, TRDP_SUB_TsubHandle, TRDP_PD_INFO_T*pPdInfo, UINT8*pData, UINT32*pDataSize; wherein appHandle represents the handle returned by the tlc_openSession() function; subHandle represents the subscriber handle; *pPdInfo represents the message information of the receiving TRDP process data; *pData represents the content of the received message; *pDataSize represents the size of the received message; the Ethernet receiving function returns 0 if executed correctly and a value less than 0 if it is wrong.
[0015] Furthermore, in step S2, based on the Linux operating system, the TRDP protocol stack is encapsulated into a library, including:
[0016] The TRDP protocol stack is encapsulated to form a TRDP library file, which is oriented to the embedded Linux operating system. When using it, the user only needs to put the src folder into the software code project used and call it according to the DEMO method.
[0017] Furthermore, the src file includes the TRDP protocol stack library libtrdp.a file and three folders with .h files, namely api, common, and usr.
[0018] Furthermore, the TRDP protocol stack is encapsulated to form a TRDP library file, and the encapsulation method used specifically includes:
[0019] Perform initialization operations;
[0020] Read and parse configuration files;
[0021] Call the configuration parameters in the configuration file;
[0022] Start the TRDP protocol stack;
[0023] Parse Ethernet sending function;
[0024] Parse Ethernet receive function.
[0025] Further, in step S2, the configuration file is used for the application to configure the TRDP Ethernet communication source and sink ports and the single or dual network port application configuration; wherein the configuration items include location, source IP address, sink IP address, ComID, port type, data length, offset and characteristic period.
[0026] Furthermore, the configuration files include a cfg1.bin configuration file and a cfg2.bin configuration file, wherein:
[0027] The cfg1.bin configuration file is used for one of the Ethernet communication interfaces, and the cfg2.bin configuration file is used for the other Ethernet communication interface; when there is only one Ethernet communication interface, the cfg1.bin configuration file is called.
[0028] Compared with the prior art, the present invention has the following advantages:
[0029] 1. A Linux-based TRDP protocol stack application method provided by the present invention solves the problem that the TRDP general protocol software is not easy to transplant in the Linux operating system. Practice has proved that by using the scheme of the present invention, the TRDP development threshold is greatly reduced, programming efficiency is improved, and errors caused by human factors are reduced.
[0030] 2. The present invention provides a Linux-based TRDP protocol stack application method, which has the advantages of easy software transplantation and friendly user interface API functions.
[0031] 3. The TRDP protocol stack application method based on Linux provided by the present invention has the advantages of simple configuration and support for single / dual Ethernet port configuration expansion.
[0032] 4. The present invention provides a Linux-based TRDP protocol stack application method, which is tailored for an embedded Linux operating system and can be used by calling a library file.
[0033] Based on the above reasons, the present invention can be widely promoted in the fields of application of TRDP protocol stack. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0035] Figure 1 Flow chart of the method of the present invention.
[0036] Figure 2 Schematic diagram of the general hardware platform designed for the present invention.
[0037] Figure 3 The present invention is a flow chart of the TRDP protocol stack encapsulation method.
[0038] Figure 4The ECN network topology provided by the embodiment of the present invention.
[0039] Figure 5 This is the overall framework of the present invention. DETAILED DESCRIPTION
[0040] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0041] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0042] like Figure 1 As shown, the present invention provides a TRDP protocol stack application method based on Linux, comprising:
[0043] S1. Design a general hardware platform based on Linux operating system and implement the TRDP protocol stack at the TRDP layer;
[0044] S2. For the TRDP layer, encapsulate the TRDP protocol stack into a library (based on the Linux operating system), provide an API interface for users, and implement the TRDP single network port and dual network port communication functions by calling configuration files.
[0045] In specific implementation, as a preferred embodiment of the present invention, in step S1, a general hardware platform is designed, such as Figure 2 As shown, including:
[0046] The MCU chip provides two Ethernet communication interfaces, two CAN communication interfaces, a COMe interface, an RS232 interface, an RS485 interface, a USB interface, a PCIe interface, an SPI interface, and an I2C interface. The MCU chip provides an extended protocol interface through the FPGA. In this embodiment, the MVB / WTB communication protocol or other communication protocols are expanded.
[0047] In specific implementation, as a preferred embodiment of the present invention, in step S2, the API interface provided to the user includes: an Ethernet sending function and an Ethernet receiving function, wherein:
[0048] The Ethernet sending function is used to modify the data packet being sent. The prototype is int process_data(). The inside of () is TRDP_APP_SESSION_T appHandle, TRDP_PUB_TpubHandle, const UINT8*pData, UINT32 dataSize; wherein appHandle represents the handle returned by the tlc_openSession() function; pubHandle represents the publisher handle; *pData represents the content of the message being sent; dataSize represents the size of the message being sent; the Ethernet sending function returns 0 if executed correctly and a return value of less than 0 if it is wrong;
[0049] The Ethernet receiving function is used to receive data packets until the last packet of valid data is received. The prototype is poll_data(), and the contents of () are TRDP_APP_SESSION_T appHandle, TRDP_SUB_TsubHandle, TRDP_PD_INFO_T*pPdInfo, UINT8*pData, UINT32*pDataSize; wherein appHandle represents the handle returned by the tlc_openSession() function; subHandle represents the subscriber handle; *pPdInfo represents the message information of the receiving TRDP process data; *pData represents the content of the received message; *pDataSize represents the size of the received message; the Ethernet receiving function returns 0 if executed correctly and a value less than 0 if it is wrong.
[0050] In the specific implementation, as a preferred embodiment of the present invention, in step S2, the TRDP protocol stack is encapsulated into a library (based on the Linux operating system), including:
[0051] The TRDP protocol stack is encapsulated to form a TRDP library file, which is oriented to the embedded Linux operating system. When using it, the user only needs to put the src folder into the software code project used and call it according to the DEMO method.
[0052] In the specific implementation, as a preferred embodiment of the present invention, the src file includes the TRDP protocol stack library libtrdp.a file and three folders with .h files, namely api, common, and usr.
[0053] In specific implementation, as a preferred embodiment of the present invention, the TRDP protocol stack is encapsulated to form a TRDP library file, such as Figure 3 As shown, the packaging methods used specifically include:
[0054] Perform initialization operations;
[0055] Read and parse configuration files;
[0056] Call the configuration parameters in the configuration file;
[0057] Start the TRDP protocol stack;
[0058] Parse Ethernet sending function;
[0059] Parse Ethernet receive function.
[0060] During specific implementation, as a preferred embodiment of the present invention, in step S2, the configuration file is used for the application program to configure the TRDP Ethernet communication source and sink ports and the single network port or dual network port application configuration; wherein, the configuration items include location, source IP address, sink IP address, ComID, port type, data length, offset and characteristic period.
[0061] In specific implementation, as a preferred implementation of the present invention, the configuration files include a cfg1.bin configuration file and a cfg2.bin configuration file, wherein:
[0062] The cfg1.bin configuration file is used for one of the Ethernet communication interfaces, and the cfg2.bin configuration file is used for the other Ethernet communication interface; when there is only one Ethernet communication interface, the cfg1.bin configuration file is called. The configuration file description is shown in the following table.
[0063] Table 1 Configuration file description
[0064]
[0065] Example
[0066] A certain type of electric locomotive network control system TCMS supports train Ethernet, and the communication protocol is TRDP process data communication. Its ECN network topology is as follows Figure 4As shown. The central control unit CCU and the train reconnection gateway GW device are based on an embedded Linux operating system, wherein CCU is a dual-port Ethernet and GW is a single-port Ethernet. The scheme of the present invention uses the vehicle-mounted terminal CCU and GW as an example to illustrate that the TRDP protocol stack application method based on Linux is used, and developers are not required to invest energy and time in the in-depth study of the TRDP protocol, avoid duplication of work, and improve work efficiency. The application developers of CCU and GW only need to call the TRDP library file and make corresponding configurations to realize the application of the TRDP protocol stack.
[0067] The overall architecture of the TRDP protocol stack application method and device based on Linux is as follows Figure 5 As shown. By designing a general hardware platform ( Figure 5 Left), the Linux-based TRDP protocol stack is implemented in the TRDP layer. For the TRDP layer, the implementation mechanism is as follows Figure 5 Right, it is proposed to encapsulate the TRDP protocol stack into a library (based on the Linux operating system) to provide users with an API interface and a method for calling configuration files.
[0068] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0069] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0070] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0071] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A TRDP protocol stack application method based on Linux, characterized in that, include: S1. Design a general hardware platform based on Linux operating system , Implement the TRDP protocol stack at the TRDP layer; S2. For the TRDP layer, encapsulate the TRDP protocol stack into a library, provide an API interface for users, and implement the TRDP single network port and dual network port communication functions by calling configuration files.
2. A TRDP protocol stack application method based on Linux according to claim 1, characterized in that, In step S1, the general hardware platform designed includes: The MCU chip provides two Ethernet communication interfaces, two CAN communication interfaces, a COMe interface, an RS232 interface, an RS485 interface, a USB interface, a PCIe interface, an SPI interface, and an I2C interface. The MCU chip provides an extended protocol interface through the FPGA.
3. A TRDP protocol stack application method based on Linux according to claim 1, characterized in that, In step S2, the API interface provided to the user includes: an Ethernet sending function and an Ethernet receiving function, wherein: The Ethernet sending function is used to modify the data packet being sent. The prototype is int process_data(). The inside of () is TRDP_APP_SESSION_T appHandle, TRDP_PUB_TpubHandle, const UINT8*pData, UINT32dataSize; wherein appHandle represents the handle returned by the tlc_openSession() function; pubHandle represents the publisher handle; *pData represents the content of the message being sent; dataSize represents the size of the message being sent; the Ethernet sending function returns 0 if executed correctly and a return value of less than 0 if it is wrong; The Ethernet receiving function is used to receive data packets until the last packet of valid data is received. The prototype is poll_data(), and the contents of () are TRDP_APP_SESSION_T appHandle, TRDP_SUB_TsubHandle, TRDP_PD_INFO_T*pPdInfo, UINT8*pData, UINT32*pDataSize; wherein appHandle represents the handle returned by the tlc_openSession() function; subHandle represents the subscriber handle; *pPdInfo represents the message information of the receiving TRDP process data; *pData represents the content of the received message; *pDataSize represents the size of the received message; the Ethernet receiving function returns 0 if executed correctly and a value less than 0 if it is wrong.
4. A TRDP protocol stack application method based on Linux according to claim 1, characterized in that, In step S2, based on the Linux operating system, the TRDP protocol stack is encapsulated into a library, including: The TRDP protocol stack is encapsulated to form a TRDP library file, which is oriented to the embedded Linux operating system. When using it, the user only needs to put the src folder into the software code project used and call it according to the DEMO method.
5. A Linux-based TRDP protocol stack application method according to claim 4, characterized in that, The src file includes the TRDP protocol stack library libtrdp.a file and three folders with .h files: api, common, and usr.
6. A Linux-based TRDP protocol stack application method according to claim 4, characterized in that, The TRDP protocol stack is encapsulated to form a TRDP library file. The encapsulation method used specifically includes: Perform initialization operations; Read and parse configuration files; Call the configuration parameters in the configuration file; Start the TRDP protocol stack; Parse Ethernet sending function; Parse Ethernet receive function.
7. A TRDP protocol stack application method based on Linux according to claim 1, characterized in that, In step S2, the configuration file is used by the application to configure the TRDP Ethernet communication source and sink ports and the single or dual network port application configuration; wherein the configuration items include location, source IP address, sink IP address, ComID, port type, data length, offset and characteristic period.
8. A Linux-based TRDP protocol stack application method according to claim 7, characterized in that, The configuration files include the cfg1.bin configuration file and the cfg2.bin configuration file, wherein: The cfg1.bin configuration file is used for one of the Ethernet communication interfaces, and the cfg2.bin configuration file is used for the other Ethernet communication interface; when there is only one Ethernet communication interface, the cfg1.bin configuration file is called.