Serial port screen GUI adaptive resolution rendering method and system

By embedding sequence identifiers and total length information in serial port screen data transmission, the problems of ambiguous data segmentation boundaries and disordered reorganization order are solved, achieving efficient data transmission and adaptive rendering, and improving the system's flexibility and reliability.

CN121501405BActive Publication Date: 2026-05-22JIYA LANGFANG ELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JIYA LANGFANG ELECTRONICS CO LTD
Filing Date
2025-11-21
Publication Date
2026-05-22

AI Technical Summary

Technical Problem

Existing technologies for serial port screen data transmission and adaptive rendering suffer from problems such as ambiguous segmentation identification, chaotic reassembly order, improper buffer management, high development costs, and high maintenance difficulty, resulting in data integrity not being guaranteed and low resource utilization efficiency.

Method used

By embedding segment metadata such as sequence identifier, total length, and current segment valid data length into data segments, the uniqueness of sequence identifiers and boundary identification in the data frame structure are realized, buffers are dynamically allocated, and data is reassembled according to sequence identifiers, supporting reliable transmission and display rendering of strings of arbitrary length.

Benefits of technology

It improves the accuracy and reliability of data transmission, avoids memory waste and insufficient buffers, enhances the system's ability to process and adapt to complex display content, and reduces development and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121501405B_ABST
    Figure CN121501405B_ABST
Patent Text Reader

Abstract

The application discloses a serial port screen GUI adaptive resolution rendering method and system, and belongs to the technical field of human-computer interaction. The method comprises the following steps: segmenting string data to obtain at least one data segment, and generating a unique sequence identifier; embedding the sequence identifier, the total length of the string data and the effective data length of the current segment in the frame structure of each data segment based on the data frame format limitation of the bus protocol to obtain a data frame carrying segment metadata; sequentially sending the data frame through the bus; dynamically allocating a buffer according to the sequence identifier and the total length information at the receiving end, and recombining each data segment according to the sending order according to the sequence identifier, obtaining display instructions after recombination and performing a rendering operation. Through the segment transmission and metadata identification mechanism, the application breaks through the limitation of the bus protocol on the length of single-frame data, realizes reliable transmission and accurate recombination of large-capacity string data, and improves the stability and adaptability of serial port screen rendering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of human-computer interaction technology, and in particular to a method and system for adaptive resolution rendering of a serial port screen GUI. Background Technology

[0002] In embedded systems and IoT devices, serial port displays are a commonly used human-machine interface, widely applied in industrial control, smart homes, medical equipment, and other fields. Serial port displays typically communicate with the host control unit via bus protocols such as UART, SPI, and I2C. The host control unit controls the content displayed on the serial port display by sending commands and data. As application scenarios become more complex, the content that serial port displays need to display is becoming increasingly rich, including long text, graphical interfaces, and dynamic data, which places higher demands on data transmission and rendering.

[0003] Traditional serial port communication methods are typically designed for fixed resolutions, with graphical user interface rendering parameters and layout coordinates hard-coded based on a specific screen size. When adapting to serial port screens with different resolutions, developers must redesign the interface and adjust the code for each screen specification, significantly increasing development costs and maintenance difficulty. Furthermore, due to limitations on the length of data frames transmitted in a single transmission by bus protocols, existing technologies often employ simple packet segmentation when transmitting long strings or complex display instructions, lacking effective segmentation management and reassembly mechanisms.

[0004] Existing technologies for serial port screen data transmission and adaptive rendering have the following shortcomings: First, existing data transmission methods lack a robust segmentation and identification mechanism. When string data exceeds the single-frame length limit of the bus protocol, although the data can be split into multiple data packets for transmission, the lack of clear sequence identifiers and association information between these packets makes it difficult for the receiving end to accurately identify the order and boundaries of each segment. This can easily lead to data reassembly errors or data loss, especially in environments with transmission delays or interference, where data integrity cannot be guaranteed. Second, existing technologies lack dynamic buffer management strategies at the receiving end. Traditional methods typically pre-allocate a fixed-size receiving buffer. This static allocation method either wastes memory or causes buffer overflows when receiving large amounts of data. Since the receiving end cannot know the total length of the complete data in advance, it cannot dynamically adjust the storage space according to actual needs, resulting in low resource utilization efficiency and potential system stability issues in memory-constrained embedded environments. Third, existing serial port screen rendering methods lack resolution adaptation capabilities. In traditional solutions, parameters such as display coordinates, control size, and font size are fixed based on a specific resolution. When changing to a different serial port screen, a large amount of code must be modified and the program recompiled. This hard-coding method is not only inefficient in development, but also makes it impossible to adapt the same code to multiple screen sizes, which severely restricts the product's versatility and scalability, and increases the cost of product iteration and maintenance. Summary of the Invention

[0005] This invention provides a serial port screen GUI adaptive resolution rendering method and system, which can at least solve some of the problems existing in the prior art.

[0006] A first aspect of this invention provides a serial port screen GUI adaptive resolution rendering method, comprising:

[0007] Obtain the string data to be transmitted and determine the total length of the string data;

[0008] The string data is segmented according to a preset upper limit for data segment length to obtain at least one data segment, and a unique sequence identifier is generated for each data segment;

[0009] Based on the data frame format limitations of the bus protocol, the sequence identifier, the total length of the string data, and the effective data length of the current segment are embedded in the frame structure of each data segment to obtain a data frame carrying segment metadata, wherein the segment metadata is used by the receiving end to identify segment boundaries and reassembly order;

[0010] The data frames carrying segmented metadata are transmitted sequentially via the bus, each frame containing valid data for one data segment;

[0011] At the receiving end, based on the sequence identifier and total length information in the received data frame, a buffer for storing complete string data is dynamically allocated, and each data segment is reassembled into the corresponding position in the buffer according to the sending order based on the sequence identifier, to obtain the reassembled complete string data;

[0012] The display instruction is parsed from the recombined complete string data, and the display rendering operation corresponding to the display instruction is executed.

[0013] The string data is segmented according to a preset upper limit for data segment length to obtain at least one data segment, and a unique sequence identifier is generated for each data segment, including:

[0014] Obtain the maximum number of bytes used to carry valid data in the single-frame data frame structure specified by the bus protocol. Based on the maximum number of bytes and the fixed number of bytes required to carry segmented metadata, obtain the net number of bytes that a single frame can use to carry string data segments.

[0015] The net number of bytes is determined as the upper limit of the data segment length, and the total number of segments after the string data is segmented according to the upper limit of the data segment length is calculated;

[0016] Based on the storage location offset of the string data in the buffer, data segments with a length not exceeding the upper limit of the data segment length are sequentially extracted as data segments, and the starting position offset and actual data length of each data segment in the string data are recorded, wherein the starting position offset is used by the receiving end to locate the reassembly position of the data segment in the complete string data;

[0017] The encoding bit width of the sequence identifier is determined based on the total number of segments, and an incremental and unique sequence identifier is assigned to each data segment according to the truncation order of the data segments, so that the sequence identifier and the starting position offset are uniquely mapped.

[0018] Based on the data frame format limitations of the bus protocol, the sequence identifier, the total length of the string data, and the effective data length of the current segment are embedded in the frame structure of each data segment to obtain a data frame carrying segment metadata, including:

[0019] Obtain the positions of fixed fields used to carry control information and variable fields used to carry valid data in the data frame structure specified by the bus protocol;

[0020] In the fixed field positions, the storage locations for the sequence identifier, the total length of the string data, and the effective data length of the current segment are allocated sequentially according to a predetermined byte order, and the number of bytes occupied and the starting offset position are determined for each segment metadata item;

[0021] The sequence identifier corresponding to the current data segment, the total length of the string data, and the effective data length of the current data segment are encoded into the fixed field position according to the byte order and the starting offset position to obtain the segment metadata field;

[0022] Fill the variable field position with the valid data of the current data segment, and the filling length is consistent with the valid data length of the current data segment.

[0023] The segmented metadata field is combined with the filled valid data to obtain a data frame carrying segmented metadata that conforms to the bus protocol data frame format restrictions.

[0024] The sequence identifier corresponding to the current data segment, the total length of the string data, and the effective data length of the current data segment are encoded into the fixed field position according to the byte order and the starting offset position to obtain the segment metadata field, including:

[0025] The number of encoded bytes for each metadata item is determined based on the numerical ranges of the sequence identifier, the total length of the string data, and the effective data length of the current data segment.

[0026] Based on the number of encoded bytes, a fixed byte order rule is used to convert the value of each metadata item into a corresponding byte sequence, wherein the fixed byte order rule ensures that the encoding and decoding order of multi-byte values ​​is consistent between the sending end and the receiving end;

[0027] Obtain the starting offset position allocated to the sequence identifier, the total length of the string data, and the effective data length of the current segment;

[0028] According to the byte order, the byte sequence corresponding to the sequence identifier is written to the starting offset position of the sequence identifier, the byte sequence corresponding to the total length of the string data is written to the starting offset position of the total length of the string data, and the byte sequence corresponding to the effective data length of the current data segment is written to the starting offset position of the effective data length of the current segment, so as to obtain the segmented metadata field that is continuously or discretely distributed in the fixed field position.

[0029] At the receiving end, based on the sequence identifier and total length information in the received data frame, a buffer for storing complete string data is dynamically allocated. Then, according to the sequence identifier, each data segment is reassembled into its corresponding position in the buffer in the order of transmission, resulting in the reassembled complete string data, including:

[0030] Based on the total length of the string data extracted from the received data frame, allocate a contiguous buffer with a capacity matching the total length in the storage space of the receiving end, and initialize the write position tracking structure of the buffer;

[0031] Extract the sequence identifier and valid data length of the current segment from the segment metadata field of the received data frame, and extract the valid data of the current data segment from the variable field position of the data frame;

[0032] Based on the sequence identifier and the preset mapping rule from sequence identifier to buffer position, the write start position of the current data segment in the buffer is calculated, and the write end position is determined according to the effective data length of the current segment;

[0033] The valid data of the current data segment is written to the buffer in byte order, starting from the write start position, until the write end position;

[0034] The write position tracking structure marks the buffer area corresponding to the current data segment as having been written. When the write position tracking structure indicates that the entire area of ​​the buffer has been written, the data stored in the buffer is determined as the reconstructed complete string data.

[0035] Based on the sequence identifier and the preset mapping rule from sequence identifier to buffer position, the write start position of the current data segment in the buffer is calculated, and the write end position is determined according to the effective data length of the current segment, including:

[0036] Obtain the upper limit of the data segment length agreed upon by both the sender and receiver;

[0037] The sequence identifier is converted into an index value. The step size is the upper limit of the data segment length. The number of steps is the index value. The byte offset of the current data segment relative to the starting address of the buffer is calculated by accumulating the positions.

[0038] Check whether the byte offset is less than the total buffer capacity allocated based on the total length of the string data. If the byte offset is less than the total buffer capacity, use the buffer start address as a reference and perform address offset according to the byte offset to obtain the write start position of the current data segment in the buffer.

[0039] Based on the write start position and the effective data length value of the current segment, the write end position of the current data segment in the buffer is obtained, wherein the write end position indicates the next storage location of the last byte of the current data segment in the buffer;

[0040] Verify that the write termination position does not exceed the storage boundary allocated by the buffer based on the total length value of the string data.

[0041] Based on the recombined complete string data, a display instruction is parsed, and the display rendering operation corresponding to the display instruction is executed, including:

[0042] The recombined complete string data is formatted to determine the separation rules between the structured fields that carry display instructions and the data fields that carry display content.

[0043] The recombined complete string data is segmented according to the segmentation rules, and the instruction type identifier, display position parameter, and display attribute parameter in the structured fields are extracted. The text content to be displayed in the data fields is also extracted.

[0044] Based on the instruction type identifier, a preset mapping table of instruction types to rendering functions is queried to determine the display rendering function corresponding to the instruction type identifier;

[0045] The display position parameters, the display attribute parameters, and the text content to be displayed are input into the display rendering function, which triggers the display rendering function to call the driver interface of the display hardware.

[0046] After the display hardware completes the data refresh from the display hardware frame buffer to the display screen, the text content to be displayed is displayed on the display screen in accordance with the display position parameters and the display attribute parameters.

[0047] A second aspect of the present invention provides a serial port screen GUI adaptive resolution rendering system, comprising:

[0048] The first unit is used to acquire the string data to be transmitted and determine the total length of the string data;

[0049] The second unit is used to segment the string data according to a preset upper limit for data segment length, to obtain at least one data segment, and to generate a unique sequence identifier for each data segment;

[0050] The third unit, based on the data frame format restrictions of the bus protocol, embeds the sequence identifier, the total length of the string data, and the effective data length of the current segment into the frame structure of each data segment to obtain a data frame carrying segment metadata, wherein the segment metadata is used by the receiving end to identify segment boundaries and reassembly order;

[0051] The fourth unit is used to sequentially send the data frames carrying segmented metadata via the bus, each data frame containing valid data of a data segment;

[0052] The fifth unit is used to dynamically allocate a buffer for storing complete string data at the receiving end based on the sequence identifier and total length information in the received data frame, and to reassemble each data segment into the corresponding position in the buffer according to the sending order based on the sequence identifier, so as to obtain the reassembled complete string data;

[0053] The sixth unit is used to parse the display instruction based on the recombined complete string data and execute the display rendering operation corresponding to the display instruction.

[0054] A third aspect of the present invention provides an electronic device, comprising:

[0055] processor;

[0056] Memory used to store processor-executable instructions;

[0057] The processor is configured to invoke instructions stored in the memory to execute the aforementioned method.

[0058] A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the aforementioned method.

[0059] This invention embeds segment metadata such as sequence identifiers, total length, and the effective data length of the current segment into the data segments, enabling the receiving end to accurately identify the boundary position of each data segment and its sequential relationship in the complete data. This effectively solves the problems of ambiguous data segment boundaries and disordered reorganization order in traditional methods, and improves the accuracy and reliability of data transmission.

[0060] This invention dynamically allocates a buffer at the receiving end based on the total length information received, and reassembles each data segment into the corresponding position in the buffer according to the sequence identifier in the order of transmission. This avoids the memory waste or insufficient buffer caused by the need to pre-allocate a fixed-size buffer in the traditional method, and realizes flexible and efficient use of memory resources, while ensuring the integrity and accuracy of data reassembly.

[0061] This invention enables serial port screens to overcome the limitation of single-frame data length in bus protocols by transmitting long string data in segments according to a preset upper limit for data segment length, and then reassembling the segments at the receiving end before parsing and rendering display instructions. This allows the system to reliably transmit and correctly display string data of any length, thereby improving the system's ability to handle complex display content and its adaptability. Attached Figure Description

[0062] Figure 1 This is a flowchart illustrating the serial port screen GUI adaptive resolution rendering method according to an embodiment of the present invention.

[0063] Figure 2 This is a schematic diagram illustrating the process of determining a data frame carrying segmented metadata according to an embodiment of the present invention. Detailed Implementation

[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0065] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0066] Figure 1 This is a flowchart illustrating the serial port screen GUI adaptive resolution rendering method according to an embodiment of the present invention. Figure 1 As shown, the method includes:

[0067] Obtain the string data to be transmitted and determine the total length of the string data;

[0068] The string data is segmented according to a preset upper limit for data segment length to obtain at least one data segment, and a unique sequence identifier is generated for each data segment;

[0069] Based on the data frame format limitations of the bus protocol, the sequence identifier, the total length of the string data, and the effective data length of the current segment are embedded in the frame structure of each data segment to obtain a data frame carrying segment metadata, wherein the segment metadata is used by the receiving end to identify segment boundaries and reassembly order;

[0070] The data frames carrying segmented metadata are transmitted sequentially via the bus, each frame containing valid data for one data segment;

[0071] At the receiving end, based on the sequence identifier and total length information in the received data frame, a buffer for storing complete string data is dynamically allocated, and each data segment is reassembled into the corresponding position in the buffer according to the sending order based on the sequence identifier, to obtain the reassembled complete string data;

[0072] The display instruction is parsed from the recombined complete string data, and the display rendering operation corresponding to the display instruction is executed.

[0073] In one optional implementation, the string data is segmented according to a preset upper limit for data segment length to obtain at least one data segment, and a unique sequence identifier is generated for each data segment, including:

[0074] Obtain the maximum number of bytes used to carry valid data in the single-frame data frame structure specified by the bus protocol. Based on the maximum number of bytes and the fixed number of bytes required to carry segmented metadata, obtain the net number of bytes that a single frame can use to carry string data segments.

[0075] The net number of bytes is determined as the upper limit of the data segment length, and the total number of segments after the string data is segmented according to the upper limit of the data segment length is calculated;

[0076] Based on the storage location offset of the string data in the buffer, data segments with a length not exceeding the upper limit of the data segment length are sequentially extracted as data segments, and the starting position offset and actual data length of each data segment in the string data are recorded, wherein the starting position offset is used by the receiving end to locate the reassembly position of the data segment in the complete string data;

[0077] The encoding bit width of the sequence identifier is determined based on the total number of segments, and an incremental and unique sequence identifier is assigned to each data segment according to the truncation order of the data segments, so that the sequence identifier and the starting position offset are uniquely mapped.

[0078] In practical implementation, it is necessary to obtain the detailed definition of the single-frame data structure from the bus protocol specification. Taking the CAN bus protocol as an example, the data field of a standard CAN frame can carry a maximum of 8 bytes of valid data. The protocol configuration file is read, the data frame format description is parsed, and the byte capacity parameter of the data field is extracted and stored as the maximum number of bytes variable. In practical applications, when using the CAN-FD protocol, the single-frame data field can be expanded to 64 bytes; this value needs to be dynamically obtained based on the actual protocol type used.

[0079] After obtaining the maximum number of bytes, it is necessary to calculate the fixed number of bytes occupied by the segment metadata. Segment metadata typically includes control information such as sequence identifiers, start position offsets, actual data lengths, and the total number of segments. Assuming the sequence identifier occupies 2 bytes, the start position offset occupies 4 bytes to support large-capacity string positioning, the actual data length occupies 2 bytes, and the total number of segments occupies 2 bytes, then the segment metadata requires a total of 10 bytes of fixed space. Subtracting the fixed number of bytes from the maximum number of bytes yields the net number of bytes. In a scenario with an 8-byte capacity CAN bus, a negative net number of bytes indicates that the protocol is not applicable, requiring adjustment of the metadata structure or a change of protocol. Under the CAN-FD protocol, 64 bytes minus 10 bytes equals a net number of 54 bytes, which is the length of the string data segment that a single frame can carry.

[0080] The calculated net byte count is set as the upper limit of the data segment length. This upper limit serves as the baseline parameter for subsequent segmentation operations. For the string data to be transmitted, its total byte length is obtained, and the total number of segments is calculated through division and rounding up. For example, if the total length of a string is 200 bytes and the upper limit of the data segment length is 54 bytes, dividing 200 by 54 yields a quotient of 3 and a remainder of 38. After rounding up, the total number of segments is 4. This total number of segments is recorded in a control variable for subsequent calculation of the encoding bit width for sequence identifiers and for data integrity verification.

[0081] Before performing the segmentation operation, the base address of the string data in the buffer needs to be determined. Assuming the buffer base address is 0x3000, the string data will be stored contiguously starting from this address. The current offset variable is initialized to 0; this variable records the length of data processed. For the first data segment, reading begins from buffer address 0x3000 plus offset 0, and a 54-byte data fragment is extracted. The starting offset of this data segment is recorded as 0, and the actual data length is recorded as 54 bytes. The current offset variable is updated by incrementing it by 54, resulting in a new offset value of 54.

[0082] When processing the second data segment, continue reading from buffer address 0x3000 plus offset 54, and extract another 54 bytes of data. The starting offset of this data segment is 54, and the actual data length is 54 bytes. The current offset is updated to 108. When processing the third data segment, read 54 bytes from offset 108. The starting offset is 108, the actual length is 54 bytes, and the current offset is updated to 162. When processing the last data segment, the remaining data length is 200 minus 162, which equals 38 bytes, less than the upper limit of the data segment length. Read 38 bytes of data from offset 162. The starting offset of this segment is 162, the actual data length is 38 bytes, and this segment is marked as the end segment.

[0083] The encoding width of the sequence identifier needs to be dynamically determined based on the total number of segments to ensure that all segments can be uniquely identified. When the total number of segments is 4, 1 byte (8 bits) can represent the range from 0 to 255, which is sufficient to cover the numbering requirements of 4 segments. If the total number of segments exceeds 255 but does not exceed 65535, then 2 bytes (16 bits) are required for encoding. By determining the numerical range of the total number of segments, the minimum number of bytes required is selected as the encoding width. In this example, 4 segments can be encoded using 1 byte.

[0084] Sequence identifiers are assigned according to the order in which the data segments are extracted. The first data segment has a starting offset of 0 and is assigned sequence identifier 0. The second data segment has a starting offset of 54 and is assigned sequence identifier 1. The third data segment has a starting offset of 108 and is assigned sequence identifier 2. The fourth data segment has a starting offset of 162 and is assigned sequence identifier 3. The sequence identifiers are numbered in an ascending order, and each identifier value is unique within the current string data segment set, with no duplicates or jumps.

[0085] By parsing the mapping relationship between sequence identifiers and starting position offsets, the receiving end can accurately locate the reassembly position of each data segment within the complete string. When the receiving end receives the data segment with sequence identifier 2, it reads the starting position offset 108 carried by the segment and writes the actual data content of the segment into the reassembly buffer at offset 108. Even if the data segments arrive out of order due to network transmission disorder, the receiving end can still correctly reassemble the data segments according to the starting position offsets, restoring the integrity and order of the original string data.

[0086] In one optional implementation, based on the data frame format limitations of the bus protocol, the sequence identifier, the total length of the string data, and the effective data length of the current segment are embedded in the frame structure of each data segment to obtain a data frame carrying segment metadata, including:

[0087] Obtain the positions of fixed fields used to carry control information and variable fields used to carry valid data in the data frame structure specified by the bus protocol;

[0088] In the fixed field positions, the storage locations for the sequence identifier, the total length of the string data, and the effective data length of the current segment are allocated sequentially according to a predetermined byte order, and the number of bytes occupied and the starting offset position are determined for each segment metadata item;

[0089] The sequence identifier corresponding to the current data segment, the total length of the string data, and the effective data length of the current data segment are encoded into the fixed field position according to the byte order and the starting offset position to obtain the segment metadata field;

[0090] Fill the variable field position with the valid data of the current data segment, and the filling length is consistent with the valid data length of the current data segment.

[0091] The segmented metadata field is combined with the filled valid data to obtain a data frame carrying segmented metadata that conforms to the bus protocol data frame format restrictions.

[0092] Figure 2 This is a schematic diagram illustrating the process of determining a data frame carrying segmented metadata according to an embodiment of the present invention. Figure 2 As shown, in the specific implementation process, the bus protocol specification document is pre-loaded, and the complete data frame structure defined by the protocol is obtained from it. The data frame structure includes a frame header identifier, command bytes, data length bytes, data payload area, check bytes, and frame trailer identifier. The protocol parsing module identifies that the area between the command byte and the data length byte is a fixed field position, which is used to store control information and has a fixed length; while the data payload area is a variable field position, and its length is dynamically adjusted within the maximum value allowed by the protocol according to the actual amount of data transmitted.

[0093] To address the storage requirements of segmented metadata, fine-grained byte-level allocation is performed within fixed field locations. Assuming a total of 8 bytes are available in the fixed field area, allocation is performed using little-endian: bytes 0 to 1 (2 bytes) are used to store the sequence identifier, supporting a sequence number range of 0 to 65535; bytes 2 to 5 (4 bytes) are used to store the total length of the string data, supporting a maximum data size of 4GB; bytes 6 to 7 (2 bytes) are used to store the effective data length of the current segment, supporting a maximum single transmission size of 64KB. The starting offset of each metadata item is explicitly recorded: the sequence identifier starts at offset 0, the total length starts at offset 2, and the effective segment length starts at offset 6.

[0094] When processing a real-world string data transfer task, assuming the original string has a total length of 150,000 bytes, it is divided into multiple data segments. For the 5th data segment, its sequence identifier is 5, indicating that this is the 5th transmission fragment of the string. The integer 5 is converted to a 2-byte hexadecimal representation of 0x0005. Following little-endian order, the least significant byte 0x05 is written to the 0th byte of the fixed field, and the most significant byte 0x00 is written to the 1st byte. The total string length of 150,000 is converted to a 4-byte hexadecimal representation of 0x000249F0. Following little-endian order, 0xF0, 0x49, 0x02, and 0x00 are written sequentially to the 2nd through 5th byte positions. The current 5th data segment carries a valid data length of 2048 bytes, which is converted to a 2-byte hexadecimal representation of 0x0800. Following little-endian order, 0x00 is written to the 6th byte, and 0x08 is written to the 7th byte. After these write operations are completed, a segmented metadata field of 8 bytes is formed at the fixed field position, the content of which is the hexadecimal sequence 0x050x00 0xF0 0x49 0x02 0x00 0x00 0x08.

[0095] During the data filling phase, 2048 bytes of actual content are extracted from the corresponding positions of the original string data. This content corresponds to the data range from byte 8192 to byte 10239 of the original string. These 2048 bytes of valid data are copied byte by byte to the variable field location, ensuring that the filling length is exactly equal to the valid data length value of 2048 recorded in the segment metadata. If the bus protocol specifies a maximum capacity of 4096 bytes for the variable field location, then only 2048 bytes are currently used, and the remaining space remains unused.

[0096] The data frame assembly process follows the order specified by the bus protocol. Taking this protocol as an example, the complete data frame structure is: a 1-byte frame header identifier (0xAA), an 8-byte segmented metadata field, 2048 bytes of valid data payload, a 2-byte CRC checksum, and a 1-byte frame trailer identifier (0x55). A contiguous memory buffer is created. First, the frame header identifier (0xAA) is written at the beginning, followed by the 8-byte segmented metadata field (0x05 0x00 0xF0 0x49 0x02 0x00 0x00 0x08). Then, 2048 bytes of actual valid data are written. Next, the CRC16 checksum is calculated based on all the aforementioned data and written to the 2-byte checksum field. Finally, the frame trailer identifier (0x55) is written at the end. The total length of the entire data frame is 2060 bytes, fully complying with the bus protocol's requirements for the data frame format.

[0097] When parsing the data frame, the receiving end reads and decodes bytes 0 to 1 in little-endian order from the fixed field positions, obtaining sequence identifier 5; bytes 2 to 5 are read and decoded to obtain the total length 150000; and bytes 6 to 7 are read and decoded to obtain the current segment's effective length 2048. Based on the effective length value, the receiving end precisely extracts 2048 bytes of data from the variable field positions, and then places the segmented data into the correct position in the reassembly buffer according to the sequence identifier. The transmission completion status is determined by checking if the total received data has reached the total length value. This embedded metadata scheme allows each data frame to carry complete segment reassembly information without the need for additional control frames or state negotiation processes, achieving efficient and reliable long string data transmission.

[0098] In one optional implementation, the sequence identifier corresponding to the current data segment, the total length of the string data, and the effective data length of the current data segment are encoded into the fixed field position according to the byte order and the starting offset position to obtain the segment metadata field, including:

[0099] The number of encoded bytes for each metadata item is determined based on the numerical ranges of the sequence identifier, the total length of the string data, and the effective data length of the current data segment.

[0100] Based on the number of encoded bytes, a fixed byte order rule is used to convert the value of each metadata item into a corresponding byte sequence, wherein the fixed byte order rule ensures that the encoding and decoding order of multi-byte values ​​is consistent between the sending end and the receiving end;

[0101] Obtain the starting offset position allocated to the sequence identifier, the total length of the string data, and the effective data length of the current segment;

[0102] According to the byte order, the byte sequence corresponding to the sequence identifier is written to the starting offset position of the sequence identifier, the byte sequence corresponding to the total length of the string data is written to the starting offset position of the total length of the string data, and the byte sequence corresponding to the effective data length of the current data segment is written to the starting offset position of the effective data length of the current segment, so as to obtain the segmented metadata field that is continuously or discretely distributed in the fixed field position.

[0103] During data transmission, segmented metadata needs to be encoded into fixed field positions according to a predetermined format. This implementation achieves precise encoding of metadata through four steps: numerical range analysis, byte order conversion, offset positioning, and sequential writing.

[0104] Before encoding, it's necessary to analyze the numerical ranges of the sequence identifier, the total length of the string data, and the effective data length of the current data segment. The sequence identifier is used to mark the sequential number of the data segments. Assuming a data transmission task supports a maximum of 65,000 segments, the sequence identifier's value range is 0 to 65,000, and values ​​within this range can be stored using 2 bytes. The total length of the string data represents the number of bytes of the original complete data. If the maximum supported data volume is 4,000,000 bytes, the total length's value range is 0 to 4,000,000, requiring 3 bytes for storage. The effective data length of the current data segment represents the actual number of bytes of data carried by this segment. Assuming the maximum payload of each segment is 4096 bytes, the effective data length's value range is 0 to 4096, also requiring 2 bytes for storage.

[0105] After determining the number of bytes, the values ​​of each metadata item need to be converted into a byte sequence. Big-endian byte order is used as the fixed byte order rule, which stores the most significant byte at the lowest address and the least significant byte at the highest address. For the sequence identifier value 1234, its hexadecimal representation is 04D2. According to big-endian byte order, the first byte is 04 and the second byte is D2. For the total length of the string data 3,000,000 bytes, its hexadecimal representation is 2DC6C0. When converted to a three-byte sequence, the first byte is 2D, the second byte is C6, and the third byte is C0. For the current segment's valid data length of 3072 bytes, its hexadecimal representation is 0C00. After conversion, the first byte is 0C and the second byte is 00. This conversion process ensures that the sending and receiving ends have completely consistent understanding of the multi-byte values. When the receiving end reads the byte sequence according to the same byte order rule, it can accurately reconstruct the original value.

[0106] When obtaining the starting offset of metadata items, the position of each metadata item within the fixed fields needs to be determined based on the structure of the segmented data packet. Assuming the total length of the fixed fields in the segmented data packet is 16 bytes, with the first 8 bytes used for header identification and checksum information, and the last 8 bytes used for storing metadata, the sequence identifier is allocated starting offset at byte 8, occupying 2 bytes (bytes 8 and 9). The total length of the string data is allocated starting offset at byte 10, occupying 3 bytes (bytes 10, 11, and 12). The current segment's valid data length is allocated starting offset at byte 13, occupying 2 bytes (bytes 13 and 14). This offset allocation method creates a continuously distributed metadata layout within the fixed fields.

[0107] When performing a byte write operation, the converted byte sequence must be written to the corresponding offset positions strictly according to byte order. A 16-byte buffer is created, and the byte sequences 04 and D2 corresponding to the sequence identifier are written to the 8th and 9th bytes of the buffer, respectively. The byte sequences 2D, C6, and C0 corresponding to the total length of the string data are written to the 10th, 11th, and 12th bytes of the buffer, respectively. The byte sequences 0C and 00 corresponding to the current segment's valid data length are written to the 13th and 14th bytes of the buffer, respectively. During the write process, offset calculations ensure that each byte is accurately placed in its predetermined position, avoiding data overwriting or misalignment. After all metadata items have been written, bytes 8-14 of the buffer form the complete segment metadata field.

[0108] In some implementation scenarios, metadata items are distributed discretely. For example, the sequence identifier is allocated to the 2nd and 3rd bytes, the total length of the string data is allocated to the 7th-9th bytes, and the current segment's valid data length is allocated to the 14th and 15th bytes. In this case, the write process needs to operate according to their respective independent starting offset positions, but the basic principles of transformation and writing remain unchanged. This discrete layout is suitable for complex data packet structures where fixed fields contain other control information.

[0109] Through the above encoding process, the original metadata values ​​are converted into binary byte sequences that conform to the transmission protocol requirements and are precisely placed at fixed positions in the segmented data packets. The receiving end can extract metadata fields from the received data packets according to the same offset definition and byte order rules, and restore the original values ​​of sequence identifier, total string data length, and current segment valid data length, thereby completing the correct identification and reassembly of data segments.

[0110] In one optional implementation, at the receiving end, a buffer for storing complete string data is dynamically allocated based on the sequence identifier and total length information in the received data frame. Then, according to the sequence identifier, each data segment is reassembled into its corresponding position in the buffer in the order of transmission, resulting in the reassembled complete string data, including:

[0111] Based on the total length of the string data extracted from the received data frame, allocate a contiguous buffer with a capacity matching the total length in the storage space of the receiving end, and initialize the write position tracking structure of the buffer;

[0112] Extract the sequence identifier and valid data length of the current segment from the segment metadata field of the received data frame, and extract the valid data of the current data segment from the variable field position of the data frame;

[0113] Based on the sequence identifier and the preset mapping rule from sequence identifier to buffer position, the write start position of the current data segment in the buffer is calculated, and the write end position is determined according to the effective data length of the current segment;

[0114] The valid data of the current data segment is written to the buffer in byte order, starting from the write start position, until the write end position;

[0115] The write position tracking structure marks the buffer area corresponding to the current data segment as having been written. When the write position tracking structure indicates that the entire area of ​​the buffer has been written, the data stored in the buffer is determined as the reconstructed complete string data.

[0116] After receiving a data frame carrying complete string data, the receiving end immediately extracts the value of the total string length field from the frame header. Assuming the value of this field is 1024 bytes in the first data frame received, the receiving end's memory management module requests 1024 bytes of contiguous physical memory space from the operating system as a buffer. The memory management module calls the memory allocation function, passing the parameter 1024. The operating system finds a contiguous free memory region in the heap space starting at address 0x2000 and returns a pointer to this region's address to the receiving end program. The receiving end program stores this address pointer in the `base_address` field of the buffer management structure, and simultaneously records the total buffer capacity as 1024 bytes in this structure.

[0117] The receiving end creates a write position tracking structure to record the write status of each region in the buffer. This tracking structure is implemented as a bitmap array, dividing the 1024-byte buffer into 8 regions with a granularity of 128 bytes each. Each region corresponds to a bit in the bitmap array. The bitmap array is initialized to all zeros, where 0 indicates that no data has been written to the corresponding region, and 1 indicates that data writing has been completed. The receiving end allocates an 8-bit byte variable `bitmap` in memory, initialized to 0x00. Each bit of this variable corresponds to a 128-byte region in the buffer. Simultaneously, a counter variable `completed_segments` is created, initialized to 0, to record the number of regions that have been written.

[0118] The receiving end reads the sequence identifier information from the segment metadata field of the received data frame. This sequence identifier field is located at offset 16 bytes in the data frame and occupies 2 bytes of space. The receiving end reads two bytes of data from this position, obtaining a sequence identifier value of 3. The sequence identifier value of 3 indicates that the currently received segment is the 3rd segment of the entire string data. The receiving end continues to read the current segment's valid data length field from offset 18 bytes. This field occupies 2 bytes, and the read value is 128, indicating that the current segment contains 128 bytes of valid string data.

[0119] The receiving end extracts the actual string data segments from the variable field positions of the data frame. The first 32 bytes of the data frame are a fixed frame header, and the variable data payload area begins from the 33rd byte. The receiving end locates the position at offset 32 ​​bytes and reads 128 bytes of data continuously from that position. The read data content is a sequence of ASCII characters, and the receiving end temporarily stores this 128 bytes of data in a local buffer for subsequent write operations.

[0120] The receiving end calculates the start position for writing the data segment in the target buffer based on the sequence identifier value 3. Each data segment has a standard length of 128 bytes, and the sequence identifiers are numbered starting from 0. The receiving end multiplies the sequence identifier value 3 by the standard segment length of 128 bytes, obtaining an offset of 384 bytes for the segment in the buffer. Adding the offset 384 to the buffer base address 0x2000 gives the absolute address of the start position, 0x2180. The receiving end adds the valid data length of the current segment (128 bytes) to the offset 384, obtaining an offset of 512 bytes for the end position, corresponding to an absolute address of 0x2200.

[0121] The receiving end performs a data write operation, reading 128 bytes of valid data from a temporary buffer and writing this data to the specified location in the target buffer using a memory copy function. The memory copy function receives three parameters: the target address (0x2180), the source data address, and the data length of 128 bytes. This function copies the source data to the target address byte by byte, starting from position 0x2180 and writing the last byte at position 0x21FF. During the write process, data integrity and order are guaranteed; each byte is placed strictly according to its position in the original string.

[0122] After writing is complete, the receiving end updates the write position tracking structure. The segment with sequence identifier 3 corresponds to the 3rd region of the buffer, which is the 3rd bit in the bitmap array. The receiving end sets the 3rd bit of the bitmap variable from 0 to 1, updating 0x00 to 0x08 through bitwise operations. Simultaneously, the value of the completed_segments counter is incremented by 1. The receiving end continues to receive subsequent data frames, repeating the above process of extraction, calculation, writing, and marking.

[0123] After the receiving end receives and processes all data segments, it checks the status of the write position tracking structure. The receiving end checks each bit of the bitmap variable and finds that all 8 bits are 1, at which point the bitmap value is 0xFF, indicating that all 8 regions of the buffer have completed data writing. Simultaneously, the completed_segments counter reaches 8, consistent with the expected total number of segments. Through this double verification of these two conditions, the receiving end confirms that all data segments have been received and correctly written to their corresponding positions in the buffer.

[0124] The receiving end identifies the 1024 bytes of data stored in the buffer as the reassembled complete string. Starting from the buffer base address 0x2000, it reads the complete 1024 bytes of data, which has been reassembled according to the original string's order. The receiving end can then perform subsequent processing on this complete string data, such as character encoding conversion, content parsing, or business logic processing. The entire reassembly process, through dynamic buffer allocation and precise positioning based on sequence identifiers, achieves the correct reassembly of out-of-order data segments, ensuring the reliability and integrity of string data transmission.

[0125] In one optional implementation, based on the sequence identifier and a preset mapping rule from sequence identifier to buffer position, the write start position of the current data segment in the buffer is calculated, and the write end position is determined according to the effective data length of the current segment, including:

[0126] Obtain the upper limit of the data segment length agreed upon by both the sender and receiver;

[0127] The sequence identifier is converted into an index value. The step size is the upper limit of the data segment length. The number of steps is the index value. The byte offset of the current data segment relative to the starting address of the buffer is calculated by accumulating the positions.

[0128] Check whether the byte offset is less than the total buffer capacity allocated based on the total length of the string data. If the byte offset is less than the total buffer capacity, use the buffer start address as a reference and perform address offset according to the byte offset to obtain the write start position of the current data segment in the buffer.

[0129] Based on the write start position and the effective data length value of the current segment, the write end position of the current data segment in the buffer is obtained, wherein the write end position indicates the next storage location of the last byte of the current data segment in the buffer;

[0130] Verify that the write termination position does not exceed the storage boundary allocated by the buffer based on the total length value of the string data.

[0131] When processing string data transmitted over the network at the receiving end, it is necessary to determine the exact storage location of each data segment in the buffer based on the sequence identifier of the data segment. The sending and receiving ends have negotiated and determined the upper limit of the data segment length before the communication begins. This upper limit defines the maximum number of bytes that each data segment can carry. For example, in a practical application scenario, the communicating parties agree that the upper limit of the data segment length is 1024 bytes. This means that when the original string data is divided, the net payload data carried by each segment will not exceed 1024 bytes.

[0132] After the receiving end obtains the current data segment, it extracts the sequence identifier field from the segment's message header. The sequence identifier is usually an incrementing integer, starting with a value of 0 and incrementing sequentially for subsequent segments. This sequence identifier is used directly as an index value, reflecting the current segment's sequential position in the complete data stream. For example, for a data segment with a sequence identifier of 3, the index value is 3, indicating that this is the fourth data segment.

[0133] When calculating the byte offset, the index value is multiplied by the upper limit of the data segment length. Specifically, the index value is used as a multiplier factor, and the upper limit of the data segment length is used as the unit step size for cumulative calculation. When the index value is 3 and the upper limit of the data segment length is 1024 bytes, the byte offset is calculated as follows: starting from position 0, the step size of 1024 bytes is added three times, resulting in 3072 bytes. This byte offset indicates that the starting data of the current data segment should be stored at a position offset 3072 bytes from the starting address of the buffer.

[0134] Before receiving the data stream, the receiving end has already obtained the total length of the string data from the control information and pre-allocated buffer space accordingly. Assuming the total length of the string data is 5000 bytes, the total capacity of the buffer allocated by the receiving end should be no less than 5000 bytes. Before writing data to the buffer, a boundary check needs to be performed on the calculated byte offset. The byte offset of 3072 bytes is compared with the total buffer capacity of 5000 bytes. Since 3072 is less than 5000, it indicates that the starting position of the current data segment falls within the valid buffer range, and subsequent write operations can continue.

[0135] When determining the starting write position, the buffer's base address is used as a reference point. Assuming the buffer's starting memory address is 0x10000000, an address offset operation is performed based on the calculated byte offset of 3072. Specifically, the buffer's starting address is added to the byte offset to obtain the absolute address of the write start position, which is 0x10000C00. This address is the target memory location where the first byte of the current data segment should be written.

[0136] In addition to the sequence identifier, the current data segment also carries a valid data length field. This field indicates the actual number of bytes of data carried by this segment. Since the last segment cannot fill the upper limit of the entire data segment length, the valid data length is less than the agreed upper limit value. Assuming that the segment with sequence identifier 3 has a valid data length of 800 bytes, it means that this segment actually carries 800 bytes of string data content.

[0137] The write termination position is determined based on two parameters: the write start position and the valid data length. The address of the write start position and the valid data length are added together to obtain the position indicator after the write operation ends. Taking a write start position of 0x10000C00 and a valid data length of 800 bytes as an example, the result is 0x10000F20. This address points to the memory location following the last byte of the current data segment, marking the termination boundary of the current segment's data write range.

[0138] Before actually performing the data copy operation, the validity of the write termination position must be verified by comparing the calculated write termination position with the storage boundary of the buffer. The storage boundary of the buffer is determined by the sum of the starting address and the total length. Taking the starting address 0x10000000 and the total length of 5000 bytes as an example, the storage boundary address is 0x10001388. Comparing the write termination position 0x10000F20 with the storage boundary 0x10001388, since the value of the write termination position is less than the storage boundary, it indicates that the write operation of the current data segment will not cause a buffer overflow, and the data copy can be safely performed.

[0139] After completing all position calculations and boundary checks, the receiving end performs a memory copy operation, copying the payload data from the data segment from the network receive buffer to the specified location in the target buffer. The copy operation starts at the write start position 0x10000C00 and continues writing 800 bytes until it reaches the byte before the write end position 0x10000F20. Through this precise position mapping mechanism, even if the data segments arrive at the receiving end out of order, each segment can be accurately placed in the correct position in the buffer according to its sequence identifier, ultimately completing the unordered reassembly of the string data.

[0140] In one optional implementation, a display instruction is parsed from the reconstructed complete string data, and the display rendering operation corresponding to the display instruction is executed, including:

[0141] The recombined complete string data is formatted to determine the separation rules between the structured fields that carry display instructions and the data fields that carry display content.

[0142] The recombined complete string data is segmented according to the segmentation rules, and the instruction type identifier, display position parameter, and display attribute parameter in the structured fields are extracted. The text content to be displayed in the data fields is also extracted.

[0143] Based on the instruction type identifier, a preset mapping table of instruction types to rendering functions is queried to determine the display rendering function corresponding to the instruction type identifier;

[0144] The display position parameters, the display attribute parameters, and the text content to be displayed are input into the display rendering function, which triggers the display rendering function to call the driver interface of the display hardware.

[0145] After the display hardware completes the data refresh from the display hardware frame buffer to the display screen, the text content to be displayed is displayed on the display screen in accordance with the display position parameters and the display attribute parameters.

[0146] Upon receiving the reconstructed complete string data, the format recognition module immediately initiates structural parsing of the data. This module identifies the data format identifier by scanning the first 128 bytes of the string; this identifier is marked with a fixed magic value. Taking the string "0xFE45|TYPE:TEXT_RENDER|POS:100,200|ATTR:FONT=16,COLOR=255|DATA:Welcome to the display system" as an example, recognizing the starting identifier 0xFE45 confirms that this is a standard display instruction data packet. The format recognition module continues to analyze the string's delimiters, identifying the vertical bar as the first-level delimiter used to separate different functional fields, the colon as the second-level delimiter used to separate field names and values, and the comma as the third-level delimiter used to separate multiple parameter values ​​within the same field.

[0147] After the splitting rules are determined, the field splitter begins parsing the complete string data segment by segment. The splitter maintains a state machine, initially in the state of SCAN_START, which transitions to FIELD_BOUNDARY when the first vertical bar symbol is encountered. The splitter scans from the beginning of the string, dividing the content after the 0xFE45 marker into multiple independent fields based on the vertical bar symbols. The first field, "TYPE:TEXT_RENDER", is extracted and split by the splitter into the field name "TYPE" and the field value "TEXT_RENDER" using a colon. This value is stored in the instruction type identifier variable. The second field, "POS:100,200", undergoes the same splitting process. The content after the colon is then parsed into two values ​​using a comma separator, which are assigned to the horizontal and vertical coordinate variables of the display position parameter, respectively. The values ​​are 32-bit unsigned integers.

[0148] The extraction process for display attribute parameters requires handling more complex nested structures. The field "ATTR:FONT=16,COLOR=255", after being separated by colons, contains multiple key-value pairs. The attribute parser uses the equals sign as the key-value separator, parsing "FONT=16" into the attribute name FONT and the attribute value 16, and "COLOR=255" into the attribute name COLOR and the attribute value 255. These attribute parameters are stored in an attribute parameter hash table, where the keys are the attribute name strings and the values ​​are the corresponding numeric or enumeration types. The attribute parser is also responsible for data type conversion, converting string-based numeric values ​​to integer variables and color values ​​to 32-bit RGBA color codes.

[0149] The extraction of data fields employs a special processing mechanism. Because the text content to be displayed may contain characters identical to the delimiters, upon recognizing the "DATA:" marker, all content following this marker until the end of the string is extracted as the text content to be displayed. The extractor performs character encoding detection on the text content, supporting multiple encoding formats such as UTF-8, GBK, and Unicode. Taking "Welcome to the Display System" as an example, after detecting UTF-8 encoding, the extractor converts the byte stream into an internally unified Unicode character array, with each Chinese character occupying 2 bytes of storage space.

[0150] The mapping table between instruction types and rendering functions is established during system initialization. This table uses a hash table data structure for fast lookup and stores 12 common instruction types. When the instruction type is identified as "TEXT_RENDER", the query module calculates the index value using a hash function and retrieves the corresponding rendering function pointer from the mapping table. The function signature of the rendering function is defined to accept three parameters: a positional parameter structure, an attribute parameter hash table, and a text content character array. The query module also verifies the validity of the instruction type. If the query result is empty, it returns the default no-operation rendering function to prevent the system from crashing due to illegal instructions.

[0151] When the rendering function is called, it performs a series of preparatory tasks. Upon receiving the x-coordinate 100 and y-coordinate 200, the function checks if these coordinate values ​​are within the valid range of the display screen. Assuming the display screen resolution is 800 x 600 pixels, the coordinate verification module confirms that 100 and 200 are both within the valid range. The rendering function reads the font size parameter 16 from the attribute parameter hash table, which indicates a font height of 16 pixels, and then loads the corresponding font data from the font library. The font data is stored in bitmap format, with each character corresponding to a 16 x 16 bitmap array. The color parameter 255 is processed and converted to a complete RGBA value, where 255 is interpreted as the red channel value, the green and blue channels default to 0, and the transparency channel defaults to 255, indicating complete opacity.

[0152] The rendering function internally creates a graphics drawing context object, which encapsulates calls to the display hardware driver interface. The drawing context first locks the frame buffer to prevent other threads from accessing display memory simultaneously. The frame buffer is a contiguous memory area, equal in size to the screen resolution multiplied by the number of bytes per pixel. At an 800x600 resolution and 32-bit color depth, the frame buffer occupies 1,920,000 bytes of memory. The rendering function processes each character in the text to be displayed. For each Chinese character in "Welcome to the Display System," it reads the corresponding 16x16 dot matrix data from the font library and writes the pixels with a value of 1 into the corresponding positions in the frame buffer according to the color parameters.

[0153] When writing to the framebuffer, the exact memory address of each pixel needs to be calculated. For a starting position of coordinates 100, 200, the memory address corresponding to the first pixel of the first character is calculated as follows: base address plus the ordinate multiplied by the screen width multiplied by the number of bytes per pixel, plus the x-coordinate multiplied by the number of bytes per pixel. Each pixel occupies 4 bytes to store the values ​​of the red, green, blue, and alpha channels respectively. The rendering function writes the bitmap data of all characters to the framebuffer in a left-to-right, top-to-bottom order, leaving a 2-pixel spacing between characters to improve readability.

[0154] After the data in the frame buffer is written, the rendering function calls the refresh method of the display hardware driver interface. The driver interface sends a refresh command to the display controller, which then initiates DMA transfer to move the data in the frame buffer to the display screen's internal memory. This process uses double buffering technology; while the content in the front buffer is being displayed, the back buffer receives new rendering data. After the DMA transfer is complete, a vertical synchronization signal is triggered, and the display controller displays the new data on the screen in the next refresh cycle. The refresh rate is set to 60 Hz, meaning the screen content is updated every 16.67 milliseconds.

[0155] In the final stage of the entire display process, the red text "Welcome to the Display System" begins to appear on the screen at a position of x-coordinate 100, y-coordinate 200. The font size is 16 pixels high, the characters are clearly visible, and the position is accurate. After the display is completed, the timestamp of this rendering operation and the display area information are recorded for subsequent display updates and partial refresh optimizations.

[0156] The serial port screen GUI adaptive resolution rendering system of this invention includes:

[0157] The first unit is used to acquire the string data to be transmitted and determine the total length of the string data;

[0158] The second unit is used to segment the string data according to a preset upper limit for data segment length, to obtain at least one data segment, and to generate a unique sequence identifier for each data segment;

[0159] The third unit, based on the data frame format restrictions of the bus protocol, embeds the sequence identifier, the total length of the string data, and the effective data length of the current segment into the frame structure of each data segment to obtain a data frame carrying segment metadata, wherein the segment metadata is used by the receiving end to identify segment boundaries and reassembly order;

[0160] The fourth unit is used to sequentially send the data frames carrying segmented metadata via the bus, each data frame containing valid data of a data segment;

[0161] The fifth unit is used to dynamically allocate a buffer for storing complete string data at the receiving end based on the sequence identifier and total length information in the received data frame, and to reassemble each data segment into the corresponding position in the buffer according to the sending order based on the sequence identifier, so as to obtain the reassembled complete string data;

[0162] The sixth unit is used to parse the display instruction based on the recombined complete string data and execute the display rendering operation corresponding to the display instruction.

[0163] A third aspect of the present invention provides an electronic device, comprising:

[0164] processor;

[0165] Memory used to store processor-executable instructions;

[0166] The processor is configured to invoke instructions stored in the memory to execute the aforementioned method.

[0167] A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the aforementioned method.

[0168] This invention can be a method, apparatus, system, and / or computer program product. The computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of the invention.

[0169] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions 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 method for adaptive resolution rendering of a serial port screen GUI, characterized in that, include: Obtain the string data to be transmitted and determine the total length of the string data; The string data is segmented according to a preset upper limit for data segment length to obtain at least one data segment, and a unique sequence identifier is generated for each data segment; Based on the data frame format limitations of the bus protocol, the sequence identifier, the total length of the string data, and the effective data length of the current segment are embedded in the frame structure of each data segment to obtain a data frame carrying segment metadata, including: Obtain the positions of fixed fields used to carry control information and variable fields used to carry valid data in the data frame structure specified by the bus protocol; In the fixed field positions, the storage locations for the sequence identifier, the total length of the string data, and the effective data length of the current segment are allocated sequentially according to a predetermined byte order, and the number of bytes occupied and the starting offset position are determined for each segment metadata item; The sequence identifier corresponding to the current data segment, the total length of the string data, and the effective data length of the current data segment are encoded into the fixed field position according to the byte order and the starting offset position to obtain the segment metadata field; Fill the variable field position with the valid data of the current data segment, and the filling length is consistent with the valid data length of the current data segment. The segmented metadata field is combined with the padded valid data to obtain a data frame carrying segmented metadata that conforms to the bus protocol data frame format. The segmented metadata is used by the receiving end to identify segment boundaries and reassembly order. The data frames carrying segmented metadata are transmitted sequentially via the bus, each frame containing valid data for one data segment; At the receiving end, based on the sequence identifier and total length information in the received data frame, a buffer for storing complete string data is dynamically allocated, and each data segment is reassembled into the corresponding position in the buffer according to the sending order based on the sequence identifier, to obtain the reassembled complete string data; The display instruction is parsed from the recombined complete string data, and the display rendering operation corresponding to the display instruction is executed. The step of encoding the sequence identifier corresponding to the current data segment, the total length of the string data, and the effective data length of the current data segment into the fixed field position according to the byte order and the starting offset position, yields the segment metadata field, including: The number of encoded bytes for each metadata item is determined based on the numerical ranges of the sequence identifier, the total length of the string data, and the effective data length of the current data segment. Based on the number of encoded bytes, a fixed byte order rule is used to convert the value of each metadata item into a corresponding byte sequence, wherein the fixed byte order rule ensures that the encoding and decoding order of multi-byte values ​​is consistent between the sending end and the receiving end; Obtain the starting offset position allocated to the sequence identifier, the total length of the string data, and the effective data length of the current segment; According to the byte order, the byte sequence corresponding to the sequence identifier is written to the starting offset position of the sequence identifier, the byte sequence corresponding to the total length of the string data is written to the starting offset position of the total length of the string data, and the byte sequence corresponding to the effective data length of the current data segment is written to the starting offset position of the effective data length of the current segment, so as to obtain the segmented metadata field that is continuously or discretely distributed in the fixed field position.

2. The method according to claim 1, characterized in that, The string data is segmented according to a preset upper limit for data segment length to obtain at least one data segment, and a unique sequence identifier is generated for each data segment, including: Obtain the maximum number of bytes used to carry valid data in the single-frame data frame structure specified by the bus protocol. Based on the maximum number of bytes and the fixed number of bytes required to carry segmented metadata, obtain the net number of bytes that a single frame can use to carry string data segments. The net number of bytes is determined as the upper limit of the data segment length, and the total number of segments after the string data is segmented according to the upper limit of the data segment length is calculated; Based on the storage location offset of the string data in the buffer, data segments with a length not exceeding the upper limit of the data segment length are sequentially extracted as data segments, and the starting position offset and actual data length of each data segment in the string data are recorded, wherein the starting position offset is used by the receiving end to locate the reassembly position of the data segment in the complete string data; The encoding bit width of the sequence identifier is determined based on the total number of segments, and an incremental and unique sequence identifier is assigned to each data segment according to the truncation order of the data segments, so that the sequence identifier and the starting position offset are uniquely mapped.

3. The method according to claim 1, characterized in that, At the receiving end, based on the sequence identifier and total length information in the received data frame, a buffer for storing complete string data is dynamically allocated. Then, according to the sequence identifier, each data segment is reassembled into its corresponding position in the buffer in the order of transmission, resulting in the reassembled complete string data, including: Based on the total length of the string data extracted from the received data frame, allocate a contiguous buffer with a capacity matching the total length in the storage space of the receiving end, and initialize the write position tracking structure of the buffer; Extract the sequence identifier and valid data length of the current segment from the segment metadata field of the received data frame, and extract the valid data of the current data segment from the variable field position of the data frame; Based on the sequence identifier and the preset mapping rule from sequence identifier to buffer position, the write start position of the current data segment in the buffer is calculated, and the write end position is determined according to the effective data length of the current segment; The valid data of the current data segment is written to the buffer in byte order, starting from the write start position, until the write end position; The write position tracking structure marks the buffer area corresponding to the current data segment as having been written. When the write position tracking structure indicates that the entire area of ​​the buffer has been written, the data stored in the buffer is determined as the reconstructed complete string data.

4. The method according to claim 3, characterized in that, Based on the sequence identifier and the preset mapping rule from sequence identifier to buffer position, the write start position of the current data segment in the buffer is calculated, and the write end position is determined according to the effective data length of the current segment, including: Obtain the upper limit of the data segment length agreed upon by both the sender and receiver; The sequence identifier is converted into an index value. The step size is the upper limit of the data segment length. The number of steps is the index value. The byte offset of the current data segment relative to the starting address of the buffer is calculated by accumulating the positions. Check whether the byte offset is less than the total buffer capacity allocated based on the total length of the string data. If the byte offset is less than the total buffer capacity, use the buffer start address as a reference and perform address offset according to the byte offset to obtain the write start position of the current data segment in the buffer. Based on the write start position and the effective data length value of the current segment, the write end position of the current data segment in the buffer is obtained, wherein the write end position indicates the next storage location of the last byte of the current data segment in the buffer; Verify that the write termination position does not exceed the storage boundary allocated by the buffer based on the total length value of the string data.

5. The method according to claim 1, characterized in that, Based on the recombined complete string data, a display instruction is parsed, and the display rendering operation corresponding to the display instruction is executed, including: The recombined complete string data is formatted to determine the separation rules between the structured fields that carry display instructions and the data fields that carry display content. The recombined complete string data is segmented according to the segmentation rules, and the instruction type identifier, display position parameter, and display attribute parameter in the structured fields are extracted. The text content to be displayed in the data fields is also extracted. Based on the instruction type identifier, a preset mapping table of instruction types to rendering functions is queried to determine the display rendering function corresponding to the instruction type identifier; The display position parameters, the display attribute parameters, and the text content to be displayed are input into the display rendering function, which triggers the display rendering function to call the driver interface of the display hardware. After the display hardware completes the data refresh from the display hardware frame buffer to the display screen, the text content to be displayed is displayed on the display screen in accordance with the display position parameters and the display attribute parameters.

6. A serial port screen GUI adaptive resolution rendering system, used to implement the method as described in any one of claims 1-5, characterized in that, include: The first unit is used to acquire the string data to be transmitted and determine the total length of the string data; The second unit is used to segment the string data according to a preset upper limit for data segment length, to obtain at least one data segment, and to generate a unique sequence identifier for each data segment; The third unit, based on the data frame format restrictions of the bus protocol, embeds the sequence identifier, the total length of the string data, and the effective data length of the current segment into the frame structure of each data segment to obtain a data frame carrying segment metadata, wherein the segment metadata is used by the receiving end to identify segment boundaries and reassembly order; The fourth unit is used to sequentially send the data frames carrying segmented metadata via the bus, each data frame containing valid data of a data segment; The fifth unit is used to dynamically allocate a buffer for storing complete string data at the receiving end based on the sequence identifier and total length information in the received data frame, and to reassemble each data segment into the corresponding position in the buffer according to the sending order based on the sequence identifier, so as to obtain the reassembled complete string data; The sixth unit is used to parse the display instruction based on the recombined complete string data and execute the display rendering operation corresponding to the display instruction.

7. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 5.