Intelligent hardware access method and platform for science education
By reading and converting the access protocol of hardware devices, selecting and configuring hardware devices, converting them into abstract syntax trees and performing syntax mapping and building block mapping, the complex problem of hardware device access process is solved, and development efficiency and convenience are improved.
Patent Information
- Application Number
- CN202411706626.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-08
AI Technical Summary
In the prior art, the hardware device access process is complicated, developers need to master a variety of technical stacks, the configuration and development environment are cumbersome, hardware access and debugging are difficult, and the lack of efficient hardware abstraction layers and unified programming interfaces, resulting in low development efficiency.
By reading the access protocol of the hardware device predefined through the configuration file and converting it into a format that the hardware device can recognize, select the hard device required by the programming tool, read the corresponding protocol configuration from the access protocol based on the selected hardware device, escape the protocol configuration into the abstract syntax tree of the selected hardware device itself, and perform syntax mapping and building block mapping to interact with the selected hardware device.
It simplifies the access process of hardware equipment, lowers the technical threshold, improves development efficiency, reduces the technology stack that developers need to master, simplifies the configuration of the development environment, and improves the convenience of hardware access and debugging.
Smart Images

Figure CN119781783A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to an intelligent hardware access method and platform for scientific education. Background Art
[0002] With the rapid development of modern technology, the rise of the Internet of Things (IoT), artificial intelligence (AI), smart homes, and various embedded systems has led to an explosive growth in the types and complexity of hardware devices. These devices range from tiny sensors to complex industrial control systems, and each device has its own unique hardware interface, communication protocol, and specific programming requirements. This diversity poses many challenges to developers during programming and development, and there is an urgent need for efficient tools to assist hardware access and configuration.
[0003] In this context, hardware assistants have emerged as a kind of middleware or plug-in, which aims to simplify the hardware access, configuration and development process. Hardware assistants can automatically identify hardware devices, configure the development environment, provide code generation tools, and achieve efficient debugging and monitoring. Furthermore, hardware assistants also support cloud integration, which significantly improves the productivity of developers, reduces the project development cycle, and enables developers to focus more on innovation and optimization at the application level, thereby promoting the rapid development of technology and the implementation of practical applications.
[0004] However, the prior art has obvious disadvantages in the following aspects.
[0005] First, as technology diversity and complexity increase, different hardware platforms may be based on different microcontrollers or processors, and support different operating systems, programming languages, and development tools. This requires developers to master a wide range of technology stacks to cope with diverse hardware devices, increasing the difficulty of learning and adapting.
[0006] Secondly, the configuration process of the development environment is often cumbersome and time-consuming. Setting up a complete hardware development environment usually involves the installation and configuration of multiple software tools, including integrated development environment (IDE), drivers, compilers, and debuggers. This process is prone to errors, and building a development environment becomes a major obstacle, especially for beginners.
[0007] In addition, hardware access and debugging also face many challenges. Connecting hardware devices to the development environment and ensuring that all hardware resources are correctly identified and configured often requires manual intervention and expertise. For example, developers need to set up correct port mappings, resolve driver compatibility issues, and configure communication protocols, which can become bottlenecks in the development process.
[0008] Finally, the lack of an efficient hardware abstraction layer and a unified programming interface leads to low development efficiency. Developers have to spend a lot of time on low-level details and cannot focus on the development of application logic and innovative functions. In addition, the cross-platform requirements for hardware access are not effectively met, and developers need to repeat development on different tools, further increasing the workload and complexity.
[0009] Therefore, in response to the above problems, a new type of hardware assistant solution is urgently needed to improve development efficiency, lower technical barriers, and promote wider application of technology.
[0010] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0011] The embodiments of the present invention provide an intelligent hardware access method and platform for scientific education, so as to at least solve the technical problem of the complicated hardware device access process in the prior art.
[0012] According to one aspect of an embodiment of the present invention, there is provided a smart hardware access method for science education, comprising: reading an access protocol of a hardware device pre-defined through a configuration file, and converting the access protocol into a format recognizable by the hardware device, wherein the access protocol includes at least one of the following of the hardware device: life cycle, instruction set, and optional building block module configuration; selecting a hardware device required by a programming tool, and reading a corresponding protocol configuration from the access protocol based on the selected hardware device; translating the protocol configuration into an abstract syntax tree of the selected hardware device itself, and performing syntax mapping and building block mapping based on the abstract syntax tree to interact with the selected hardware device.
[0013] According to another aspect of an embodiment of the present invention, there is also provided an intelligent hardware access platform for science education, comprising: a reading module, configured to read an access protocol of a hardware device pre-defined through a configuration file, and convert the access protocol into a format recognizable by the hardware device, wherein the access protocol includes at least one of the following of the hardware device: a life cycle, an instruction set, and an optional building block module configuration; a selection module, configured to select a hardware device required by a programming tool, and read a corresponding protocol configuration from the access protocol based on the selected hardware device; a mapping module, configured to convert the protocol configuration into an abstract syntax tree of the selected hardware device itself, and perform syntax mapping and building block mapping based on the abstract syntax tree to interact with the selected hardware device.
[0014] In an embodiment of the present invention, the access protocol of the hardware device pre-defined by the configuration file is read, and the access protocol is converted into a format that can be recognized by the hardware device, wherein the access protocol includes at least one of the following of the hardware device: life cycle, instruction set, and optional building block module configuration; the hardware device required by the programming tool is selected, and the corresponding protocol configuration is read from the access protocol based on the selected hardware device; the protocol configuration is converted into the abstract syntax tree of the selected hardware device itself, and syntax mapping and building block mapping are performed based on the abstract syntax tree to interact with the selected hardware device. Through the above scheme, the complex technical problem of the hardware device access process in the prior art is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0016] Figure 1 is a flow chart of a smart hardware access method for science education according to an embodiment of the present invention;
[0017] Figure 2 is a flow chart of another intelligent hardware access method for science education according to an embodiment of the present invention;
[0018] Figure 3 is a flow chart of a method for configuring an access protocol according to an embodiment of the present invention;
[0019] Figure 4 is a flow chart of a method for a decoder to perform protocol parsing according to an embodiment of the present invention;
[0020] Figure 5 is a flow chart of a method for establishing a connection according to an embodiment of the present invention;
[0021] Figure 6 is a flow chart of a method for generating a building block adapter according to an embodiment of the present invention;
[0022] Figure 7 is an architecture diagram of an intelligent hardware access platform for science education according to an embodiment of the present invention;
[0023] Figure 8 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] According to an embodiment of the present invention, a method embodiment of an intelligent hardware access method for scientific education is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0027] Figure 1 is a smart hardware access method for science education according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0028] Step S102, reading the access protocol of the hardware device pre-defined by the configuration file, and converting the access protocol into a format recognizable by the hardware device, wherein the access protocol includes at least one of the following of the hardware device: life cycle, instruction set, and optional building block module configuration.
[0029] Step S104, selecting the hardware device required by the programming tool, and reading the corresponding protocol configuration from the access protocol based on the selected hardware device.
[0030] Register the hardware devices in the access protocol into the hardware catalog of the programming tool of the programming platform; select the required hardware devices from the hardware catalog as the selected hardware devices, and obtain the protocol configuration from the hardware catalog based on the selected hardware devices.
[0031] Step S106: convert the protocol configuration into an abstract syntax tree of the selected hardware device itself, and perform syntax mapping and building block mapping based on the abstract syntax tree to interact with the selected hardware device.
[0032] Based on the abstract syntax tree, syntax mapping is performed to generate building blocks corresponding to the selected hardware device; based on the abstract syntax tree, building block mapping is performed to generate a syntax library corresponding to the selected hardware device. Then, the connection type is parsed from the protocol configuration, and based on the connection type, a connection is established between the programming platform and the selected hardware device; based on the connection, the programming platform uses the building blocks or the syntax library to interact with the selected hardware device.
[0033] This application also provides another intelligent hardware access method for science education, such as Figure 2 As shown, the method comprises the following steps:
[0034] Step S202: configure the access protocol.
[0035] First, you need to generate a JSON configuration file that describes the hardware device, namely the access protocol. The access protocol is the basis of the entire access process, including the device life cycle, instruction set, and optional building block module configuration, ensuring that different hardware devices can be connected to the system in a standardized manner. Specifically, Figure 3 As shown, the following steps are included:
[0036] Step S2022, configure basic device information.
[0037] The user enters basic information about the device in the platform's user interface. This information usually includes the device name, model, manufacturer, and version number. The accuracy and completeness of this basic information is critical for subsequent device identification and management. The platform stores this information in a database for quick query and verification when the user uses the device.
[0038] Step S2024, configure the life cycle.
[0039] In the access protocol, the lifecycle part needs to define the different states and processing logic of the device in detail. The lifecycle configuration specifically includes four aspects of information. The first is the initialization information, which describes the startup process of the device when it is connected, including hardware self-test, initialization settings, and parameter verification. For example, when the device is connected, it will perform a self-test to confirm that all sensors and modules are working properly, and perform initialization settings according to the preset parameters to ensure that the device can operate in the best state. The second is the operation information, which lists the performance of the device under normal working conditions. Users need to describe the specific tasks that the device can perform, response time, power consumption and other performance indicators. This not only helps users understand the functions of the device, but also provides a basis for subsequent performance evaluation. For example, a device can be defined as "capable of reading temperature data within 1 second and sending it to the cloud via Wi-Fi", which can clearly indicate the expected performance of the device. Next is the stop information, where users need to define the conditions and subsequent processing methods for the device to stop working. This includes how the device should safely power off when receiving a shutdown command, or automatically enter standby mode when there is no activity. Detailed stop logic helps save energy when the device is not in use and avoid damage to the device. Finally, there is error handling information, which is used to describe the device's response measures when a failure occurs, including error codes, possible causes of failure, and repair suggestions. By recording this information in detail, users can quickly locate the problem and take corresponding measures when they encounter device failures. For example, when a device fails, the platform may return "Error code 101: Sensor failure, please check the connection cable", and such feedback can effectively help users troubleshoot.
[0040] Step S2026, configure the instruction set.
[0041] The command set part of the access protocol is the key to ensure the normal operation of the device. Users need to list all the command sets supported by the device in detail in the JSON file. Each command can contain the following information:
[0042] Instruction Name: A unique identifier for each instruction to facilitate subsequent calls. Users should choose names that are easy to remember and describe so that they can be quickly identified when programming.
[0043] Parameter requirements: The type and number of parameters required by the instruction to ensure that the user can provide the correct data when calling the instruction. For example, a command may require two parameters, one is the device ID (string type) and the other is the timeout (integer type).
[0044] Return value: The result returned after the command is executed, including the data format and meaning. This part ensures that the user can correctly parse the returned data after calling the command, so as to facilitate subsequent processing and decision-making. For example, a command may return a floating point number containing the current temperature value of the device, and the user needs to know how to interpret this return result.
[0045] Step S2028, configuring optional building block modules.
[0046] In the access protocol, users can also add optional building block module configurations according to device functions. These modules can provide additional functional expansion for the device, such as sensor reading, data processing, signal transmission, etc. Define the name, function description and whether it is a required option for each optional module to ensure that users can flexibly choose according to actual needs during configuration.
[0047] For example, users can add a "temperature sensor module" with the function description of "reading ambient temperature in real time and sending data to the cloud". Through such configuration, users can clearly understand the functions and usage scenarios of the module, so as to make full use of the hardware in actual applications.
[0048] After all configurations are completed, the platform will automatically verify the correctness of the JSON format. This includes syntax checking and field integrity verification to ensure that the configuration file can be parsed correctly. The platform will recursively check the JSON structure to ensure that each field meets the predetermined format and type requirements. If an error is found, the platform will return detailed error information indicating the problem, such as "Missing the required field 'instruction name'" or "Parameter type does not match, please check." This automated verification mechanism greatly reduces human errors and improves the accuracy of configuration.
[0049] Through the detailed description of the above steps, users can efficiently configure the access protocol of the device. The automation and standardized design of the entire process not only improves the work efficiency of users, but also lowers the technical threshold for accessing smart hardware, allowing more educators to easily apply smart hardware for scientific education.
[0050] Step S204: register the hardware device through a registration assistant.
[0051] During the process of intelligent hardware access, use the "Registration Assistant" to parse the protocol configuration and write it into the hardware list of the programming tool, so that the user-defined device information and configuration can be integrated into the platform for subsequent programming and control.
[0052] The registration assistant first accesses the JSON configuration file specified by the user. The platform checks whether the configuration file path entered by the user is valid. If the path is incorrect, the registration assistant will prompt the user to re-enter it. After successfully verifying the path, the registration assistant will open the JSON file and read its contents. To ensure that possible errors can be handled during the reading process, such as the file does not exist or cannot be accessed, the platform uses standard file operation methods. The registration assistant then uses the JSON parsing library to convert the file contents into an in-memory data structure. During the parsing process, the registration assistant performs a syntax check to ensure that the file format complies with the JSON standard, and checks all fields to extract data such as device information, life cycle, instruction set, and optional modules.
[0053] After successfully reading and parsing the configuration file, the registration assistant will perform the operation of updating the hardware list. The platform will format the parsed information to conform to the standard structure of the programming tool hardware list. This includes organizing information such as device name, model, and function description into a consistent format to ensure that the data can be stored smoothly. The registration assistant will then add the formatted information to the programming tool's hardware list. The platform will ensure the uniqueness of the hardware name to avoid duplicate registration. If the name of the new device already exists, the registration assistant will refuse to register and prompt the user to modify it. At the same time, in order to increase the retrieval speed of hardware information, the registration assistant will create an index for the newly registered device in the hardware list, thereby speeding up the efficiency of subsequent user queries and operations.
[0054] After registration is complete, the platform will provide feedback to the user, displaying the registration results, including detailed information about the newly registered hardware. This information includes the hardware name, function description, life cycle status, and configured modules. The feedback information will be displayed in a clear and easy-to-read format on the user interface, allowing users to quickly understand the functions of the new device. If an error occurs during the registration process, the platform will provide detailed error information. For example, if the configuration file format entered by the user is incorrect, the platform will prompt "The configuration file format is incorrect, please check the JSON syntax." If necessary fields are missing, the platform will indicate the specific missing field names to help users quickly correct them. In order to guide users to the next step, the platform may also include operational suggestions in the feedback information, such as suggesting that users perform subsequent hardware testing or programming. With such feedback, users can decide the next step based on the registration results, such as continuing to register other hardware or directly entering the programming stage.
[0055] Step S206: The decoder performs protocol analysis.
[0056] After successful registration, the platform calls the decoder to perform protocol analysis and convert the device configuration file content into a data structure that the platform can operate for subsequent processing and function implementation. The specific implementation process is as follows: Figure 4 As shown, including:
[0057] Step S2062, parse the protocol configuration.
[0058] The decoder first reads the configuration file of the corresponding device in the hardware list updated by the registration assistant. The decoder accesses the file system configured by the storage device to confirm whether the path and name of the configuration file are valid. If the file cannot be found or the format is incorrect, the decoder will return the corresponding error message and guide the user to make corrections.
[0059] After confirming that the file is valid, the decoder loads its contents into memory for parsing. At this point, the decoder uses the file reading method to load the entire configuration file as a string for subsequent parsing. The decoder then calls the JSON parsing library to parse the string content into an operable data structure, usually a dictionary or object type. The decoder traverses each part of the file and maps the information in the configuration file to the corresponding internal structure, including device information, life cycle, instruction set, and optional modules. To ensure the integrity of the information, the decoder performs necessary verification to ensure that each part meets the predetermined format and requirements.
[0060] Step S2064, construct AST (abstract syntax tree).
[0061] After successfully parsing the protocol configuration, the decoder will generate an abstract syntax tree (AST) based on the device's instruction set. AST is a tree-like data structure used to represent structured information about device functions. The decoder converts the parsed instruction set into nodes in the AST one by one, and each node will contain key information about the instruction, including the instruction name, parameter requirements, and return value description.
[0062] The decoder creates a new node for each instruction, which has at least one of the following attributes: instruction name (used to identify the instruction), parameter list (listing required parameters and their types), and return value information (describing the format and meaning of the returned data). During the construction process, the decoder checks whether there are conflicts or duplications in the instructions to ensure the uniqueness and consistency of each instruction.
[0063] The generated AST will be stored in a tree structure, and the nodes of each instruction will be connected to each other according to the logical relationship to form a complete instruction call chain. This structured information representation method makes the subsequent instruction parsing and execution process more efficient and convenient for calling and operating in the programming environment.
[0064] Step S2066, escape processing.
[0065] After the AST is built, the decoder will perform the escape process. The hardware instruction set is escaped into a format that the programming tool can recognize, so as to ensure that the subsequent processes can be seamlessly connected. During the escape process, the decoder will perform necessary conversions according to the grammatical rules of the programming tool.
[0066] The decoder first analyzes each node in the AST and converts the instruction name, parameter format, and return value type in the node into a standard format supported by the tool according to the requirements of the programming tool. For example, if an instruction uses a specific naming rule in the hardware protocol, the decoder converts it into the standard naming used in the programming tool to ensure consistency.
[0067] In addition, the decoder also needs to handle parameter type conversion. If a parameter is defined as a floating point type in the hardware protocol, but the programming tool requires an integer type, the decoder will perform the corresponding conversion and processing to ensure that the parameter can be correctly identified and used when the code is executed. The escape process ensures compatibility between different systems, so that users do not need to worry about the underlying implementation details when using programming tools.
[0068] The final generated AST will provide basic data for subsequent connection assistants, building block adapters, and syntax adapters to ensure that subsequent steps can run efficiently.
[0069] Step S208, establishing a connection.
[0070] During the process of smart hardware access, the connection assistant is responsible for establishing a connection with the device. Figure 5 As shown, the following steps are included:
[0071] Step S2082, determine the connection type.
[0072] The connection assistant identifies the required connection type based on the AST information, including serial port connection, Bluetooth connection, and Wi-Fi connection. Specifically, the connection assistant analyzes the connection attributes in the AST and extracts the field indicating the connection type. For different types of connections, the connection assistant performs corresponding logical judgments.
[0073] The connection assistant checks whether the current device supports the identified connection type. The check usually includes querying the device's hardware specifications and function description to ensure that the device can technically meet the connection requirements. For example, some devices may only support serial port connections but not wireless connections.
[0074] The connection assistant also ensures that the platform has the appropriate drivers installed to support the selected connection type. If the required drivers are not installed, the platform will prompt the user to install them or provide installation instructions to ensure that the user can complete the connection setup smoothly.
[0075] Step S2084, establish a connection.
[0076] After confirming the connection type and driver availability, the connection assistant will perform the corresponding connection steps according to the identified connection type. For different connection methods, the specific implementation details are as follows:
[0077] For serial port connections, the connection assistant will initialize the serial port parameters, including baud rate, data bits, stop bits, and parity. These parameters are used to ensure stable communication between the device and the computer. The connection assistant will set these parameters according to the device's specification document and try to open the specified serial port. If the connection is successful, the assistant will perform preliminary data communication tests to ensure that data can be transmitted normally.
[0078] For Bluetooth connections, the connection assistant will start the Bluetooth pairing process, including scanning for available Bluetooth devices and listing the target device for the user to select. After the user selects the device, the assistant will send a pairing request, which usually requires entering a pairing code or confirming the pairing operation. After successful pairing, the connection assistant will establish the connection and perform a preliminary test of data transmission to ensure that the device can correctly recognize and receive instructions.
[0079] For Wi-Fi connections, the connection assistant will ask the user to enter the name and password of the Wi-Fi network so that the device can access the Internet. The connection assistant will verify the information entered by the user to ensure the validity of the network name and password. After successfully connecting to Wi-Fi, the connection assistant will perform a network connection test to ensure that the device can transmit data over the Internet.
[0080] During the connection establishment process, the connection assistant will provide real-time feedback, display the connection progress and status, and help users understand the connection process.
[0081] Step S2086, manage life cycle.
[0082] During the connection process, the connection assistant needs to manage the life cycle of the hardware, including the establishment, maintenance, and termination of the connection. After successfully establishing the connection, the connection assistant will record the status of the connection and initialize the necessary communication parameters. These parameters will be used for subsequent data transmission. The connection assistant regularly checks the connection status to ensure smooth communication with the hardware. This check can be achieved by sending a heartbeat signal or regularly reading the device status. If the connection is found to be unstable or interrupted, the connection assistant will automatically try to reconnect and notify the user as needed. When the user decides to stop communicating with the device, or the device enters standby mode, the connection assistant will be responsible for safely terminating the connection, including sending a disconnect command, releasing resources, and recording the disconnection time and reason for subsequent analysis.
[0083] In addition, to ensure that the communication interface with the hardware works properly, the connection assistant will implement basic communication protocols, including the sending and receiving of data. The connection assistant will parse the received data, extract useful information, and pass the data to other modules for further processing. Through these steps, the connection assistant provides a stable connection environment for the device, ensuring that users can interact with the hardware smoothly.
[0084] Through the above technical solutions, the connection assistant ensures that smart hardware can be connected to programming tools efficiently and stably.
[0085] Step S210: generating a building block adapter.
[0086] After successfully establishing a connection with the hardware device, the platform will call the building block adapter to perform corresponding operations to support users to interact with the device efficiently in the programming environment. The main function of the building block adapter is to convert the parsed abstract syntax tree (AST) into user-visual programming building blocks and ensure that the functional description and instruction sending mechanism of these building blocks are clear and accurate.
[0087] Specifically, Figure 6 As shown, the following steps are included:
[0088] Step S2102, perform AST conversion.
[0089] The building block adapter first automatically generates the corresponding building blocks based on the parsed AST information. First, the adapter traverses each node in the AST to identify the type of instruction and related information. For each instruction, the building block adapter creates a new building block object and defines its basic properties, including semantics, functions, and identifiers.
[0090] When defining semantics, the block adapter needs to ensure that each block clearly reflects the function of the device. For example, if a node represents "read temperature", the semantics of the block will be set to "get the current ambient temperature". The function specifically describes the operation that the user can achieve with this block, such as "store the obtained temperature value into a variable". The identifier is a unique identification name for each block to ensure that there is no duplication in the programming environment.
[0091] During the generation process, the adapter will also assign graphical representations to the blocks. This includes selecting appropriate icons and colors so that each block is both beautiful and easy to identify in the programming interface. The adapter will use design tools to generate a graphical interface for the blocks, ensuring that users can quickly identify the function of each block when using it.
[0092] Step S2104, describing the function of the building blocks.
[0093] Each generated block will be accompanied by a detailed functional description and usage example. This description will include the purpose of the block, how it is operated, and the expected effect, so that users can quickly understand how to apply it correctly during use. For example, for the "Read Temperature" block, the functional description can be written as: "This block is used to obtain the current temperature value from the connected temperature sensor and store it in the specified variable."
[0094] To enhance the user experience, the adapter provides practical examples showing how to drag and drop the block in the programming environment. Through the instantiation code snippet, users can intuitively see how to combine the block with other blocks to complete a specific programming task.
[0095] Step S212, constructing a grammar adapter.
[0096] The syntax adapter automatically generates the corresponding syntax library based on the parsed AST. The syntax library contains the complete calls and interfaces of the device objects for users to use when programming. Ensure that each interface in the syntax library accurately reflects the function of the device and provides detailed instructions and parameter requirements. The syntax adapter generates sample code for each interface to help users understand how to use it.
[0097] When the user writes code, the platform will call the generated syntax library to convert the user's code instructions into a format that the device can understand. The syntax adapter will ensure that when calling the interface, all parameters and return values meet the requirements of the device to avoid call failures.
[0098] Step S214, programming the hardware device using building blocks or grammar libraries.
[0099] When users drag and drop blocks in the programming environment to program, the platform converts the user's instructions into signals that the device can understand. Whenever the user completes a program and triggers a run instruction, the block adapter collects all currently activated blocks or codes and converts them into commands that the device can understand.
[0100] Before sending instructions, the programming platform will detect the instructions to verify whether they are correct. For example, the first eigenvector of the context code of the code to be detected and the second eigenvector of the current code to be detected are extracted respectively, and the first eigenvector and the second eigenvector are respectively upgraded according to the extended rank criterion, and the first eigenvector and the second eigenvector are coupled and fused using a multi-channel convolution kernel to obtain the coupled main embedded feature matrix and the auxiliary embedded feature matrix. The above matrix is expanded along the extended dimension to form multiple sub-matrices. Each sub-matrix is subjected to singular value decomposition to extract the core subspace representation and factor matrix. The principal component difference between the main feature matrix and the auxiliary feature matrix is calculated based on the core subspace representation and the factor matrix to extract the core features, thereby effectively identifying logical errors and reference problems.
[0101] When sending instructions, the building block adapter will also assemble the instructions to ensure that all parameters and data meet the requirements of the device. This includes verifying the input data type, number of parameters and format, etc. The adapter will call the pre-defined communication protocol to ensure that the construction of the instructions meets the device's instruction set specifications.
[0102] After the instructions are assembled, the building block adapter sends the generated instructions to the hardware device through the underlying interface. The adapter implements the necessary error handling mechanism to ensure the correct communication of the instructions. If an error occurs during the sending process, the adapter will record the error information and provide corresponding feedback to the user. For example, if the device does not respond, the platform will prompt the user to check the connection status or reconfigure the hardware.
[0103] Through the above steps, the building block adapter effectively bridges the connection between user programming and device execution, ensuring that users can control smart hardware intuitively and efficiently, thereby achieving a richer interactive experience in science education.
[0104] If you use the syntax library for programming, the operation is similar to that of the building block adapter and will not be described here.
[0105] This application also provides an intelligent hardware access platform for science education, such as Figure 7 As shown, it includes: a reading module 72, configured to read the access protocol of the hardware device pre-defined by the configuration file, and convert the access protocol into a format recognizable by the hardware device, wherein the access protocol includes at least one of the following of the hardware device: life cycle, instruction set, and optional building block module configuration; a selection module 74, configured to select the hardware device required by the programming tool, and read the corresponding protocol configuration from the access protocol based on the selected hardware device; a mapping module 76, configured to convert the protocol configuration into an abstract syntax tree of the selected hardware device itself, and perform syntax mapping and building block mapping based on the abstract syntax tree to interact with the selected hardware device.
[0106] It should be noted that the intelligent hardware access platform for science education provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the intelligent hardware access platform for science education provided in the above embodiment and the virtual object rendering method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0107] Figure 8 FIG. 1 shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present disclosure. It should be noted that: Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0108] like Figure 8 As shown, the electronic device includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.
[0109] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0110] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A smart hardware access method for scientific education, characterized in that: include: Reading an access protocol of a hardware device pre-defined in a configuration file, and converting the access protocol into a format recognizable by the hardware device, wherein the access protocol includes at least one of the following of the hardware device: life cycle, instruction set, and optional building block module configuration; Selecting a hardware device required by the programming tool, and reading a corresponding protocol configuration from the access protocol based on the selected hardware device; The protocol configuration is converted into an abstract syntax tree of the selected hardware device itself, and syntax mapping and building block mapping are performed based on the abstract syntax tree to interact with the selected hardware device.
2. The method according to claim 1, characterized in that Performing syntax mapping and building block mapping based on the abstract syntax tree includes: Based on the abstract syntax tree, perform syntax mapping to generate building blocks corresponding to the selected hardware device; and / or Based on the abstract syntax tree, building block mapping is performed to generate a syntax library corresponding to the selected hardware device.
3. The method according to claim 2, characterized in that Interact with selected hardware devices, including: Parsing a connection type from the protocol configuration, and establishing a connection between the programming platform and the selected hardware device based on the connection type; Based on the connection, the building blocks or the grammar library are used on the programming platform to interact with the selected hardware device.
4. The method according to claim 1, characterized in that: Selecting a hardware device required by the programming tool, and reading a corresponding protocol configuration from the access protocol based on the selected hardware device, including: Registering the hardware device in the access protocol into the hardware catalog of the programming tool of the programming platform; A required hardware device is selected from the hardware catalog as the selected hardware device, and the protocol configuration is acquired from the hardware catalog based on the selected hardware device.
5. The method according to claim 4, characterized in that The programming platform is a graphical programming platform or a source code programming platform.
6. The method according to claim 4, characterized in that A hook is reserved in the access protocol for autonomously calling the context of the programming tool.
7. An intelligent hardware access platform for scientific education, characterized in that: include: A reading module is configured to read an access protocol of a hardware device pre-defined by a configuration file, and convert the access protocol into a format recognizable by the hardware device, wherein the access protocol includes at least one of the following of the hardware device: life cycle, instruction set, and optional building block module configuration; A selection module configured to select a hardware device required by the programming tool and read a corresponding protocol configuration from the access protocol based on the selected hardware device; The mapping module is configured to convert the protocol configuration into an abstract syntax tree of the selected hardware device itself, and perform syntax mapping and building block mapping based on the abstract syntax tree to interact with the selected hardware device.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.
9. A computer device, characterized in that: include: Memory and processor, The memory stores a computer program; The processor is used to execute the computer program stored in the memory, and when the computer program is run, the processor is enabled to execute the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Pluggable software three-party equipment access method
CN121209970A