Embedded device webpage end data generation and analysis method
By using data encoding functions in embedded devices to convert web page data into binary data packets, and then using DataView objects in the browser to parse them into JavaScript variables, the problem of high resource consumption in data transmission in embedded devices is solved, and more efficient data processing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHUHAI HUGE IC CO LTD
- Filing Date
- 2026-01-12
- Publication Date
- 2026-05-01
AI Technical Summary
Embedded devices consume significant resources when transmitting web page data, especially when processing string-formatted data interactions, which consumes the device's limited computing resources.
A preset data encoding function is used to convert web page data into binary data packets with the same size and structure as the embedded device's C structure, and then transmitted via the HTTP protocol. The DataView object is used to parse the data into standard JavaScript variables on the browser side, eliminating the need for string processing on the embedded device.
It significantly reduces the computational resource consumption of embedded devices, improves data transmission efficiency, and reduces the consumption of limited resources.
Smart Images

Figure CN121958686A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of embedded device data processing technology, and in particular to a method for generating and parsing web-based data for embedded devices. Background Technology
[0002] Built-in web interfaces in embedded devices are typically used for device configuration, monitoring, and control. These interfaces need to retrieve data from the device to update their content and may also need to receive data from the device for configuration or control. Embedded devices typically have very limited on-chip resources, especially those based on RTOS. Traditional web data interaction is based on fixed-format strings, requiring significant on-chip resources for processing. Implementing web functionality on embedded devices requires running a web server on the device. The web server handles requests from client browsers, including returning web pages, returning data, or receiving returned data. Currently, there are two main types of data-interactive web pages: one is based on traditional static HTML pages, where updating page data involves pre-populating the static page with server scripts before sending it to the client's browser. Retrieving data from the client is done through HTML... <form>The submission function of the table element sends the data back to the server. Another approach is the use of modern dynamic HTML pages, where JavaScript is used to populate dynamically updated content on the browser side. Data can be sent back using HTML form elements or by customizing the return logic in JavaScript, using JSON arrays for data interaction.
[0003] Traditional HTML-based web pages are highly compatible with browsers, and browsers don't need to support JavaScript to achieve data interaction. However, this approach requires significant string processing on the web server to populate the parameter values to be displayed and process the string data submitted by form elements. Modern dynamic web pages primarily rely on JavaScript. The interaction between these pages and the server mainly depends on application interfaces based on the HTTP protocol. Data interaction can use JSON array format natively supported by JavaScript, or HTML form submission string format. Compared to the first approach, the web server on embedded devices does not need to dynamically modify the web page content beforehand. Only some processing functions need to be added to handle JavaScript data retrieval and submission requests. The required computational workload is relatively reduced, and the code development for both the web page and the server is simpler than the first approach. However, because the transmitted data still uses string format, it still consumes computing resources on the embedded device. Summary of the Invention
[0004] This invention provides a method for generating and parsing web page data in embedded devices, which can solve the technical problem of high resource consumption in the processing of web page transmission data by embedded devices in the prior art. The technical solution is as follows:
[0005] In a first aspect, embodiments of the present invention provide a method for generating and parsing web page data on an embedded device, including:
[0006] Obtain the size and structure of the embedded device's C structure, as well as the data to be transmitted from the web page;
[0007] A preset data encoding function is used to convert the data to be transmitted from the web page into a binary data packet with the same size and structure as the embedded device's C structure; the binary data packet is then sent back to the corresponding embedded device.
[0008] After acquiring the data transmitted from the embedded device, a preset data parsing function is used to convert the data transmitted from the embedded device into standard JavaScript variables.
[0009] In some embodiments of the present invention, the step of using a preset data encoding function to convert the data to be transmitted from the web page into a binary data packet with the same size and structure as the embedded device C structure includes:
[0010] Use an ArrayBuffer() object to generate a buffer with the same size and construction as the embedded device's C structure;
[0011] Based on the construction, type, offset, and end order of the embedded device C structure, the various Set methods contained in the DataView() object are called to fill the buffer;
[0012] The data to be transmitted from the web page is filled into the buffer to generate the binary data packet.
[0013] In some embodiments of the present invention, the step of using a preset data parsing function to convert data transmitted from an embedded device into standard JavaScript variables includes:
[0014] Obtain binary data from the embedded device, wherein the binary data type is an ArrayBuffer buffer;
[0015] Based on the construction, type, offset, and end order of the binary data, various Get methods contained in the DataView() object are called to convert the data in the ArrayBuffer buffer into standard JavaScript variables.
[0016] In some embodiments of the present invention, acquiring data transmitted from the embedded device includes:
[0017] It calls JavaScript standard resources to obtain APIs and sends data requests to the web server of the corresponding embedded device via the HTTP protocol.
[0018] The data is retrieved from the embedded device according to the data request.
[0019] Secondly, the present invention also provides a data transmission method for an embedded device, comprising:
[0020] Transmit C language structure data from the embedded device directly to the browser in raw binary format;
[0021] The browser is controlled to parse the raw binary format data using any of the methods described in the embedded device webpage data generation and parsing methods above.
[0022] In some embodiments of the present invention, the raw binary format data is data that has not undergone conversion processing by the embedded device.
[0023] Thirdly, the present invention also provides a data receiving method for an embedded device, comprising:
[0024] Control the embedded device to obtain data feedback requests sent from the web client;
[0025] According to the data feedback request, obtain the binary data packet received by conversion through the preset data encoding function in the embedded device web page data generation and parsing method described above;
[0026] The binary data packet is converted into a standard C structure using standard C data type conversion.
[0027] Fourthly, the present invention also provides an embedded device web page data generation and parsing apparatus, comprising:
[0028] The acquisition module is used to obtain the size and structure of the embedded device's C structure and the data to be transmitted from the web page.
[0029] The encoding module is used to convert the data to be transmitted from the web page into a binary data packet with the same size and structure as the C structure of the embedded device using a preset data encoding function; and to send the binary data packet back to the corresponding embedded device.
[0030] The parsing module is used to convert the data transmitted from the embedded device into standard JavaScript variables using a preset data parsing function after the data is received.
[0031] Fifthly, the present invention also provides an electronic device, comprising: a processor and a memory;
[0032] The memory stores a computer-readable program that can be executed by the processor;
[0033] When the processor executes the computer-readable program, it implements the steps in the embedded device web page data generation and parsing method as described in any of the preceding claims, and / or processes the steps in the embedded device data transmission method as described in any of the preceding claims, and / or the steps in the embedded device data reception method as described in the preceding claims.
[0034] Sixthly, the present invention also provides a computer-readable storage medium storing one or more programs that can be executed by one or more processors to implement the steps in the embedded device web page data generation and parsing method as described in any of the preceding claims, and / or process the steps in the embedded device data transmission method as described in any of the preceding claims, and / or the steps in the embedded device data reception method as described in the preceding claims.
[0035] The beneficial effects of the technical solutions provided by some embodiments of the present invention include at least the following: First, the size and structure of the embedded device's C structure and the data to be transmitted from the web page are obtained; then, a preset data encoding function is used to convert the data to be transmitted from the web page into a binary data packet with the same size and structure as the embedded device's C structure; the binary data packet is then sent back to the corresponding embedded device; after obtaining the data transmitted from the embedded device, a preset data parsing function is used to convert the data transmitted from the embedded device into standard JavaScript variables. By directly parsing and generating the binary data of the C language data structure in the embedded device on the browser side, and using binary format data to interact with the web server of the embedded device, the process of converting data between the embedded device and JSON strings is eliminated, significantly reducing the occupation of the limited computing resources of the embedded device. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 A system architecture diagram of an embodiment of the embedded device web page data generation and parsing method provided by the present invention;
[0038] Figure 2 A flowchart illustrating an embodiment of the embedded device web page data generation and parsing method provided by the present invention;
[0039] Figure 3 for Figure 2 A flowchart of a method according to an embodiment of step S202;
[0040] Figure 4 for Figure 2 A flowchart of a method according to an embodiment of step S203;
[0041] Figure 5 A flowchart illustrating an embodiment of the data transmission method for an embedded device provided by the present invention;
[0042] Figure 6 A flowchart illustrating an embodiment of the data receiving method for an embedded device provided by the present invention;
[0043] Figure 7 This is a schematic diagram of an embodiment of the embedded device web page data generation and parsing device provided by the present invention;
[0044] Figure 8 This is a schematic diagram of the operating environment of an embodiment of the electronic device provided by the present invention. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0046] It should be noted that the data generation method for embedded device-webpage interaction provided in this application is generally executed by the terminal device, and correspondingly, the data generation device for embedded device-webpage interaction is generally located in the terminal device.
[0047] Figure 1 An exemplary system architecture is shown that can be applied to the data generation method or apparatus for data generation in the interaction between an embedded device and a web page in this application.
[0048] like Figure 1 As shown, the system architecture may include: terminal device 101 and server 102. Terminal device 101 and server 102 can communicate via a network, which serves as the medium for providing communication links between the various units. The network may include various types of wired or wireless communication links, such as: wired communication links including fiber optic cables, twisted-pair cables, or coaxial cables; and wireless communication links including Bluetooth communication links, Wi-Fi communication links, or microwave communication links.
[0049] It should be noted that the terminal device 101 and the server 102 can be either hardware or software. When the terminal device 101 and the server 102 are hardware, they can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the terminal device 101 and the server 102 are software, they can be implemented as multiple software programs or software modules (for example, to provide distributed services), or as a single software program or software module; no specific limitations are made here.
[0050] The terminal device of this application can be equipped with various communication client applications, such as video recording applications, video playback applications, voice interaction applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0051] A terminal device can be either hardware or software. When the terminal device is hardware, it can be various terminal devices with a display screen, including but not limited to smartphones, tablets, laptops, and desktop computers. When the terminal device is software, it can be installed on the terminal devices listed above. It can be implemented as multiple software programs or software modules (e.g., used to provide distributed services) or as a single software program or software module; no specific limitation is made here.
[0052] When the terminal device is hardware, it can also be equipped with a display device and a camera. The display device can be any device capable of displaying information, and the camera is used to capture video streams. For example, the display device can be a cathode ray tube display (CR), a light-emitting diode display (LED), an e-ink screen, a liquid crystal display (LCD), a plasma display panel (PDP), etc. Users can use the display device on the terminal device to view displayed text, images, videos, and other information.
[0053] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is for illustrative purposes only. Depending on implementation needs, there can be any number of terminal devices, networks, and servers.
[0054] Embedded device applications are typically developed using C, and application data and various parameter configurations are usually stored using C structures. Normally, when a webpage communicates with a device via a browser, it uses JSON arrays or fixed-format strings. When an embedded device needs to send data to the browser, these structures must first be converted into JSON arrays or fixed-format strings before being sent to the browser for parsing by the webpage's JavaScript code. Similarly, when a webpage submits data, it directly submits JSON arrays or fixed-format strings submitted via HTML elements to the embedded device. The device then processes these strings, extracts the variable values, and passes them to C functions for further processing.
[0055] Processing and generating these strings requires a certain amount of system CPU resources and cache. Most embedded devices have quite limited computing resources, and when transmitting large amounts of data, it may affect the execution of other applications. A C language struct is simply a contiguous block of memory containing the variables initially defined in the struct. JavaScript supports parsing and generating the same data structures as C language structs, thus saving the overhead of string processing on embedded devices.
[0056] The following will be combined with the appendix Figure 2 This application provides a detailed description of the embedded device webpage data generation and parsing method provided in its embodiments. The embedded device webpage data generation and parsing device in these embodiments may be... Figure 1 The terminal device shown.
[0057] Please see Figure 2 This is a flowchart illustrating a method for generating and parsing web-based data on an embedded device, as provided in this application embodiment. Figure 2 As shown, the method described in this application embodiment may include the following steps:
[0058] S201. Obtain the size and structure of the embedded device's C structure and the data to be transmitted from the web page.
[0059] It's important to note that the data to be transmitted on the webpage is data generated by the JavaScript program logic within the web browser and intended for transmission to the embedded device. Examples include new configuration values entered by the user in a webpage form (such as a new temperature setting), user-clicked control commands (such as "start," "stop," or "reset"), and certain parameters calculated by the webpage frontend. Initially, in JavaScript, this data consists of ordinary JavaScript variables, whose values are obtained through DOM manipulation (such as `document.getElementById("setTemperature").value`) or program logic.
[0060] S202. Using a preset data encoding function, the data to be transmitted from the web page is converted into a binary data packet with the same size and structure as the embedded device's C structure; the binary data packet is then sent back to the corresponding embedded device.
[0061] By obtaining the size and structure of the embedded device's C structure and using a data encoding function to convert the data transmitted from the web page into binary data packets with the same size and structure as the embedded device's C structure, the problem of the embedded device consuming resources due to the need for the device to recalculate and convert the data after it is sent back to the embedded device is avoided.
[0062] In one specific embodiment of the present invention, please refer to Figure 3 ,include:
[0063] S301. Use an ArrayBuffer() object to generate a buffer with the same size and structure as the embedded device's C structure;
[0064] S302. Based on the construction, type, offset, and end order of the embedded device C structure, call the various Set methods contained in the DataView() object to fill the buffer;
[0065] S303. Fill the data to be transmitted from the web page into the buffer to generate the binary data packet.
[0066] It should be noted that the data to be sent is converted into an ArrayBuffer object using the arrayBuffer() method;
[0067] The data encoding function is responsible for converting the configuration parameter data that the web page needs to send to the embedded device into a binary data packet with the same size and structure as the C language structure inside the embedded device. An ArrayBuffer() object is used to generate a buffer with the same memory size as the C language data structure in the embedded device. Based on the structure, type, offset, and endianness of this data structure, various Set methods contained in the DataView() object are called to fill the buffer, and the data to be sent back to the embedded device is added, generating the binary data packet to be sent back.
[0068] It should be noted that in some embodiments, TypedArray (such as Uint8Array, Int16Array) can also be used to combine or parse data.
[0069] S203. After obtaining the data transmitted from the embedded device, a preset data parsing function is used to convert the data transmitted from the embedded device into standard JavaScript variables.
[0070] In one specific embodiment of the present invention, please refer to Figure 4 ,include:
[0071] S401. Obtain binary data from the embedded device, wherein the binary data type is an ArrayBuffer buffer;
[0072] S402. Based on the structure, type, offset, and end order of the binary data, call the various Get methods contained in the DataView() object to convert the data in the ArrayBuffer buffer into standard JavaScript variables.
[0073] It should be noted that the data interpretation function is responsible for converting the binary data obtained by the web page from the embedded device into a variable type that JavaScript can process.
[0074] It's worth noting that JavaScript offers two objects specifically for handling binary data: ArrayBuffer and DataView. These objects have been supported since JavaScript ES2015, and should generally work correctly with browsers released after 2015. ArrayBuffer can be used to construct an empty binary buffer of a specified size, which can be used in network request tools like fetch to retrieve server response data in binary format. DataView is primarily used for handling binary data, allowing you to retrieve variables of a specified size from a specified position in an ArrayBuffer or insert variables of a specified size into a specified position.
[0075] It should be noted that, based on the definition of the C structure (variable type, order, offset, byte order), the values of each variable are parsed from the correct offset position using DataView's getInt8(), getUint16(), and other methods.
[0076] In some embodiments of the present invention, acquiring data transmitted from the embedded device includes:
[0077] It calls JavaScript standard resources to obtain APIs and sends data requests to the web server of the corresponding embedded device via the HTTP protocol.
[0078] The data is retrieved from the embedded device according to the data request.
[0079] In this embodiment, the response is first obtained using the fetch API. Then, the response body is read into a binary buffer (ArrayBuffer) using the response.arrayBuffer() method. A DataView object is then created to manipulate this buffer. Based on the definition of the C structure in the embedded device (variable type, order, offset, byte order), the values of each variable are parsed from the correct offset using DataView's getInt8(), getUint16(), and other methods. This embodiment leverages JavaScript's binary data processing capabilities (ArrayBuffer and DataView) to enable the browser to directly parse and generate structure data that is completely consistent with the C language program in the embedded device's memory. This eliminates the need for the embedded device to perform data conversion between data and JSON strings, significantly reducing the consumption of the embedded device's limited computing resources.
[0080] In one specific embodiment of the present invention, sensor information is obtained by accessing an embedded device through a browser. The C structure defined in the device is as follows:
[0081] struct weather_info {
[0082] int 8 temp;
[0083] uint8 humidity;
[0084] uint16 wind_dir;
[0085] uint8 wind_spd;
[0086] uint8 uv_idx;
[0087] uint8 pm10;
[0088] uint8 pm25;
[0089] }
[0090] The total data size is 8 bytes, but if it needs to be converted to standard JSON format:
[0091] {"temp": 31, "humidity": 72, "wind_dir": 271, "wind_spd": 22, "uv_idx": 7, "pm10": 15, "pm25": 17}
[0092] The embedded device converted 8 bytes of data into a 126-byte JSON string, which contains a total of 126 characters.
[0093] However, if the data of this array is sent directly, the transmission volume is only 8 bytes, and there is no need to convert to JSON string, which can greatly save the resource consumption of embedded devices.
[0094] However, web pages cannot directly convert this data into a format that JavaScript can process for display. JavaScript's default `JSON.parse()` is for standard JSON strings. Therefore, we need to use `ArrayBuffer` and `DataView` objects to process this binary data. First, the method for obtaining the binary data is the same as a normal JavaScript HTTP API access: using the standard `fetch` API to obtain the correct HTTP response, and then using an `ArrayBuffer` object to retrieve the binary data. Finally, the obtained binary buffer is passed to a `DataView` object for processing.
[0095] JavaScript code example:
[0096] const resp = await fetch( <path>, {method: "GET", header:"application / octet-stream"});
[0097] if (resp.ok) {
[0098] let buffer = await resp.arrayBuffer();
[0099] let data = new DataView(buffer);
[0100] }
[0101] The `arrayBuffer` object has a `byteLength` property, which is used to perform a simple data integrity check by comparing it with the size of the structure defined on the embedded device. The `DataView` object is used to parse the data structure and extract the data contained within it.
[0102] DataView objects support parsing and modifying various data types, including int8, int16, int32, int64, uint8, uint16, uint32, uint64, float16, float32, and float64. They support both big-endian and little-endian memory order and can be used with embedded devices on different CPU architectures.
[0103] JavaScript code example, parsing the C struct mentioned in the previous example:
[0104] let temp = data.getInt8(0);
[0105] let humidity = data.getUint8(1);
[0106] let wind_dir = data.getUint16(2, true); / / Specifies little-endian memory order.
[0107] let wind_spd = data.getUint8(4);
[0108] let uv_idx = data.getUint8(5);
[0109] let pm10 = data.getUint8(6);
[0110] let pm25 = data.getUint8(7);
[0111] By specifying an offset address, methods within the DataView object are used to parse the original C language-defined struct. The DataView object can also be used to generate data structures identical to C language structs, which can be directly read on embedded devices without any additional parsing functions. Simply perform a type cast on the received data to the corresponding struct type to directly access the internal data. Below is a code example demonstrating how to reconstruct the memory structure of the C struct mentioned above using JavaScript:
[0112] let weatherInfoMem = new ArrayBuffer(8); / / Create an empty 8-byte buffer
[0113] let Cstruct = new DataView(weatherInfoMem); / / Populate data using a DateView object.
[0114] Cstruct.setUint8(0, 31);
[0115] Cstruct.setUint8(1, 72);
[0116] Cstruct.setUint16(2, 271, true); / / Specifies little-endian memory order
[0117] Cstruct.setUint8(4, 22);
[0118] Cstruct.setUint8(5, 7);
[0119] Cstruct.setUint8(6, 15);
[0120] Cstruct.setUint8(7, 17);
[0121] Then, the cached weatherInfoMem is sent back to the embedded device, and after a type cast, the data inside can be directly parsed out.
[0122] This invention also provides a data transmission method for an embedded device; please refer to [link / reference]. Figure 5 ,include:
[0123] S501: Transmit the C language structure data from the embedded device to the browser in raw binary format.
[0124] S502. Control the browser to parse the original binary format data using the method in the above-mentioned embedded device web page data generation and parsing method.
[0125] It's important to note that the raw binary data organized as C language structures, waiting to be sent to the webpage from the embedded device's memory, includes things like sensor readings (temperature, humidity, pressure), device status information (on / off status, operating mode, error codes), and configuration parameters (device name, IP address, threshold settings). In the device's memory, this is a continuous sequence of bytes; it's not a JSON string, XML, or any other text format that needs parsing, but rather a direct memory image of the C language structure variables. On the embedded device side, without any string serialization / deserialization, the memory image of the C language structure is directly sent as the HTTP response body, avoiding resource consumption caused by data conversion within the embedded device. Simultaneously, on the browser side, the DataView object parses the data from the ArrayBuffer based on predefined offsets and data types that match the device-side C language structures, and accurately reads the data based on data mapping rules. Specifically, the rules define the correspondence between the browser-side JavaScript DataView operations and the device-side C language structures (including field order, type, offset, and byte order). The specific form of these rules is not limited here.
[0126] This invention also provides a data receiving method for an embedded device; please refer to [link / reference]. Figure 6 ,include:
[0127] S601. Obtain the data return request sent by the web client;
[0128] S602. Based on the data feedback request, obtain the binary data packet converted by the preset data encoding function in the above-mentioned embedded device web page data generation and parsing method;
[0129] S603. Convert the binary data packet into a standard C structure by using a preset C data type conversion.
[0130] In this embodiment, the data acquired by the embedded device is binary format data processed by the web page. The embedded device only needs to perform simple conversion and processing logic to read the values contained in the structure and configure or control the device.
[0131] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0132] Please see Figure 7 This illustration shows a schematic diagram of an embedded device web page data generation and parsing apparatus provided in an exemplary embodiment of this application, hereinafter referred to as apparatus 7. Apparatus 7 can be implemented as all or part of a terminal device through software, hardware, or a combination of both. Apparatus 7 includes:
[0133] The acquisition module 710 is used to acquire the size and structure of the embedded device's C structure and the data to be transmitted from the web page.
[0134] The encoding module 720 is used to convert the data to be transmitted from the web page into a binary data packet with the same size and structure as the embedded device C structure using a preset data encoding function; and to send the binary data packet back to the corresponding embedded device.
[0135] The parsing module 730 is used to convert the data transmitted from the embedded device into standard JavaScript variables using a preset data parsing function after acquiring the data.
[0136] This application also provides a computer storage medium that can store multiple instructions, which are adapted to be loaded and executed by a processor as described above. Figure 2 , and / or Figure 5 The method steps of the illustrated embodiment can be found in the following documentation for detailed execution. Figure 2 , and / or Figure 3 The specific details of the illustrated embodiments will not be elaborated here.
[0137] This application also provides a computer program product storing at least one instruction, which is loaded and executed by the processor to implement the steps in the embedded device web page data generation and parsing method as described in the above embodiments, and / or process the steps in the embedded device data transmission method as described in any of the above embodiments, and / or the steps in the embedded device data reception method as described above.
[0138] Please see Figure 8 This document provides a schematic diagram of the structure of a terminal device according to an embodiment of this application. Figure 8 As shown, the terminal device 800 may include: at least one processor 801, at least one network interface 804, a user interface 803, a memory 805, and at least one communication bus 802.
[0139] The communication bus 802 is used to enable communication between these components.
[0140] The user interface 803 may include a display screen and a camera. Optionally, the user interface 803 may also include a standard wired interface and a wireless interface.
[0141] The network interface 804 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).
[0142] The processor 801 may include one or more processing cores. The processor 801 connects to various parts within the terminal device 800 using various interfaces and lines, and performs various functions and processes data of the terminal device 800 by running or executing instructions, programs, code sets, or instruction sets stored in the memory 805, and by calling data stored in the memory 805. Optionally, the processor 801 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 801 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 801 and may be implemented as a separate chip.
[0143] The memory 805 may include random access memory (RAM) or read-only memory. Optionally, the memory 805 may include a non-transitory computer-readable storage medium. The memory 805 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 805 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 805 may also be at least one storage device located remotely from the aforementioned processor 801. Figure 8 As shown, the memory 805, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and application programs.
[0144] exist Figure 8 In the terminal device 800 shown, the user interface 803 is mainly used to provide an input interface for the user and to obtain the user's input data; while the processor 801 can be used to call the application program stored in the memory 805 and specifically execute, such as Figure 2 and / or Figure 5 The method shown can be referred to for details. Figure 2 and / or Figure 5 As shown, it will not be elaborated further here.
[0145] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory, or random access memory, etc.
[0146] The above description discloses only preferred embodiments of the present invention and should not be construed as limiting the scope of the present invention. Therefore, equivalent variations made in accordance with the claims of the present invention are still within the scope of the present invention.< / path> < / form>
Claims
1. A method for generating and parsing web page data on an embedded device, characterized in that, include: Obtain the size and structure of the embedded device's C structure, as well as the data to be transmitted from the web page; A preset data encoding function is used to convert the data to be transmitted from the web page into a binary data packet with the same size and structure as the embedded device's C structure; the binary data packet is then sent back to the corresponding embedded device. After acquiring the data transmitted from the embedded device, a preset data parsing function is used to convert the data transmitted from the embedded device into standard JavaScript variables.
2. The embedded device web page data generation and parsing method according to claim 1, characterized in that, The step of using a preset data encoding function to convert the data to be transmitted from the webpage into a binary data packet with the same size and structure as the embedded device's C structure includes: Use an ArrayBuffer() object to generate a buffer with the same size and construction as the embedded device's C structure; Based on the construction, type, offset, and end order of the embedded device C structure, the various Set methods contained in the DataView() object are called to fill the buffer; The data to be transmitted from the web page is filled into the buffer to generate the binary data packet.
3. The embedded device web page data generation and parsing method according to claim 1, characterized in that, The process of using a preset data parsing function to convert data transmitted from the embedded device into standard JavaScript variables includes: Obtain binary data from the embedded device, wherein the binary data type is an ArrayBuffer buffer; Based on the construction, type, offset, and end order of the binary data, various Get methods contained in the DataView() object are called to convert the data in the ArrayBuffer buffer into standard JavaScript variables.
4. The embedded device web page data generation and parsing method according to claim 1, characterized in that, The acquisition of data transmitted from the embedded device includes: It calls JavaScript standard resources to obtain APIs and sends data requests to the web server of the corresponding embedded device via the HTTP protocol. The data is retrieved from the embedded device according to the data request.
5. A data transmission method for an embedded device, characterized in that, include: Transmit C language structure data from the embedded device directly to the browser in raw binary format; The browser is controlled to parse the original binary format data using the method in the embedded device web page data generation and parsing method according to any one of claims 1-4.
6. The data transmission method for an embedded device according to claim 5, characterized in that, The raw binary format data is data that has not undergone conversion processing by the embedded device.
7. A data receiving method for an embedded device, characterized in that, include: Retrieve data return requests sent from the web client; According to the data feedback request, obtain the binary data packet converted by the preset data encoding function in the embedded device web page data generation and parsing method according to any one of claims 1-4; The binary data packet is converted into a standard C structure using standard C data type conversion.
8. An embedded device web page data generation and parsing apparatus, characterized in that, include: The acquisition module is used to obtain the size and structure of the embedded device's C structure and the data to be transmitted from the web page. The encoding module is used to convert the data to be transmitted from the web page into binary data packets with the same size and structure as the embedded device's C structure using a preset data encoding function. The binary data packet is then sent back to the corresponding embedded device. The parsing module is used to convert the data transmitted from the embedded device into standard JavaScript variables using a preset data parsing function after the data is received.
9. An electronic device, characterized in that, include: Processor and memory; The memory stores a computer-readable program that can be executed by the processor; When the processor executes the computer-readable program, it implements the steps in the embedded device web page data generation and parsing method as described in any one of claims 1-4, and / or processes the steps in the embedded device data transmission method as described in any one of claims 5-6, and / or the steps in the embedded device data reception method as described in claim 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, which can be executed by one or more processors to implement the steps in the embedded device web page data generation and parsing method as described in any one of claims 1-4, and / or process the steps in the embedded device data transmission method as described in any one of claims 5-6, and / or the steps in the embedded device data reception method as described in claim 7.