Configurable data packing method and system for vehicle-mounted information acquisition system
By using JSON format policy configuration files and remote update mechanism in the on-board information collection system, the problem of difficulty in changing data transmission protocols in the existing technology is solved, data transmission efficiency and maintenance convenience are improved, and flexible data transmission protocols are realized manage.
Patent Information
- Application Number
- CN202411550867.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2024-12-27
AI Technical Summary
When the data transmission protocol is changed, the existing vehicle information collection system needs to update the application, resulting in artificial design errors, low development efficiency, high maintenance costs, and complex data transmission protocols and difficult to maintain.
The policy configuration file in JSON format can realize the configurability of the data transmission protocol through the policy configuration file loading, data transmission policy analysis, data storage and remote update steps of the policy configuration file, allowing dynamic management of the data transmission protocol content, reducing the need for Application dependencies.
It improves data transmission efficiency, simplifies the upgrade and maintenance of data transmission functions, reduces maintenance difficulty and cost, and realizes the flexibility and efficient update of data transmission protocols.
Smart Images

Figure CN119211008A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a vehicle-mounted information transmission technology, in particular to a configurable data packaging method and system for a vehicle-mounted information acquisition system. Background Art
[0002] The vehicle information system (also known as the vehicle information system) is a device that enables the driver to timely understand the vehicle's operating status and external information through the vehicle's electronic equipment during driving. The vehicle information system consists of two parts: the vehicle information display system and the information communication system. The application running on the vehicle information collection system uses wireless communication technology and HTTP (Hypertext Transfer Protocol) or MQTT (Message Queuing Telemetry Transport) underlying protocols to transmit the vehicle's key information data to the cloud TSP (Telematics Service Provider, automotive remote service provider) platform. In the specific work process, as business needs change, the system needs to frequently change the content of the data transmission protocol.
[0003] The data transmission data type, attributes, storage location, strategy, etc. defined by the data transmission protocol are usually solidified in the program through coding. During the iterative development period or product maintenance period, it is often necessary to frequently change the data transmission requirements for the cloud-oriented TSP platform. In the prior art, the solidified representation method must be implemented by updating the application and performing batch upgrades, which is prone to introducing human design errors, low development efficiency, and high pressure on product maintenance costs and cycles; the prior art solution requires modifying the application to implement changes in the data transmission protocol content, and the update efficiency is low; the data transmission protocol is complex and difficult to maintain. Summary of the invention
[0004] The present invention aims to avoid the deficiencies in the above-mentioned prior art and to provide a configurable data packaging method and system for a vehicle-mounted information collection system, so as to improve data transmission efficiency and facilitate the upgrade of data transmission function.
[0005] The present invention adopts the following technical solutions to solve the technical problems.
[0006] A configurable data packaging method for a vehicle-mounted information collection system of the present invention comprises the following steps:
[0007] Step 1: loading the policy configuration file; the policy configuration file is a JSON (JavaScript Object Notation) file; the policy configuration file is initialized and serialized, and loaded into the memory of the vehicle information collection system;
[0008] Step 2: Data transmission strategy parsing step: parsing the strategy configuration file (i.e., the structure object obtained in step 1) in the memory of the vehicle information collection system according to the data identifier to obtain the data transmission packet grouping strategy;
[0009] Get the signal value data from the signal value storage buffer (for example: "bufIndex": 10, the real value of the charging status data in the previous program is a long array, stored at the position of the buffer index 10;), and package the signal value data according to the package strategy;
[0010] Step 3: Data storage step: storing the data transmission packet obtained after the packet assembly in step 2 into the specified data transmission storage area (buffer);
[0011] Step 4: remote update step of the policy configuration file; obtain the latest policy configuration file from the policy configuration file remote upgrade platform, replace the old policy configuration file in the vehicle information collection system, and implement the update of the policy configuration file.
[0012] The configurable data packaging method of the vehicle-mounted information collection system of the present invention is also characterized in that:
[0013] During specific implementation, in step 1, when initializing the policy configuration file, the JSON file is formatted into a structure object.
[0014] In the specific implementation, in step 2, the packaging strategy includes packaging module identification ID, packaging module name Zm, packaging module content Zn, signal list Zx, signal storage buffer Zc, signal value type Zl, signal value position Zw and signal value size Zz.
[0015] During specific implementation, in step 2, when the signal value data is packaged, the signal value is written into the memory according to the signal value type, signal value position and signal value size.
[0016] The present invention also discloses a system of the configurable data packaging method of the vehicle-mounted information collection system, including a policy configuration file loading module, a data transmission policy parsing module, a data storage module and a policy configuration file OTA (Over-the-Air Technology, air download technology) module;
[0017] The policy configuration file loading module is used to initialize and serialize the policy configuration file and load it into the memory of the vehicle information collection system;
[0018] The data transmission strategy parsing module is used to parse the strategy configuration file in the memory of the vehicle information collection system according to the data identifier to obtain the data transmission packet grouping strategy; obtain the signal value data from the signal value storage buffer, and group the signal value data according to the grouping strategy;
[0019] The data storage module is used to store the data transmission packets obtained after packet assembly into a designated data transmission storage area;
[0020] The policy configuration file OTA module is used to obtain the latest policy configuration file from the policy configuration file remote upgrade platform, replace the old policy configuration file in the vehicle information collection system, and implement the update of the policy configuration file.
[0021] In specific implementation, the policy configuration file loading module includes an object initialization module and an object serialization module.
[0022] The present invention also discloses an electronic device, comprising at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the configurable data packaging method of the vehicle-mounted information acquisition system.
[0023] The present invention also discloses a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the configurable data packaging method for the vehicle-mounted information collection system.
[0024] The present invention also discloses a computer program product, including a computer program; the characteristic of the computer program is that when the computer program is executed by a processor, the computer program realizes the configurable data packaging method of the vehicle-mounted information collection system.
[0025] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0026] The present invention discloses a configurable data packaging method and system for an on-board information collection system, comprising a policy configuration file loading step; the policy configuration file is a JSON file; the policy configuration file is initialized and serialized; a data transmission strategy parsing step; obtaining a data transmission packaging strategy; obtaining signal value data from a signal value storage buffer, and packaging the signal value data according to the packaging strategy; a data storage step; storing the data transmission package obtained after packaging in a designated data sending storage area; a remote updating step of the policy configuration file; obtaining the latest policy configuration file from a policy configuration file remote upgrade platform to replace the old policy configuration file in the on-board information collection system, thereby updating the policy configuration file.
[0027] The configurable data packaging method and system of the vehicle-mounted information collection system of the present invention have the advantages of being able to improve data transmission efficiency, facilitate the upgrade of data transmission functions, and make maintenance more intuitive and convenient. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 The present invention is a flow chart of a configurable data packaging method for a vehicle-mounted information collection system.
[0029] Figure 2 It is a schematic diagram of the working process of data packaging of the present invention.
[0030] The present invention will be further described below through specific implementation modes in conjunction with the accompanying drawings. DETAILED DESCRIPTION
[0031] See also Figure 1-2 A configurable data packaging method for a vehicle-mounted information collection system of the present invention comprises the following steps:
[0032] Step 1: loading the policy configuration file; the policy configuration file is a JSON (JavaScript Object Notation) file; the policy configuration file is initialized and serialized, and loaded into the memory of the vehicle information collection system;
[0033] The initialization process loads the file in JSON format into the memory through the system structure; the serialization process forms a structured array in the format of key:value for the entire block of data in the memory to facilitate retrieval by the program; in the step 1, after loading the policy configuration file in JSON format, the policy configuration file is parsed, the text content is formatted into a structure object that can be recognized by the vehicle information collection system, and the structure object is saved to the memory of the vehicle information collection system to facilitate the data transmission policy parsing module to read these structure objects. In one embodiment, the structure object includes "name: reported data name description", "cmdId: reported data command word" and other contents. The structure objects in the computer program are listed in the program as follows. Figure 2 It is a schematic diagram of the package assembly process in the program.
[0034] name: description of the reported data name;
[0035] cmdId: Report data command word;
[0036] infoList: data structure object array;
[0037]
[0038] The information reported by new energy vehicles includes charging status, battery pack information, CP duty cycle, PCU status and other data. The data structure reported by different models will vary greatly, especially the battery pack information. New energy vehicles usually have 1-2 battery packs, and 1 battery pack usually contains 1-200 single cells. The voltage of each single cell needs to be packaged and reported. The number of single cells in different models is different, the model iteration speed is fast, and the single cell voltage package reporting structure changes frequently. Through the configurable data packaging method of the vehicle information acquisition system of the present invention, the needs of different models can be quickly iterated.
[0039] The policy configuration file in step 1 is usually in JSON format.
[0040] For example, the specific content of the JSON format file of the power battery cell voltage strategy configuration file is as follows:
[0041]
[0042]
[0043] The “total number of power battery cells” in the strategy configuration file is defined as: the total number of power battery cells of this vehicle model; the “cell voltage value set” is defined as: the set of all voltage values of the power battery cells of this vehicle model.
[0044] In step 1, the content of the policy configuration file is loaded into the system memory to form memory image data similar to the following format, and the data type is as follows:
[0045]
[0046] The data content is as follows:
[0047] / / Power battery cell total number object
[0048] Json.Object[0].name = "Total number of power battery cells";
[0049] Json.Object[0].bufIndex=58;
[0050] Json.Object[0].data=-1;
[0051] Json.Object[0].type="byte";
[0052] Json.Object[0].startPos=0;
[0053] Json.Object[0].length=8;
[0054] / / Single battery voltage value object collection
[0055] Json.Object[n].name = "Single battery voltage value";
[0056] Json.Object[n].bufIndex=0;
[0057] Json.Object[n].data=0;
[0058] Json.Object[n].type="word";
[0059] Json.Object[n].startPos=0;
[0060] Json.Object[n].length=16;
[0061] like Figure 1 In the embodiment, the function of the data packaging module is to package the data into a data stream in a specified format according to the definition of the structure object. In the computer program of this embodiment, the data stream after packaging is:
[0062] 232302fe890101a02208300034323431303030303901037117070610162001020001fffe0000e3d8fffefffe2afe0ffffefe99020101fefefffefffefefffefffe050006fd46bf01e4523d060101fffe0101fffe0101fe0101fe07000000000000000000080101000000000078000178fffefffefffefffefffefffefffefffefffefffef ffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffefffe0901010008fe fefefefefefefe80021938393831545454545454545408003200000000000500000000000000000000000000000000000000000000000000000000fefefefefefefefefefefefefefefefe000c010a948000010011 05569afe000f0000000000000000ffffffffffffff003500fe00fefffefffe0000fffe0000fffefefffe000000000000000000fefffe00000000fe0000fefffffffffe00fefe00fe00fffe00270000000038393930303030303030303030303030303030300b313331303030303030 3030170000000e01fefffe01fefffe01fefe01fefe0018fefefefefefefeffeffeffeffeffeffeffeffe0000000000000000012d0d01002800fe00000000000000fefe000 000000000fffefeffefffefefefefefefefeffeffefffefefe020005fffe00000003000300000010002c000 00000000000000000fefffefefffe00fefefefefffefefefeffeffeffeffefefefefeffeffeffeffeffefef e110034000000000000000000000000000000000000000000000000000000000000ffffeffe00000000000 d0d1d2d300d5d6d7d8fe000000300003000000320013000000000000000000000000000000000000000330 00c0000000000000000000000003400040064646450001d00000000000000fe0000000000000000000000 000000000000fefe00fe6000180000000000000000fefefefefefefefe000000000000000081000cfe0000000000fefefffefefe82000e0000fffe0000fffefefefefffefe56.
[0063] Which data is placed at each position in the data stream is determined by the policy defined in the structure object obtained after parsing the policy configuration file.
[0064] Step 2: Data transmission strategy parsing step: parsing the strategy configuration file (i.e., the structure object obtained in step 1) in the memory of the vehicle information collection system according to the data identifier to obtain the data transmission packet grouping strategy;
[0065] During the parsing of the policy configuration file (i.e., the structure object obtained in step 1), the data area contents are read from the structure object in sequence, and the data corresponding to the bufIndex data buffer address subscript is filled into the data stream according to the starting position, length, type and other information of the data defined in the data area in the protocol.
[0066] In step 2, the system parses the memory image data of the configuration information and obtains the following:
[0067] The total number of power battery cells of this model is obtained from the buffer address 58. This location data is obtained by the system from the vehicle bus. The obtained value varies depending on the model. Commonly obtained values include: 120, 136, 200, etc.
[0068] By obtaining the total number of battery cells, such as 120, the system automatically creates 120 single-cell battery voltage value objects for storing the single-cell voltage values obtained by the system from the vehicle bus.
[0069] For example:
[0070] {
[0071] "name":"Charging status",
[0072] "bufIndex":10,
[0073] "data":0,
[0074] "type":1,
[0075] "startPos":0,
[0076] "length":8
[0077] }
[0078] This program is a packetization strategy for data transmission, in which the various information of the charging status data in the data stream is as follows: the storage location is 10, the default value of the data is 0, the data type is 1 (byte), the storage start position is 0 (subscript of the object array + 0), and the length is 8 (8 bits);
[0079] Get the signal value data from the signal value storage buffer (for example: "bufIndex": 10, the real value of the charging status data in the previous program is a long array, stored at the position of the buffer index 10;), and package the signal value data according to the package strategy;
[0080] In the process of packaging the signal value data in the above program, the charging status data is finally stored in the following data stream (which is part of the data stream above):
[0081] 232302fe890101a022083000343234313030303039010371170706101620 protocol header fixed value
[0082] 01Vehicle data identifier
[0083] 02Vehicle status (in operation)
[0084] 0001 Charging status (vehicle charging), the charging status is placed in this position according to the strategy defined in the structure object. ......
[0086] Step 3: Data storage step: storing the data transmission packet obtained after the packet assembly in step 2 into the designated data transmission storage area (buffer);
[0087] In step 3, the system assigns values and packages the objects parsed in step 2, as shown below:
[0088] / / Power battery cell voltage assignment
[0089] Json.Object[n].data=CANDataBuffer[Json.Object[n].bufIndex+n];
[0090] After cyclically assigning all monomer voltage values, the system packages the monomer voltage values. The packaged data is as follows:
[0091] / / Write the single cell voltage value into the memory according to its type and length to complete the package assembly.
[0092] ButteryBuf[0].memcpy(Json.Object[n].data,Json.Object[n].length,Json.Object[n].type);
[0093] The final memory data is as follows:
[0094] 0x01 0x34 0x01 0x37 0x01 0x32......
[0095] Among them, 0x01 0x34 represents the voltage of battery 1, 0x01 0x37 represents the voltage of battery 2, and so on, a total of 120 battery cell voltage values.
[0096] Step 4: remote update step of the policy configuration file; obtain the latest policy configuration file from the policy configuration file remote upgrade platform, replace the old policy configuration file in the vehicle information collection system, and implement the update of the policy configuration file.
[0097] Step 4: The vehicle manufacturer can use the FOTA platform to send the policy configuration file to the vehicle terminal by remote upgrade. After the system replaces the policy configuration file, the content of the vehicle power battery cell voltage data reporting can be adjusted, for example:
[0098] The type of the single cell voltage value of the new model is changed from word to dword. We only need to modify the policy configuration file in the cloud as follows:
[0099]
[0100] When the new policy configuration file is sent to the system, a new package strategy is also generated. When packaging, the voltage of a single battery will automatically change from occupying 2 bytes to occupying 4 bytes, as shown below:
[0101] Single cell voltage assignment:
[0102] ButteryBuf[0].memcpy(Json.Object[n].data,Json.Object[n].length,Json.Object[n].type);
[0103] The final memory data is as follows:
[0104] 0x00 0x01 0x01 0x34 0x00 0x01 0x01 0x37 0x00 0x01 0x01 0x32......
[0105] Among them, x00 0x01 0x01 0x34 represents the voltage of battery 1, x00 0x01 0x01 0x37 represents the voltage of battery 2... and so on, a total of 120 battery cell voltage values.
[0106] As mentioned above, the configurable data packaging solution completes the data packaging solution of the vehicle's power battery cell voltage through the strategy configuration file adjustment and remote upgrade functions.
[0107] The present invention provides a configurable data packaging method for an on-board information collection system, including a strategy configuration file loading step, a data transmission strategy parsing step, a data storage step, and a remote update step for the strategy configuration file; the strategy configuration file in JSON format is used to define the data transmission protocol content and the transmission strategy, mainly including the source of the data to be transmitted, the data storage location, the data length, the calibration scheme, the default value, and other information. The application serializes the JSON file to the system memory to form a transmission protocol object, and obtains the data transmission protocol strategy by parsing the transmission protocol object.
[0108] In the present invention, the application parses the data that needs to be transmitted to the cloud TSP platform. The strategy completely comes from the definition in the JSON file. The user can clearly read the parsing strategy through the JSON file, making maintenance more intuitive and convenient. When the data transmission strategy needs to be upgraded and updated, the system allows the JSON file to be directly replaced to achieve the change of the data transmission strategy, so as to upgrade the data transmission function more efficiently and stably. The application serializes the JSON file into a memory MAP object, which facilitates the program's acquisition of the data transmission strategy and improves the efficiency of data transmission. A configurable data packaging method for a vehicle-mounted information acquisition system of the present invention adopts a policy configuration file in json format, which can dynamically manage the content of the data transmission protocol, has a clear format, low maintenance difficulty, and high update efficiency.
[0109] During specific implementation, in step 1, when initializing the policy configuration file, the JSON file is formatted into a structure object.
[0110] JSON (JavaScript Object Notation) is a lightweight data exchange format. It is based on a subset of ECMAScript (European Computer Manufacturers Association, JS specification developed by the European Computer Association) and uses a text format that is completely independent of the programming language to store and represent data. The concise and clear hierarchical structure makes JSON an ideal data exchange language. It is easy for people to read and write, and it is also easy for machines to parse and generate, and it effectively improves network transmission efficiency. JSON files are text files. During initialization, the text content is parsed and formatted into a structure object that can be recognized by the vehicle information collection system. It is stored in the memory of the vehicle information collection system for use by the data transmission strategy parsing module.
[0111] In the specific implementation, in step 2, the packaging strategy includes packaging module identification ID, packaging module name Zm, packaging module content Zn, signal list Zx, signal storage buffer Zc, signal value type Zl, signal value position Zw and signal value size Zz.
[0112] The computer program of the above embodiment, part of the code of the package strategy process is as follows:
[0113]
[0114]
[0115] During specific implementation, in step 2, when the signal value data is packaged, the signal value is written into the memory according to the signal value type, signal value position and signal value size.
[0116] The present invention also discloses a system of the configurable data packaging method of the vehicle-mounted information collection system, including a policy configuration file loading module, a data transmission policy parsing module, a data storage module and a policy configuration file OTA (Over-the-Air Technology, air download technology) module;
[0117] The policy configuration file loading module is used to initialize and serialize the policy configuration file and load it into the memory of the vehicle information collection system;
[0118] The data transmission strategy parsing module is used to parse the strategy configuration file in the memory of the vehicle information collection system according to the data identifier to obtain the data transmission packet grouping strategy; obtain the signal value data from the signal value storage buffer, and group the signal value data according to the grouping strategy;
[0119] The data transmission policy parsing module obtains the corresponding policy from the data transmission policy object according to the data identifier, so as to switch the data transmission protocol mode in a configurable manner.
[0120] The data storage module is used to store the data transmission packets obtained after packet assembly into a designated data transmission storage area;
[0121] Following the definition of the data transmission strategy, the data is stored in the specified buffer. According to the results of the strategy analysis module, when the data is packaged, the signal value is read from the signal buffer, and according to the provisions of the signal value type, signal value position, and signal value size, the signal value is written into the memory for sending.
[0122] The policy configuration file OTA module is used to obtain the latest policy configuration file from the policy configuration file remote upgrade platform, replace the old policy configuration file in the vehicle information collection system, and implement the update of the policy configuration file.
[0123] The policy configuration file OTA module uses the remote upgrade function to obtain the updated policy configuration file in JSON format from the cloud, and upgrade the data transmission protocol content and policy without modifying the application.
[0124] In specific implementation, the policy configuration file loading module includes an object initialization module and an object serialization module.
[0125] The policy configuration file is serialized and loaded into the system memory through the object initialization Initinitialize module and the object serialization Serializable module.
[0126] The present invention also discloses an electronic device, comprising at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the configurable data packaging method of the vehicle-mounted information acquisition system.
[0127] The present invention also discloses a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the configurable data packaging method for the vehicle-mounted information collection system.
[0128] The present invention also discloses a computer program product, including a computer program; the characteristic of the computer program is that when the computer program is executed by a processor, the computer program realizes the configurable data packaging method of the vehicle-mounted information collection system.
[0129] The working process of the configurable data package of the vehicle information collection system of the present invention is as follows: Figure 2 As shown, one of the implementation codes is as follows.
[0130] / **
[0131] *@brief: Package operation based on real-time data signals defined in json file
[0132] *json=>bufIndex is the signal value buffer index. When bufIndex=-1, it indicates that the signal is not obtained by CAN. The system uses json=>data by default to describe the value of the signal.
[0133] *
[0134] *@paramu8EventId[in] Event ID
[0135] *@return0 = success, otherwise return error code
[0136] * /
[0137] intRI_PkgRealinfoSig(u8u8EventId)
[0138] {
[0139] / *Get the protocol group package policy object* /
[0140] ptProtPacks=cJSON_GetObjectItem(g_ptMainJson,JSON_KEY_PROT_PACKS);
[0141] if (ptProtPacks == NULL)
[0142] {
[0143] / *Object acquisition failed, error code returned, unable to package and report data. * /
[0144] log_i("[%s]JSONProtocolPackegs[%s]ObjectIsNull.",MODULE,JSON_KEY_PROT_PACKS);
[0145] returnERR_JSON_PARSE;
[0146] }
[0147] / *Get real-time data package strategy* /
[0148] ptRealInfo=cJSON_GetObjectItem(ptProtPacks,JSON_KEY_REAL_INFO);
[0149] if (ptRealInfo == NULL)
[0150] {
[0151] / *Object acquisition failed, error code returned, unable to package and report data* /
[0152] log_i("[%s]JSONRealinfoPackegs[%s]ObjectIsNull.",MODULE,JSON_KEY_REAL_INFO);
[0153] returnERR_JSON_PARSE;
[0154] }
[0155] / *Get data information list* /
[0156] ptInfoList=cJSON_GetObjectItem(ptRealInfo,JSON_KEY_INFO_LIST);
[0157] if (ptInfoList == NULL)
[0158] {
[0159] / *Object acquisition failed, error code returned, unable to package and report data* /
[0160] log_i("[%s]JSONPackegInfoList[%s]ObjectIsNull.",MODULE,JSON_KEY_REAL_INFO);
[0161] returnERR_JSON_PARSE;
[0162] }
[0163] / *Get the total number of modules with real-time signals* /
[0164] u8InfoListSum=cJSON_GetArraySize(ptInfoList);
[0165] / **
[0166] *@brief Real-time signal packaging process
[0167] *
[0168] *u8InfoListSum total number of periodic signal modules. TBOX working modes are divided into the following two types:
[0169] *National standard mode: (total number of periodic signal modules - 1), using this as the package assembly condition, a reporting data package that meets the national standard requirements can be formed.
[0170] *JAC mode: (total number of periodic signal modules), including custom data.
[0171] * /
[0172] / *Judge whether the current TBOX working mode is the national standard mode* /
[0173] if(param_Get_SysModeGb())
[0174] {
[0175] / *Remove custom data from the signal group package* /
[0176] u8InfoListSum -= 1;
[0177] }
[0178] / *
[0179] Enter the real-time data signal information list and cycle
[0180] Loop through the basic properties of each module and the signal list under the module
[0181] * /
[0182] for(s_iLoop=0;s_iLoop <u8InfoListSum;s_iLoop++)
[0183] {
[0184] / *Parsing real-time data information module* /
[0185] ptInfo=cJSON_GetArrayItem(ptInfoList,s_iLoop);
[0186] / *Message ID* /
[0187] ptInfoType=cJSON_GetObjectItem(ptInfo,JSON_KEY_INFO_TYPE);
[0188] if(NULL == ptInfoType)
[0189] {
[0190] log_i("[%s]JSONInfoType[%s]ObjectIsNull.",MODULE,JSON_KEY_INFO_TYPE); u8PerInfoId=0;
[0191] }
[0192] else
[0193] {
[0194] u8PerInfoId=cJSON_GetNumberValue(ptInfoType);
[0195] / *Write information ID* /
[0196] u32Cursor=RI_InsU8Value(u32Cursor,u8PerInfoId);
[0197] }
[0198] / *Get the signal list under the information object* /
[0199] ptSigList=cJSON_GetObjectItem(ptInfo,JSON_KEY_SIG_LIST);
[0200] if(NULL == ptSigList)
[0201] {
[0202] / *If there is no signal list, set the number of signals to 0 and skip this signal group* /
[0203] u16SignalSum=0;
[0204] }
[0205] else
[0206] {
[0207] u16SignalSum=cJSON_GetArraySize(ptSigList);
[0208] }
[0209] / *Loop signal list* /
[0210] for(s_jLoop=0;s_jLoop <u16SignalSum;s_jLoop++)
[0211] {
[0212] / *Get the signal object* /
[0213] ptSignal=cJSON_GetArrayItem(ptSigList,s_jLoop);
[0214] / *Judging whether the data needs to be packaged in variable length based on u8InfoId* /
[0215] if(bInfoVariable == true)
[0216] {
[0217] / *Skip all data exceeding the maximum length* /
[0218] if((u32LenData>0)&&(s_jLoop>=(u32LenData+u8Offset)))
[0219] {
[0220] / *log_d("[%s] Skip the redundant data exceeding the maximum length, InfoId: %d, Index: %d", MODULE, u8PerInfoId, s_jLoop);* /
[0221] continue;
[0222] }
[0223] else
[0224] {
[0225] / *If the parsed variable-length data is within the maximum length, continue with the next data parsing process* /
[0226] }
[0227] }
[0228] else
[0229] {
[0230] / * Non-variable length packet data * /
[0231] }
[0232] / *Get the data type of the signal* /
[0233] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_TYPE))
[0234] {
[0235] / *If the signal data type is not defined, the default is BYTE* /
[0236] u8SignalType=VALUE_TYPE_BYTE;
[0237] }
[0238] else
[0239] {
[0240] u8SignalType=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGN AL_TYPE));
[0241] }
[0242] / / log_d("Currently writing data [%s] into the data packet, data extraction address: %f",cJSON_GetStringValue(cJSON_GetObjectItem(ptSignal,"name")),cJSON_GetNumberVal ue(cJSON_GetObjectItem(ptSignal,"bufIndex")));
[0243] / *Signal data type must be within the specified range* /
[0244] if((VALUE_TYPE_BIT<=u8SignalType)&&(u8SignalType<=VALUE_TYPE_SERIAL))
[0245] {
[0246] / *1. String signal value - this type of data does not exist in the current protocol* /
[0247] if(VALUE_TYPE_STR1==u8SignalType)
[0248] {
[0249] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_BUF_INDEX))
[0250] {
[0251] / *If the buffer index of string data is not set, write the json predefined value* /
[0252] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_DATA))
[0253] {
[0254] / *If json has no predefined value, write an empty string* /
[0255] u32Cursor=RI_InsStr(u32Cursor,"");
[0256] }
[0257] else
[0258] {
[0259] u32Cursor=RI_InsStr(u32Cursor,cJSON_GetStringValue(cJSON_GetObjectItem(ptSignal,JSO N_KEY_SIGNAL_DATA)));
[0260] }
[0261] }
[0262] else
[0263] {
[0264] if(cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_BUF_INDEX))===-1)
[0265] {
[0266] / *Signal value is not obtained by CAN, json is predefined. * /
[0267] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_DATA))
[0268] {
[0269] / *If json has no predefined value, write an empty string* /
[0270] u32Cursor=RI_InsStr(u32Cursor,"");
[0271] }
[0272] else
[0273] {
[0274] u32Cursor=RI_InsStr(u32Cursor,cJSON_GetStringValue(cJSON_GetObjectItem(ptSignal,JSO N_KEY_SIGNAL_DATA)));
[0275] }
[0276] }
[0277] else
[0278] {
[0279] / *Signal value is obtained by CAN* /
[0280] / *TODO* /
[0281] }
[0282] }
[0283] }
[0284] / *2. Integer signal value byteworddword is processed uniformly* /
[0285] elseif((VALUE_TYPE_BIT <u8SignalType)&&(u8SignalType<=VALUE_TYPE_DWORD))
[0286] {
[0287] / ******Temporary variables used for CAN signal data acquisition and calibration****** /
[0288] / *CAN message data* /
[0289] u32u32CANData = 0x0;
[0290] / *CAN signal data after offset calibration. Because of the concern that the data may be biased after precision conversion, the calibrated data is saved in double type first* /
[0291] doubledCANData = 0x0;
[0292] / ** /
[0293] cJSON*ptAgainst=NULL;
[0294] / *Signal accuracy* /
[0295] doubledResolution = 0;
[0296] / *Signal offset* /
[0297] s32sOffset = 0;
[0298] / *Invert the flag* /
[0299] u8u8against=0;
[0300] / *Whether the signal needs calibration, by default true needs calibration, false does not need calibration* /
[0301] bool bCal = true;
[0302] / *Gear information string in binary format* /
[0303] / / charcGear[9]={0};
[0304] / ***************************************** /
[0305] / *Read the buffer array index* /
[0306] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_BUF_INDEX))
[0307] {
[0308] / *If there is no cache index, the value is obtained from the json file by default* /
[0309] s16BufIndex = -1;
[0310] }
[0311] else
[0312] {
[0313] s16BufIndex=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_BUF_INDEX));
[0314] }
[0315] / *json file fixed signal value* /
[0316] if(s16BufIndex == -1)
[0317] {
[0318] / *Signal value is not obtained by CAN, json is predefined* /
[0319] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_DATA))
[0320] {
[0321] / *If no fixed value is defined in json, the default value is 0* /
[0322] u32CANData = 0;
[0323] }
[0324] else
[0325] {
[0326] u32CANData=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGN AL_DATA));
[0327] }
[0328] }
[0329] else
[0330] {
[0331] / *Signal value is obtained by CAN* /
[0332] RI_ReadCANMsg(s16BufIndex,&u32CANData);
[0333] / *Integer data needs to be offset and adjusted for precision* /
[0334] / *First save the acquired signal value to the double type calibration data buffer* /
[0335] dCANData = u32CANData;
[0336] / *According to the length of the integer data, first determine the default value without adjusting the precision and offset* /
[0337] switch(u8SignalType)
[0338] {
[0339] caseVALUE_TYPE_BYTE:
[0340] {
[0341] if((u32CANData==DEFAULT_INVALID_BYTE)||(u32CANData==DEFAULT_FAULT_BYTE))
[0342] {
[0343] bCal = false;
[0344] }
[0345] }
[0346] break;
[0347] caseVALUE_TYPE_WORD:
[0348] {
[0349] if((u32CANData==DEFAULT_INVALID_WORD)||(u32CANData==DEFAULT_FAULT_WORD))
[0350] {
[0351] bCal = false;
[0352] }
[0353] }
[0354] break;
[0355] caseVALUE_TYPE_DWORD:
[0356] {
[0357] if((u32CANData==DEFAULT_INVALID_DWORD)||(u32CANData==DEFAULT_FAULT_DWORD))
[0358] {
[0359] bCal = false;
[0360] }
[0361] }
[0362] break;
[0363] default:
[0364] break;
[0365] }
[0366] / *The reported data is non-default value* /
[0367] if(true == bCal)
[0368] {
[0369] / *Integer data may need to be offset and adjusted in precision* /
[0370] if(NULL!=cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_RESOLUTION))
[0371] {
[0372] dResolution=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_RESOLUTION));
[0373] / / log_d("SignalResolution%f",dResolution);
[0374] / *Adjust accuracy* /
[0375] dCANData=dCANData*dResolution;
[0376] }
[0377] if(NULL!=cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_OFFSET))
[0378] {
[0379] sOffset=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_OFFSET));
[0380] / *log_d("Signaloffset%d",sOffset);* /
[0381] / *Adjust offset* /
[0382] dCANData=dCANData+sOffset;
[0383] }
[0384] }
[0385] / * After calibration, the u32 type signal data is transmitted back and waits to be written into the packet buffer* / u32CANData = dCANData;
[0386] }
[0387] / *Write to the packet buffer according to the signal type* /
[0388] switch(u8SignalType)
[0389] {
[0390] caseVALUE_TYPE_BYTE:
[0391] u32Cursor=RI_InsU8Value(u32Cursor,u32CANData);
[0392] break;
[0393] caseVALUE_TYPE_WORD:
[0394] u32Cursor=RI_InsU16Value(u32Cursor,u32CANData);
[0395] break;
[0396] caseVALUE_TYPE_DWORD:
[0397] u32Cursor=RI_InsU32Value(u32Cursor,u32CANData);
[0398] break;
[0399] default:
[0400] break;
[0401] }
[0402] }
[0403] / *3.bit signal value processing* /
[0404] elseif(VALUE_TYPE_BIT==u8SignalType)
[0405] {
[0406] / *Gather a byte and insert it into the send buffer* /
[0407] / *Data start bit* /
[0408] u8u8StartPos=0;
[0409] / *Data length (bits)* /
[0410] u8u8DataLen=0;
[0411] / *Signal offset* /
[0412] s32sOffset = 0;
[0413] / *Invert the flag* /
[0414] u8u8against=0;
[0415] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_BUF_INDEX))
[0416] {
[0417] / *If there is no buffer index object, the default is -1* /
[0418] s16BufIndex = -1;
[0419] }
[0420] else
[0421] {
[0422] s16BufIndex=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_BUF_INDEX));
[0423] }
[0424] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_STARTPOS))
[0425] {
[0426] / *If there is no signal starting position, fill in 8 by default and enter error processing* /
[0427] u8StartPos = 8;
[0428] }
[0429] else
[0430] {
[0431] u8StartPos=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_STARTPOS));
[0432] }
[0433] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_LENGTH))
[0434] {
[0435] / *If there is no signal length, fill in 0 by default* /
[0436] u8DataLen = 0;
[0437] }
[0438] else
[0439] {
[0440] u8DataLen=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_LENGTH));
[0441] }
[0442] / *Group bit type reporting data. Usually, the bit type data defined in the json file should be continuous and merged into a whole byte* /
[0443] if((u8StartPos<0)||(u8StartPos>7)||(u8DataLen>8)||((u8StartPos+u8DataLen)>8))
[0444] {
[0445] / *Some operation parameters are invalid
[0446] Invalid starting position for bitwise operation
[0447] Invalid data length by bit operation
[0448] Bit operation starting position + length is greater than one byte
[0449] * /
[0450] log_i("[%s]Periodsignalpackegtacticserror,pleasecheckthejsonfilewithkey=%s",MODULE,cJS ON_GetStringValue(cJSON_GetObjectItem(ptSignal,"name")));
[0451] }
[0452] else
[0453] {
[0454] / *Data packetized bit by bit, no more than one byte* /
[0455] u8u8CANData=0;
[0456] u32u32CANData = 0;
[0457] cJSON*ptAgainst=NULL;
[0458] / *Get the value of the data* /
[0459] if(-1 == s16BufIndex)
[0460] {
[0461] / *Reserved position, take out the default value* /
[0462] if(NULL==cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_DATA))
[0463] {
[0464] / *If there is no default value defined in json, fill in 0* /
[0465] u8CANData = 0;
[0466] }
[0467] else
[0468] {
[0469] u8CANData=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNA L_DATA));
[0470] }
[0471] / *Move the signal value to the specified position according to the starting position* /
[0472] u8BitData=u8BitData|(u8CANData< <u8StartPos);
[0473] }
[0474] else
[0475] {
[0476] / *Read the signal value from the buffer* /
[0477] RI_ReadCANMsg(s16BufIndex,&u32CANData);
[0478] / *This type of data is less than one byte, so you only need to extract the value of one byte* /
[0479] u8CANData = u32CANData;
[0480] / *Offset* /
[0481] if(NULL!=cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_OFFSET))
[0482] {
[0483] sOffset=cJSON_GetNumberValue(cJSON_GetObjectItem(ptSignal,JSON_KEY_SIGNAL_OFFSET));
[0484] / *log_d("Signaloffset%d",sOffset);* /
[0485] / *Adjust offset* /
[0486] u8CANData=u8CANData+sOffset;
[0487] }
[0488] / *log_d("bitdata:%d,candata:%d,startpos:%d",u8BitData,u8CANData,u8StartPos);* / / *Move the signal value to the specified position according to the start bit* /
[0489] u8BitData=u8BitData|(u8CANData< <u8StartPos);
[0490] / *log_d("bitdata:%d",u8BitData);* /
[0491] }
[0492] if(BYTE_LENGTH_BIT==(u8StartPos+u8DataLen))
[0493] {
[0494] / *Calculate to the last bit, at this time you can use the single-point periodic byte type data operation* / u32Cursor = RI_InsU8Value (u32Cursor, u8BitData);
[0495] / *Clean up the scene* /
[0496] u8BitData = 0;
[0497] }
[0498] else
[0499] {
[0500] / *The last bit is not calculated, continue to parse the next bit of data* /
[0501] }
[0502] }
[0503] }
[0504] / *4. Time type signal value processing* /
[0505] elseif(VALUE_TYPE_TIME==u8SignalType)
[0506] {
[0507] / *X041 does not have a time type signal that needs to be packaged* /
[0508] }
[0509] / *5. Serial number type signal value processing* /
[0510] elseif(VALUE_TYPE_SERIAL==u8SignalType)
[0511] {
[0512] / *Serial number data 4 bytes* /
[0513] u8m_u8Serial[4] = {0};
[0514] / *Get the serial number* /
[0515] get_u32_rand(m_u8Serial,4);
[0516] / *Write serial number* /
[0517] u32Cursor=RI_InsSerial(u32Cursor,m_u8Serial);
[0518] }
[0519] else
[0520] {
[0521] / *Other types of signal values are not processed and are not added to the sending buffer* /
[0522] }
[0523] }
[0524] else
[0525] {
[0526] / *If the data type is not within the specified range, do not package the data and continue to the next signal* /
[0527] if(NULL==cJSON_GetObjectItem(ptSignal,"name"))
[0528] {
[0529] log_i("[%s]SignalTypeInvolid,CheckJSONFileByObject%s",MODULE,"NameObjectIsNull.");
[0530] }
[0531] else
[0532] {
[0533] log_i("[%s]SignalTypeInvolid,CheckJSONFileByObject%s",MODULE,cJSON_GetStringValue(cJSON_GetObjectItem(ptSignal,"name")));
[0534] }
[0535] }
[0536] }
[0537] }
[0538] return 0;
[0539] }
[0540] The configurable data packaging method and system of the vehicle-mounted information collection system of the present invention have the following characteristics:
[0541] (1) Use the json file as the policy configuration file of the data transmission policy;
[0542] (2) It realizes the configurability of data transmission strategy independent of application programs;
[0543] (3) Enable visual editing of data transmission strategies;
[0544] (4) The data transmission strategy can be upgraded remotely and independently.
[0545] The present invention provides a configurable data packaging method and system for an on-board information collection system, which realizes the configurable function of the data transmission protocol solution, enables the data transmission function to have the function of remote upgrade and update, and improves the performance and stability of the overall system in terms of data transmission stability, efficient upgrade, and visual editing. After the present invention has the configurable function of the data transmission protocol, the system can adapt more quickly to the transmission protocols required by different cloud platforms. The visual editing function can make the data transmission protocol editing easier and more fault-tolerant.
[0546] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
[0547] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
Claims
1. A configurable data packaging method for a vehicle-mounted information collection system, characterized in that: The steps include: Step 1: Loading the policy configuration file; the policy configuration file is a JSON file; initialize and serialize the policy configuration file and load it into the memory of the vehicle information collection system; Step 2: Data transmission strategy parsing step: parsing the strategy configuration file in the memory of the vehicle information collection system according to the data identifier to obtain the data transmission packet grouping strategy; Acquire signal value data from the signal value storage buffer, and package the signal value data according to the package package strategy; Step 3: Data storage step; The data transmission packet obtained after the packetization in step 2 is stored in the designated data transmission storage area; Step 4: remote update step of the policy configuration file; obtain the latest policy configuration file from the policy configuration file remote upgrade platform, replace the old policy configuration file in the vehicle information collection system, and implement the update of the policy configuration file.
2. The configurable data packaging method of the vehicle information collection system according to claim 1 is characterized in that: In the step 1, when initializing the policy configuration file, the JSON file is formatted into a structure object.
3. The configurable data packaging method of the vehicle information collection system according to claim 1 is characterized in that: In step 2, the packaging strategy includes packaging module identification ID, packaging module name Zm, packaging module content Zn, signal list Zx, signal storage buffer Zc, signal value type Zl, signal value position Zw and signal value size Zz.
4. The configurable data packaging method of the vehicle information collection system according to claim 1 is characterized in that: In the step 2, when the signal value data is packaged, the signal value is written into the memory according to the signal value type, signal value position and signal value size.
5. A system according to the configurable data packaging method of the vehicle-mounted information collection system according to claim 1, characterized in that: It includes a policy configuration file loading module, a data transmission policy parsing module, a data storage module and a policy configuration file OTA module; The policy configuration file loading module is used to initialize and serialize the policy configuration file and load it into the memory of the vehicle information collection system; The data transmission strategy parsing module is used to parse the strategy configuration file in the memory of the vehicle information collection system according to the data identifier to obtain the data transmission packet grouping strategy; obtain the signal value data from the signal value storage buffer, and group the signal value data according to the grouping strategy; The data storage module is used to store the data transmission packets obtained after packet assembly into a designated data transmission storage area; The policy configuration file OTA module is used to obtain the latest policy configuration file from the policy configuration file remote upgrade platform, replace the old policy configuration file in the vehicle information collection system, and implement the update of the policy configuration file.
6. The system of the configurable data packaging method of the vehicle-mounted information collection system according to claim 5 is characterized in that: The policy configuration file loading module includes an object initialization module and an object serialization module.
7. An electronic device comprising at least one processor and a memory connected to the at least one processor in communication; wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the configurable data packaging method for the in-vehicle information collection system according to any one of claims 1-4.
8. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the configurable data packaging method for the vehicle-mounted information collection system according to any one of claims 1-4.
9. A computer program product comprising a computer program; wherein: When the computer program is executed by a processor, the computer program implements the configurable data packaging method for the vehicle information collection system according to any one of claims 1 to 4.