An AT instruction parsing method, a terminal and a computer readable medium

By reading and parsing AT commands in the main control processor, the compatibility problem of testing equipment from different manufacturers is solved, universal AT command parsing is realized, testing efficiency and equipment compatibility are improved, and development costs are reduced.

CN115562728BActive Publication Date: 2026-04-28AITIWEIER ELECTRONICS TECH BEIJING
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
AITIWEIER ELECTRONICS TECH BEIJING
Filing Date
2022-10-28
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In existing technologies, testers need to use AT commands that are compatible with data transmission modules from different manufacturers to communicate with the main control processor, which makes testing time-consuming and labor-intensive, and lacks a universal AT command parsing method.

Method used

An AT command parsing method is provided, which reads the command line from the circular buffer queue, queries the URC table to find the matching element and executes the corresponding function, releases the semaphore, and marks the parsing status according to the feedback result, thereby realizing the parsing of AT commands.

Benefits of technology

It enables universal AT command parsing for devices from different manufacturers, shortens R&D and testing time, improves the processing speed and efficiency of the main control processor, and reduces development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115562728B_ABST
    Figure CN115562728B_ABST
Patent Text Reader

Abstract

The application discloses an AT instruction analysis method, a terminal and a computer readable medium, and relates to the field of electronic communication. The method comprises the following steps: reading an instruction line from a circular buffer queue ring_buf; under the premise that the instruction line data is correct, querying and calling an element matched with the data line in a URC table, executing a function corresponding to the element, releasing a second semaphore resp_notice, and completing the analysis of the AT instruction; when the URC table does not store the element matched with the data line, querying whether the last line of a string of a processing result fed back after the execution of the AT instruction by a data transmission module is a correct identifier OK or a failure or error identifier, if the correct identifier OK, marking a response state resp_status as successful and releasing the resp_notice semaphore, and completing the analysis of the AT instruction; if the failure or error identifier, marking the response state resp_status as a failure and releasing the resp_notice semaphore, and completing the analysis of the AT instruction. The application realizes the analysis of AT instructions of different data transmission modules.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic communications, and more particularly to a method for parsing AT commands, a terminal, and a computer-readable medium. Background Technology

[0002] With the rapid development of the Internet of Things (IoT), more and more devices are being used in IoT applications. In IoT, devices are typically connected to the network via data transmission modules, and the main control processor communicates with the device's data transmission modules via AT commands.

[0003] Because manufacturers install different data transmission modules in their equipment according to different usage scenarios when developing equipment products, and because the AT commands of each data transmission module are different, testers need to use the AT commands that are compatible with the module of the equipment to communicate with the main control processor when testing equipment with different data transmission modules, which is time-consuming and labor-intensive.

[0004] Therefore, there is currently no single AT command parsing method that can be adapted to different devices from different manufacturers. Summary of the Invention

[0005] The purpose of this invention is to provide an AT command parsing method, terminal, and computer-readable medium, so as to provide an AT command parsing method that can be adapted to different devices from different manufacturers, thereby shortening the research and development time and testing time.

[0006] To achieve the above objectives, a first aspect of the present invention provides a method for parsing AT commands, used in a master controller, comprising: reading a command line from a circular buffer queue ring_buf; provided the command line data is correct, querying and retrieving an element in the URC table that matches the data line, executing the function corresponding to the element, releasing the second semaphore resp_notice, and completing the parsing of the AT command; if the URC table does not store an element that matches the data line, querying whether the last string of the processing result fed back by the data transmission module after executing the AT command is a correct identifier OK or a failure or error identifier; if it is a correct identifier OK, then the response status resp_status is marked as successful and the resp_notice semaphore is released, completing the parsing of the AT command; if it is a failure or error identifier, then the response status resp_status is marked as failure and the resp_notice semaphore is released, completing the parsing of the AT command.

[0007] Preferably, before reading an instruction line from the circular buffer queue ring_buf, the main controller further performs initialization settings for the parsing process, specifically:

[0008] S001, the main controller creates a structure client; the structure client includes an rx_notice semaphore that points to the received new data to be parsed, a resp_notice semaphore that points to the completion of AT command parsing, a circular buffer queue ring_buf for storing the data to be parsed received from the serial port, and a URC table for acquiring and recording the data sent by the CNC module to the main controller;

[0009] S002, the main controller initializes the circular buffer queue ring_buf;

[0010] S003, the main controller creates a mutex lock to protect the AT command sending interface;

[0011] S004, the main controller creates an rx_notice semaphore, and increments the value of the rx_notice semaphore by 1 each time it is released;

[0012] S005, the main controller creates a resp_notice semaphore. When a complete AT command is parsed or the content reported in the URC table is parsed, the resp_notice semaphore is released once, and the value of the resp_notice semaphore is incremented by 1.

[0013] S006, AT parsing task created and started successfully;

[0014] S007, the main controller initializes the ports and power I / O of its subordinate data transmission modules;

[0015] S008, Register the URC table of the master controller, obtain and record the URC table from which the CNC module sends data to the master controller.

[0016] Preferably, in S1, reading an instruction line from the circular buffer queue ring_buf specifically involves:

[0017] S101, read the circular buffer queue ring_buf in a loop and determine whether a character of 1 byte has been read within the preset time;

[0018] If so, proceed to S102;

[0019] If not, check if the rx_notice semaphore has been acquired. If yes, continue reading characters from the circular buffer queue ring_buf; if no, check if the rx_notice semaphore has been acquired.

[0020] S102, assign the above character to the variable CH, determine whether the data length of the byte exceeds the maximum length of the cache space, if yes, then execute S103; if no, update the variable is_full to 1;

[0021] S103, store the data corresponding to the character assigned to the variable CH into the cache space client->recv_line_buf, and at the same time increment the receive count read_len by 1;

[0022] S104, determine whether an end flag has been received. The end flag is at least one of a newline character and a URC flag. If yes, proceed to S105; otherwise, return to S101.

[0023] S105, determine if the variable is_full is equal to 1.

[0024] If so, clear the circular buffer queue ring_buf and indicate an error reading command line data;

[0025] If not, a message will be displayed indicating that the command line data was read successfully.

[0026] Preferably, the method for storing instruction line data in the circular buffer queue ring_buf is as follows:

[0027] S401: The main controller detects an incoming serial port interrupt and checks whether instruction line data has been received in the serial port register. If yes, it executes S402; otherwise, it continues to detect.

[0028] S402, the master controller stores the received instruction line data into the circular buffer queue ring_buf and releases the rx_notice semaphore once, completing the storage of instruction line data.

[0029] A second aspect of the present invention is a terminal comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the AT instruction parsing method as described in any one of claims 1-4.

[0030] A third aspect of the present invention is a computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the AT instruction parsing method as described in any one of claims 1-4.

[0031] The beneficial effects of this invention are:

[0032] The AT command parsing method described in one technical solution of the present invention is a general AT command parsing method, which parses according to the command line to realize the parsing of AT commands for different data transmission modules.

[0033] One technical solution of this invention increases the compatibility of device product software, shortens the development cycle, and reduces costs. Using instruction line parsing for AT commands helps improve the processing speed and efficiency of the main control processor.

[0034] One technical solution of the present invention parses according to the instruction line, reducing parsing time and increasing the testing time after parsing, so that the equipment product is tested in detail, further reducing the occurrence of abnormalities after the equipment product is launched on the market. Attached Figure Description

[0035] Figure 1 This is a schematic diagram of an AT command parsing method according to an embodiment of this application;

[0036] Figure 2 This is a schematic diagram of the process of initializing the parsing method by the main controller in one embodiment of this application;

[0037] Figure 3 This is a flowchart illustrating an embodiment of the present application for reading an instruction line from a circular buffer queue ring_buf;

[0038] Figure 4 This is a schematic diagram of the process of storing instruction line data in the circular buffer queue ring_buf according to an embodiment of this application;

[0039] Figure 5 This is a schematic diagram of the main control and data transmission module of one embodiment of this application. Detailed Implementation

[0040] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0041] Example

[0042] Reference Figure 1 The AT command parsing method described in this embodiment is applied to the main controller. Based on the communication connection between the main controller and its subordinate data transmission modules, the parsing method includes:

[0043] S1, the master controller reads a line of instruction data from the circular buffer queue ring_buf and determines whether the data in the instruction line is correct.

[0044] If so, then execute S2;

[0045] If not, then release the thread scheduler according to the preset time. In FreeRTOS, there is a 10ms delay before releasing the permissions for 10ms.

[0046] S2, the master controller queries whether the above data rows match the elements in the pre-arranged URC table.

[0047] If so, retrieve the aforementioned element from the URC table, execute the hook function corresponding to that element, and proceed to S5;

[0048] If not, then execute S3;

[0049] S3, the main controller checks whether the last line of the processing result returned by the data module after executing the AT command is correct (identifier OK).

[0050] If so, the response status resp_status is marked as successful, i.e., resp_status is assigned a value of 0, and the process proceeds to S5;

[0051] If not, then execute S4;

[0052] S4, the main controller determines whether the queried string is a failure or error identifier, wherein the failure or error identifier is fall or error;

[0053] If so, mark the response status resp_status as failure, i.e., assign the value -1 to resp_status, and proceed to S5;

[0054] If not, return S1;

[0055] S5, the main controller releases the resp_notice semaphore to complete the parsing of AT commands.

[0056] More detailed explanation:

[0057] (a) such as Figure 2 As shown, before the main controller reads a data line from the circular buffer queue ring_buf, the following steps are also included:

[0058] S001, the master controller creates a structure client; the structure client includes an rx_notice semaphore that points to the received new instruction line data to be parsed, a resp_notice semaphore that points to the completion of AT instruction parsing, a circular buffer queue ring_buf for storing the data to be parsed received by the serial port, and a URC table for acquiring and recording the data sent by the CNC module to the master controller; if creation is successful, proceed to S002; if creation fails, return failure.

[0059] S002, the main controller initializes the circular buffer queue ring_buf; if the initialization is successful, proceed to S003; if the initialization fails, return failure.

[0060] S003, the main controller creates a mutex lock to protect the AT command sending interface;

[0061] S004, the main controller creates an rx_notice semaphore, and increments the value of the rx_notice semaphore by 1 each time it is released;

[0062] S005, the main controller creates a resp_notice semaphore. When a complete AT command is parsed or the content reported in the URC table is parsed, the resp_notice semaphore is released once, and the value of the resp_notice semaphore is incremented by 1.

[0063] S006, Create an AT parsing task and start it successfully; if creation is successful, proceed to S007; if creation fails, return failure.

[0064] S007, the main controller initializes the ports and power I / O of its subordinate data transmission modules; if the initialization is successful, it proceeds to S008; if the initialization fails, it returns a failure message.

[0065] S008, The master controller registers the URC table, obtains and records the URC table from which the CNC module sends data to the master controller, and the master controller successfully completes the initialization settings before the parsing process.

[0066] (II) Reference Figure 3 In S1, reading a line of instruction data from the circular buffer queue ring_buf specifically involves:

[0067] S101, read the circular buffer queue ring_buf in a loop and determine whether a character of 1 byte has been read within the preset time;

[0068] If so, proceed to S102;

[0069] If not, check if the rx_notice semaphore has been acquired. If yes, continue reading characters from the circular buffer queue ring_buf; if no, check if the rx_notice semaphore has been acquired.

[0070] S102, assign the above character to the variable CH, and determine whether the data length of the byte exceeds the maximum length of the cache space client->recv_bufsz. If yes, execute S103; otherwise, update the variable is_full to 1.

[0071] S103, store the data corresponding to the character assigned to the variable CH into the cache space client->recv_line_buf, and at the same time increment the receive count read_len by 1;

[0072] S104, determine whether an end flag has been received. The end flag is at least one of a newline character and a URC flag. If yes, proceed to S105; otherwise, return to S101.

[0073] S105, determine if the variable is_full is equal to 1.

[0074] If so, clear the circular buffer queue ring_buf and indicate an error reading command line data;

[0075] If not, a message will be displayed indicating that the command line data was read successfully.

[0076] Before step S101, the method further includes: defining the variable is_full and initializing the variable is_full to 0; the variable is_full = 0 indicates that the cache space recv_line_buf in the client structure is not full; the variable is_full = 1 indicates that the cache space recv_line_buf in the client structure is full.

[0077] Define a variable CH to store a single character received from the serial port.

[0078] Define a receive count, read_len, and initialize read_len to 0.

[0079] The cache space client->recv_line_buf is cleared to 0. The cache space client->recv_line_buf represents a cache space in the structure.

[0080] recv_line_len represents the total number of bytes of data ultimately parsed and received by the cache space client->recv_line_buf.

[0081] (III) Reference Figure 4 The method for storing instruction line data in the circular buffer queue ring_buf:

[0082] S401: The main controller detects an incoming serial port interrupt and checks whether instruction line data has been received in the serial port register. If yes, it executes S402; otherwise, it continues to detect.

[0083] S402, the master controller stores the received instruction line data into the circular buffer queue ring_buf and releases the rx_notice semaphore once, completing the storage of instruction line data.

[0084] If the serial port callback receives data, the rx_notice semaphore is released. The data processing task continuously polls the rx_notice semaphore; if it receives the rx_notice semaphore released by the serial port callback, it will read the serial port data.

[0085] Another embodiment of the present invention provides a terminal comprising: one or more processors; and a memory for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the AT instruction parsing method.

[0086] Another embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the AT command parsing method.

[0087] By adopting the above-disclosed technical solution of this invention, the following beneficial effects are obtained: The AT command parsing method of one technical solution of this invention is a general AT command parsing method, which parses according to the command line to realize the parsing of AT commands of different data transmission modules.

[0088] One technical solution of this invention increases the compatibility of device product software, shortens the development cycle, and reduces costs. Using instruction line parsing for AT commands helps improve the processing speed and efficiency of the main control processor.

[0089] One technical solution of the present invention parses according to the instruction line, reducing parsing time and increasing the testing time after parsing, so that the equipment product is tested in detail, further reducing the occurrence of abnormalities after the equipment product is launched on the market.

[0090] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for parsing AT commands, used in a main controller, characterized in that, include: Read a line of instructions from the circular buffer queue ring_buf; Assuming the data in the instruction line is correct, query and retrieve the element in the URC table that matches the instruction line, execute the function corresponding to the element, release the second semaphore resp_notice, and complete the parsing of the AT instruction; If the URC table does not store an element matching the command line, the system queries the last line of the processing result returned by the data transmission module after executing the AT command to determine whether it is a success identifier (OK) or a failure or error identifier. If it is a success identifier (OK), the response status (resp_status) is marked as successful and the resp_notice semaphore is released, completing the parsing of the AT command. If it is a failure or error identifier, the response status (resp_status) is marked as failed and the resp_notice semaphore is released, completing the parsing of the AT command.

2. The AT command parsing method according to claim 1, characterized in that, Before reading an instruction line from the circular buffer queue ring_buf, the main controller performs initialization settings for the parsing process, specifically: S001, the main controller creates a structure client; the structure client includes an rx_notice semaphore that points to the received new data to be parsed, a resp_notice semaphore that points to the completion of AT command parsing, a circular buffer queue ring_buf for storing the data to be parsed received from the serial port, and a URC table for acquiring and recording the data sent by the CNC module to the main controller; S002, the main controller initializes the circular buffer queue ring_buf; S003, the main controller creates a mutex lock to protect the AT command sending interface; S004, the main controller creates an rx_notice semaphore, and increments the value of the rx_notice semaphore by 1 each time it is released; S005, the main controller creates a resp_notice semaphore. When a complete AT command is parsed or the content reported in the URC table is parsed, the resp_notice semaphore is released once, and the value of the resp_notice semaphore is incremented by 1. S006, AT parsing task created and started successfully; S007, the main controller initializes the ports and power I / O of its subordinate data transmission modules; S008, Register the URC table of the master controller, obtain and record the URC table from which the CNC module sends data to the master controller.

3. The AT command parsing method according to claim 1, characterized in that, In S1, reading an instruction line from the circular buffer queue ring_buf specifically refers to: S101, read the circular buffer queue ring_buf in a loop and determine whether a character of 1 byte has been read within the preset time; If so, proceed to S102; If not, check if the rx_notice semaphore has been acquired. If yes, continue reading characters from the circular buffer queue ring_buf; if no, check if the rx_notice semaphore has been acquired. S102, assign the above character to the variable CH, determine whether the data length of the byte exceeds the maximum length of the cache space, if yes, then execute S103; if no, update the variable is_full to 1; S103, store the data corresponding to the character assigned to the variable CH into the cache space client->recv_line_buf, and at the same time increment the receive count read_len by 1; S104, determine whether an end flag has been received. The end flag is at least one of a newline character and a URC flag. If yes, proceed to S105; otherwise, return to S101. S105, determine if the variable is_full is equal to 1. If so, clear the circular buffer queue ring_buf and indicate an error reading command line data; If not, a message will be displayed indicating that the command line data was read successfully.

4. The AT command parsing method according to claim 1, characterized in that, Method for storing instruction line data in the circular buffer queue ring_buf: S401: The main controller detects an incoming serial port interrupt and checks whether instruction line data has been received in the serial port register. If yes, it executes S402; otherwise, it continues to detect. S402, the master controller stores the received instruction line data into the circular buffer queue ring_buf and releases the rx_notice semaphore once, completing the storage of instruction line data.

5. A terminal, characterized in that, include: One or more processors; A memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the AT instruction parsing method as described in any one of claims 1-4.

6. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the AT instruction parsing method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Simulation serial port testing method and device

    CN103580942A

  • Queue-based AT instruction control method

    CN113179227A