CN106658688B - System and method for realizing GSM module control in single chip microcomputer - Google Patents

System and method for realizing GSM module control in single chip microcomputer Download PDF

Info

Publication number
CN106658688B
CN106658688B CN201710020080.0A CN201710020080A CN106658688B CN 106658688 B CN106658688 B CN 106658688B CN 201710020080 A CN201710020080 A CN 201710020080A CN 106658688 B CN106658688 B CN 106658688B
Authority
CN
China
Prior art keywords
task
function
gsm
layer
reply
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710020080.0A
Other languages
Chinese (zh)
Other versions
CN106658688A (en
Inventor
颜昊霖
牟荣增
王宏飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kunshan Microelectronics Technology Research Institute
Original Assignee
Institute of Microelectronics of CAS
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Institute of Microelectronics of CAS filed Critical Institute of Microelectronics of CAS
Priority to CN201710020080.0A priority Critical patent/CN106658688B/en
Publication of CN106658688A publication Critical patent/CN106658688A/en
Application granted granted Critical
Publication of CN106658688B publication Critical patent/CN106658688B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. TPC [Transmission Power Control], power saving or power classes
    • H04W52/02Power saving arrangements
    • H04W52/0209Power saving arrangements in terminal devices
    • H04W52/0225Power saving arrangements in terminal devices using monitoring of external events, e.g. the presence of a signal
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention discloses a system for realizing GSM module control in a single chip microcomputer, which comprises a GSM task scheduling layer, a task processing and cancelling layer, a task executing layer, a function packaging layer, a bottom layer driving layer and a global variable layer, wherein the GSM task scheduling layer, the task processing and cancelling layer, the task executing layer, the function packaging layer and the bottom layer driving layer are sequentially connected and are all connected with the global variable layer. The invention divides the GSM task into the function sequence of the GSM module by five layers and a software architecture of a global variable layer, each time calls the task execution function to execute a function packaging function, the function packaging function can quickly respond to the AT command with reply in a short time by detecting the reply in a synchronous mode through asynchronous control, and for the AT command with longer reply time, the reply is detected in an asynchronous mode, thereby reducing the waiting time of the reply and reducing the system power consumption.

Description

System and method for realizing GSM module control in single chip microcomputer
Technical Field
The invention relates to the field of wireless communication, in particular to an embedded system for realizing low-power consumption control of a GSM wireless communication module on a singlechip and a working method thereof, and more particularly relates to the embedded software architecture for realizing the low-power consumption control of the GSM module.
Background
The GSM (global System for Mobile communication) technology is widely known, and the core module thereof is a GSM wireless communication module, which refers to a software module conforming to the GSM specification and having all basic functions based on the GSM network, such as sending short messages, voice calls, GPRS data transmission, and the like, and is also referred to as a GSM module for short.
Most intelligent hardware products on the market are attached with communication modules, and a WIFI module, a Bluetooth module and a GSM module can be selected according to the requirements. Among them, the GSM module has wide network coverage and small application limitation, and is one of the most popular communication schemes on intelligent hardware. In general intelligent hardware development, a single chip microcomputer controls a communication module and other related peripheral devices, wherein the communication module is the most complex part, and the perfection of control logic of the communication module directly influences the stability, power consumption and functionality of the single chip microcomputer, so that the value of a final intelligent hardware product is influenced.
The existing software architectures (hereinafter referred to as software architectures) for controlling a communication module through a single chip microcomputer are roughly two types:
(1) data transparent transmission: the GSM module is configured into a data transparent transmission mode, and is in an open state in the operation period of the whole system. This approach is simple to program and does not require complex software design, but the GSM module functions that can be used are limited to GPRS data transmission. Meanwhile, the GSM module is kept on, so that the circuit power consumption is large, and the GSM module is not suitable for products with strict requirements on power consumption.
(2) The synchronous control type: and controlling the GSM module by using the AT command, and blocking the program until the GSM module returns a result after the AT command is sent out. In order to prevent the program from locking, a timeout period is generally set, and if the return time exceeds the timeout period, the command is considered to fail. This approach is simpler to program, but has certain drawbacks: the return time of the AT instruction which consumes longer time is not fixed, if the overtime time is set to be too short, the command failure rate is high, and if the overtime time is set to be too long, the system blocking time is too long, so that the system processing speed is influenced. Furthermore, no matter how the timeout is set, there is some congestion of the system, resulting in a degradation of the user experience.
These prior arts have the following disadvantages. In the data transparent transmission type architecture, the power consumption is high because the GSM module is turned on for too long, and in addition, the GSM module is turned on continuously, so that the functions except GPRS data transmission cannot be used. In a synchronous control type framework, the overtime time of a long command is difficult to set properly, if the overtime time is too high, the system blocks for a long time, if the overtime time is too low, the command success rate is low, and the system block necessarily causes the reduction of user experience.
Disclosure of Invention
The present invention is directed to solving the above-mentioned problems of the prior art, and the object of the present invention is achieved by the following technical solutions.
The invention provides a method for realizing GSM module control in a singlechip, which is characterized by comprising the following steps:
step S1: detecting whether a module starting command is received, if not, returning to other service logics, continuing to wait, if so, judging whether a task to be executed is a GSM task, if not, closing the GSM module, and if so, entering step S2;
step S2: executing GSM task scheduling;
step S3: after the GSM task scheduling is finished, returning to other service logics and continuously waiting for a new command.
Further, the method for executing the GSM task scheduling in step S2 includes:
step S201: the GSM task scheduling layer of the system judges whether the task is in progress, if the task is in progress, the GSM task scheduling layer enters a task execution processing link, and if the task is not in progress, a task is taken out from a task queue and enters the task execution processing link;
step S202: in the task execution processing link, judging whether the module has errors, if not, indicating that the execution is successful, and exiting the current task; if so, adding 1 to the value in the error counter, and proceeding to step S203;
step S203: judging whether the numerical value of the error counter exceeds a preset threshold value or not, if not, correcting the GSM state machine, and exiting the current task; if the threshold is exceeded, a task undo operation S204 is performed;
step S204: executing module detection, if the detection is not passed, stopping the module, and exiting the current task; if the detection passes, the value of the error counter is cleared and the current task is exited.
Further, the task execution processing link comprises:
step S201-1: judging whether asynchronous reply is waiting according to the asynchronous waiting flag bit, if not, entering step S201-2, and if so, entering step S201-3;
step S201-2: judging which task is currently executed, calling a task execution function according to the task number, if the task execution function has an error, setting a module error bit in a GSM state variable, and exiting a task execution processing link; if the task execution function has no error, the task execution processing link is quitted after the execution is finished;
step S201-3: detecting whether an asynchronous reply is received, if the asynchronous reply is overtime or fails, setting a module error bit in a GSM state variable, and exiting a task execution processing link; if the asynchronous reply overtime or failure is not detected, the asynchronous reply success detection is continued, if the asynchronous reply is successful, the asynchronous waiting flag bit is reset, and the task execution processing link is quitted; and if the asynchronous reply success is not detected yet, directly exiting the task execution processing link.
Further, the running method of the task execution function comprises the following steps:
step S201-2-a: judging the state of the current module according to the task content, and determining which function encapsulation function needs to be executed;
step S201-2-b: calling a corresponding function packaging function according to the determined function packaging function number;
step S201-2-c: and judging whether the function encapsulation function has errors or not, if so, returning to be wrong, and otherwise, returning to be normal.
Further, the function encapsulation function combines one or more AT commands to be continuously executed, and executes the AT commands replied in a short time in a synchronous manner;
for AT commands with long reply time, the AT command is placed AT the end of the function encapsulation function, and a wait long reply flag bit is set.
Further, the execution method of the function encapsulation function comprises the following steps:
step ss 1: executing the AT command with reply in a short time, judging whether the execution is successful, and if the execution is unsuccessful, returning to 'failure'; if the execution is successful, setting a GSM module state machine in the GSM state variable, and continuously executing a subsequent AT command;
step ss 2: executing the AT command replied for a long time, setting a waiting long reply flag bit, and setting a GSM module state machine in a GSM state variable;
step ss 3: after the AT commands are executed, the success is returned.
Further, the specific command is saved in a long-time AT command list, the system queries the long-time AT command list when processing the AT command to be executed, if the AT command to be executed is included in the list, the AT command to be executed belongs to the AT command replied for a long time, and if the AT command to be executed is not included in the list, the AT command replied for a short time belongs to the AT command replied for a short time.
The invention also provides a system for realizing the control of the GSM module in the singlechip, which comprises:
the GSM task scheduling layer is used for switching GSM tasks, calling a task processing function and a task canceling function, and correcting a GSM state machine if a module error is detected;
the task processing and revocation layer is used for calling a corresponding task processing function according to the current task; when the task needs to be cancelled, calling a corresponding task cancelling function, and carrying out corresponding cancelling work according to the current task;
the task execution layer comprises at least one task execution function, each GSM task corresponds to one task execution function and is used for calling a corresponding function according to specific service logic and the current state of the module;
the function packaging layer is used for packaging one or more AT instructions and controlling the GSM module to realize specific functions;
the bottom layer driving layer is used for executing the sending of the AT command and the receiving and the detection of the reply;
the system also comprises a global variable layer which comprises GSM state variables and is used for exchanging information among the GSM task scheduling layer, the task processing and revocation layer, the task execution layer, the function encapsulation layer and the bottom layer driving layer;
the GSM task scheduling layer, the task processing and revocation layer, the task execution layer, the function encapsulation layer and the bottom layer driving layer are sequentially connected and are all connected with the global variable layer.
Further, the GSM state variables have stored therein: the method comprises the steps of a GSM module state machine, a GSM task queue, a currently executed task, a currently executed function, a receiving cache, a sending cache and a module error bit, wherein the GSM module state machine needs to be set after each function is successfully packaged and executed.
Further, wherein the bottom layer driver layer includes three bottom layer driver functions: a command sending function, a reply receiving function, and a reply detection function configured to: firstly, clearing a receiving cache by the command sending function, and then sending the content in the sending cache to a GSM module through a serial port; secondly, calling a reply receiving function in the serial port interruption, and storing the character string replied by the serial port into a receiving cache; and, the reply detection function scans the receive cache to determine whether there is a reply and the contents of the reply.
The invention is based on the original software architecture for controlling the GSM module on the single chip microcomputer, and has the following characteristics: 1. the software architecture of the invention has lower power consumption, and is particularly suitable for portable intelligent hardware products. 2. The invention combines synchronous control with asynchronous control to minimize the time consumption of blocking ring segments. 3. The invention has no limit to the GPRS data to be transmitted and received due to the flexibility of the GSM module. 4. The invention can support the GSM basic functions of short message receiving and sending and GPRS data transmission. 5. The invention can realize the encapsulation of the GSM function and the decoupling with the main program code, and reduce the code amount needing to be rewritten when the GSM module is replaced. Through the improvement of the invention, the control of low power consumption, high efficiency and high compatibility of the GSM module can be realized on the singlechip.
Compared with the prior art, the invention divides the GSM task into the function sequence of the GSM module by five-layer division and a software architecture of a set of global variables, each time the task execution function is called, a function encapsulation function is executed, the function encapsulation function detects the reply of the AT command with reply in a short time by a synchronous mode through asynchronous control, can quickly respond, and detects the reply of the AT command with longer reply time by an asynchronous mode, thereby greatly reducing the waiting time of the reply.
In summary, the invention has the advantages that: compared with a data transparent transmission structure, the GSM module is closed in idle and opened in case of a task, so that the power consumption can be reduced, and the GSM module does not need to be always kept in a GPRS connection state (only needs to be opened when needed), so that a short message function can be used; compared with a synchronous control type framework, the invention detects and replies the AT command with long time consumption in an asynchronous mode, can set larger overtime time compared with a synchronous mode, thus having higher stability and not influencing user experience, and besides, clearly encapsulates and subpackages program codes needing to be realized, wherein only a functional encapsulation layer is directly related to a GSM module, thus reducing the code quantity needing to be modified when the module changes.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 shows a system framework diagram for implementing GSM module control in a single chip according to an embodiment of the present invention.
FIG. 2 is a flow chart showing the execution of a main program in the system according to the embodiment of the present invention.
Fig. 3 shows a flow chart of a specific implementation method of GSM task scheduling according to an embodiment of the present invention.
Fig. 4 is a flow chart of a specific working method of a task processing and revocation layer according to an embodiment of the present invention.
FIG. 5 is a flow chart illustrating a method for executing a task execution function according to an embodiment of the present invention.
FIG. 6 is a flow chart illustrating a method for performing a function wrapper function according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
According to an embodiment of the present invention, the present invention includes at least an 8-bit single chip microcomputer in terms of hardware; RAM above 1KB, with 512B as receive buffer and 512B as transmit buffer; a GSM module; and the serial port between the GSM module and the singlechip is connected with TX and RX wires for example. The single chip microcomputer receives the reply of the GSM module in a serial port interrupt mode.
In terms of software, the system for realizing the control of the GSM module in the single chip microcomputer comprises a five-layer structure, and fig. 1 shows a structural block diagram of the software system of the invention, which comprises the five-layer structure, and sequentially comprises the following steps: the system comprises a GSM task scheduling layer, a task processing and revocation layer, a task execution layer, a function encapsulation layer and a bottom layer driving layer. Information is exchanged between five layers by using a set of global variables (GSM state variables), wherein the composition principle of each layer is arranged according to the hierarchy in the program call tree.
Specifically, the GSM state variables hold: the GSM module state machine, the GSM task queue, the currently executed task, the currently executed function, the receiving cache, the sending cache, the module error bit and the like are used for connection and control among all layers. And the GSM task scheduling layer is used for switching the GSM task, calling a task processing function and a task canceling function, and correcting the state machine if a module error is detected. The task processing and revocation layer calls a corresponding task processing function according to the current task; when the task needs to be cancelled, a corresponding task cancelling function is called, and corresponding cancelling work is carried out according to the current task. The task execution layer comprises at least one task execution function, and the task execution function calls a corresponding function according to specific business logic and the current state of the module. Each GSM task has a corresponding task execution function. The function packaging layer packs one or more AT instructions and controls the GSM module to realize a certain function. After each function package is successfully executed, a state machine of the GSM module needs to be set. The underlying driver layer is used to perform the sending of AT commands and the receiving and detection of replies.
Figure 2 shows the main program execution flow of the system according to the invention. The invention relates to a method for realizing GSM module control in a singlechip, which comprises the following steps of firstly detecting a module in a device, if the detection is not passed, stopping the module, and entering other service logics, and if the detection is passed, directly entering the other service logics, and executing the following steps:
step S1: detecting whether a module starting command is received, if not, returning to other service logics, continuing to wait, if so, judging whether a task to be executed is a GSM task, if not, closing the GSM module, and if so, entering step S2;
step S2: executing GSM task scheduling;
step S3: after the GSM task scheduling is finished, returning to other service logics and continuously waiting for a new command.
The specific execution method flow of the GSM task scheduling in step S2 is shown in fig. 3, and includes:
step S201: the GSM task scheduling layer of the system judges whether the task is in progress, if the task is in progress, the GSM task scheduling layer enters a task execution processing link, and if the task is not in progress, a task is taken out from a task queue and enters the task execution processing link; taking out a task from the task queue, preferably selecting the task with the highest priority;
step S202: in the task execution processing link, judging whether the module has errors, if not, indicating that the execution is successful, and exiting the current task; if so, adding 1 to the value in the error counter, and proceeding to step S203;
step S203: judging whether the numerical value of the error counter exceeds a preset threshold value or not, if not, correcting the GSM state machine, and exiting the current task; if the threshold is exceeded, a task undo operation S204 is performed;
step S204: executing module detection, if the detection is not passed, stopping the module, and exiting the current task; if the detection passes, the value of the error counter is cleared and the current task is exited.
It should be noted that the specific implementation process of the GSM task scheduling in the present invention is not only completed by the GSM task scheduling layer in the system. In the execution process, a task processing module and a task revocation module of a task processing and revocation layer need to be called to perform task execution processing and task revocation operations, and the task processing module and the task revocation module respectively comprise a task execution function and a task revocation function. In addition, the determination steps in the above steps S202 and S203 may be executed by the task processing module, or may be executed by the GSM task scheduling layer.
Fig. 4 shows a specific working method of the task processing and revocation layer, where the method for executing and processing the task specifically includes:
step S201-1: judging whether asynchronous reply is waiting according to the asynchronous waiting flag bit, if not, entering step S201-2, and if so, entering step S201-3;
step S201-2: judging which task is currently executed, calling a task execution function according to the task number, such as calling a task 1 execution function, a task 2 execution function, a task 3 execution function and the like, if the task execution function has errors, setting a module error bit in a GSM state variable, and exiting a task execution processing link; if the task execution function has no error, the task execution processing link is quitted after the execution is finished;
step S201-3: detecting whether an asynchronous reply is received, if the asynchronous reply is overtime or fails, setting a module error bit in a GSM state variable, and exiting a task execution processing link; if the asynchronous reply overtime or failure is not detected, the asynchronous reply success detection is carried out again, so that the correctness of the asynchronous reply is repeatedly determined, and the running accuracy of the system is improved. If the asynchronous reply is successful, resetting the asynchronous waiting flag bit and exiting the task execution processing link; and if the asynchronous reply success is not detected yet, directly exiting the task execution processing link.
The task execution function is included in a task execution layer of the system, which includes task-specific business logic. When the task execution function is called, the function encapsulation function to be executed is determined according to the actual task content, and an error/correctness is returned according to the execution result of the function encapsulation function, referring to fig. 5. The running method of the task execution function comprises the following steps:
step S201-2-a: judging the state of the current module according to the task content, and determining which function encapsulation function needs to be executed;
step S201-2-b: calling corresponding function packaging functions, such as a function 1 packaging function, a function 2 packaging function and a function 3 packaging function, according to the determined result;
step S201-2-c: and judging whether the function encapsulation function has errors or not, if so, returning to be wrong, and otherwise, returning to be normal.
The function encapsulation function is included in the function encapsulation layer of the system of the present invention, which combines one or more AT commands together for continuous execution. Specifically, the AT command with reply in a short time is processed in a synchronous mode; whereas if a long AT command needs to be executed in the functional wrapper function, the command must be placed AT the end of the functional wrapper function and a long reply wait bit is set. If the function encapsulation function is successfully executed, the state of the GSM module in the GSM state variable needs to be correspondingly set. An exemplary flowchart of a method for executing a function encapsulation function according to the present invention is shown in fig. 6, and includes:
step I: firstly, executing an AT command 1 with a reply in a short time, judging whether the execution is successful, and if the execution is unsuccessful, returning to 'failure'; if the execution is successful, setting a GSM module state machine in the GSM state variable, and continuously executing a subsequent AT command;
step II: executing AT command 2 with reply in short time, and judging whether the execution is successful, if not, returning to 'failure'; if the execution is successful, setting the GSM module state machine in the GSM state variable again, and continuously executing the subsequent AT command;
step III: and executing the AT command 1 replied for a long time, setting a waiting long reply flag bit, and setting a GSM module state machine in a GSM state variable. The wait long reply flag is used to indicate that the system is waiting for the reply of AT command 1 for this long reply.
Step IV: after the AT commands are executed, the success is returned.
In the above method, the number of AT commands replied in a short time is not limited, and fig. 6 illustrates 2 AT commands only for clarity of the example, and in an actual system, the number of AT commands may be 1 or more than 2, and the number of repetitions of step I is changed accordingly. However, it should be noted that if the number of AT commands is too large and the execution time is too long, the maximum delay of each main cycle of the system will increase, which is not favorable for the operation of the system.
In addition, the flow corresponding to AT command 1 replied for a long time is represented by a dashed box in fig. 6 because it is an optional item, if there is AT command replied for a long time, step III is performed, and if not, step III can be ignored. Similarly, only 1 AT command is taken as an illustration here, and the actual system may not be limited to 1.
Further, the differentiation criteria of the AT command replied in a short time and the AT command replied in a long time may be preset by a developer. For example, a specific command may be set as an AT command replied for a long time, and the remaining commands all belong to AT commands replied for a short time. Specifically, a specific command may be saved in a long-time AT command list, which is queried by the system upon distinguishing the kind of the AT command to be executed, and if the AT command to be executed is included in the list, the AT command to be executed belongs to the AT command replied for a long time, and if the AT command to be executed is not included in the list, the AT command replied for a short time.
The distinguishing criterion may also be trained by the system, for example, a time threshold t is set, when the number of times that the reply time of the same AT command exceeds t reaches a predetermined limit, the AT command is recorded as an AT command replied for a long time, otherwise, the AT command replied for a short time is recorded as an AT command replied for a short time. The benefit of system training is that the classification of the AT command can be flexibly adjusted according to the actual situation of the system, so that the execution process of the AT command can be better adapted to the current platform.
The bottom layer driver layer includes three bottom layer driver functions: a command sending function, a reply receiving function, and a reply detecting function. During specific execution, firstly, clearing the receiving cache by the command sending function, and then sending the content in the sending cache to the GSM module through the serial port; secondly, calling a reply receiving function in the serial port interruption, and storing the character string replied by the serial port into a receiving cache; in addition, the reply detection function scans the receive cache to determine whether there is a reply and the contents of the reply.
The system for realizing the control of the GSM module in the singlechip also comprises two error processing functions: a GSM state machine correction function and a module detection function. The GSM state machine correction function is used for sending a relevant AT command to confirm the current state of the GSM module when a program has an error, and correspondingly setting the GSM module state machine, and the GSM state machine correction function can be used for executing GSM state machine correction, for example. The module detection function is used for sending related AT commands to detect whether the module functions normally or not, and can be used for executing module detection.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (8)

1. A method for realizing GSM module control in a singlechip is characterized by comprising the following steps:
step S1: detecting whether a module starting command is received, if not, returning to other service logics, continuing to wait, if so, judging whether a task to be executed is a GSM task, if not, closing the GSM module, and if so, entering step S2;
step S2: executing GSM task scheduling;
step S3: after the GSM task scheduling is finished, returning to the rest service logic, and continuing to wait for a new command, wherein the method for executing the GSM task scheduling in step S2 includes:
step S201: judging whether the task is in progress by a GSM task scheduling layer, if so, entering a task execution processing link, and if not, taking out a task from a task queue and entering the task execution processing link;
step S202: in the task execution processing link, judging whether the module has errors, if not, indicating that the execution is successful, and exiting the current task; if so, adding 1 to the value in the error counter, and proceeding to step S203;
step S203: judging whether the numerical value of the error counter exceeds a preset threshold value or not, if not, correcting the GSM state machine, and exiting the current task; if the threshold is exceeded, a task undo operation S204 is performed;
step S204: executing module detection, if the detection is not passed, stopping the module, and exiting the current task; if the detection is passed, clearing the value of the error counter, and exiting the current task, wherein the task execution processing links in step 201 and step 202 include:
step S201-1: judging whether asynchronous reply is waiting according to the asynchronous waiting flag bit, if not, entering step S201-2, and if so, entering step S201-3;
step S201-2: judging which task is currently executed, calling a task execution function according to the task number, if the task execution function has an error, setting a module error bit in a GSM state variable, and exiting a task execution processing link; if the task execution function has no error, the task execution processing link is quitted after the execution is finished;
step S201-3: detecting whether an asynchronous reply is received, if the asynchronous reply is overtime or fails, setting a module error bit in a GSM state variable, and exiting a task execution processing link; if the asynchronous reply overtime or failure is not detected, the asynchronous reply success detection is continued, if the asynchronous reply is successful, the asynchronous waiting flag bit is reset, and the task execution processing link is quitted; and if the asynchronous reply success is not detected yet, directly exiting the task execution processing link.
2. The method of claim 1, wherein the method of executing the task execution function comprises:
step S201-2-a: judging the state of the current module according to the task content, and determining which function encapsulation function needs to be executed;
step S201-2-b: calling a corresponding function packaging function according to the determined function packaging function number;
step S201-2-c: and judging whether the function encapsulation function has errors or not, if so, returning to be wrong, and otherwise, returning to be normal.
3. The method of claim 2, wherein the function wrapper function combines one or more AT commands for continuous execution and executes in a synchronous manner for AT commands that are replied in a short time;
for AT commands with long reply time, the AT command is placed AT the end of the function encapsulation function, and a wait long reply flag bit is set.
4. The method of claim 3, wherein the method of executing the function wrapper function comprises:
step ss 1: executing the AT command with reply in a short time, judging whether the execution is successful, and if the execution is unsuccessful, returning to 'failure'; if the execution is successful, setting a GSM module state machine in the GSM state variable, and continuously executing a subsequent AT command;
step ss 2: executing the AT command replied for a long time, setting a waiting long reply flag bit, and setting a GSM module state machine in a GSM state variable;
step ss 3: after the AT commands are executed, the success is returned.
5. The method of claim 4, wherein the specific command is stored in a long time AT command list, the system queries the long time AT command list when processing the AT command to be executed, if the AT command to be executed is included in the list, the AT command to be executed belongs to the AT command replied for a long time, if not included in the list, the AT command replied for a short time.
6. A system for implementing GSM module control in a single chip microcomputer for performing the method of any one of claims 1-5, the system comprising:
the GSM task scheduling layer is used for switching GSM tasks, calling a task processing function and a task canceling function, and correcting a GSM state machine if a module error is detected;
the task processing and revocation layer is used for calling a corresponding task processing function according to the current task; when the task needs to be cancelled, calling a corresponding task cancelling function, and carrying out corresponding cancelling work according to the current task;
the task execution layer comprises at least one task execution function, each GSM task corresponds to one task execution function and is used for calling a corresponding function according to specific service logic and the current state of the module;
the function packaging layer is used for packaging one or more AT instructions and controlling the GSM module to realize specific functions;
the bottom layer driving layer is used for executing the sending of the AT command and the receiving and the detection of the reply;
the system also comprises a global variable layer which comprises GSM state variables and is used for exchanging information among the GSM task scheduling layer, the task processing and revocation layer, the task execution layer, the function encapsulation layer and the bottom layer driving layer;
the GSM task scheduling layer, the task processing and revocation layer, the task execution layer, the function encapsulation layer and the bottom layer driving layer are sequentially connected and are all connected with the global variable layer.
7. The system of claim 6, wherein the GSM state variables have stored therein: the method comprises the steps of a GSM module state machine, a GSM task queue, a currently executed task, a currently executed function, a receiving cache, a sending cache and a module error bit, wherein the GSM module state machine needs to be set after each function is successfully packaged and executed.
8. The system of claim 7, wherein the bottom layer driver layer includes three bottom layer driver functions: a command sending function, a reply receiving function, and a reply detection function configured to:
firstly, clearing a receiving cache by the command sending function, and then sending the content in the sending cache to a GSM module through a serial port;
secondly, calling a reply receiving function in the serial port interruption, and storing the character string replied by the serial port into a receiving cache;
and, the reply detection function scans the receive cache to determine whether there is a reply and the contents of the reply.
CN201710020080.0A 2017-01-11 2017-01-11 System and method for realizing GSM module control in single chip microcomputer Active CN106658688B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710020080.0A CN106658688B (en) 2017-01-11 2017-01-11 System and method for realizing GSM module control in single chip microcomputer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710020080.0A CN106658688B (en) 2017-01-11 2017-01-11 System and method for realizing GSM module control in single chip microcomputer

Publications (2)

Publication Number Publication Date
CN106658688A CN106658688A (en) 2017-05-10
CN106658688B true CN106658688B (en) 2020-01-10

Family

ID=58842732

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710020080.0A Active CN106658688B (en) 2017-01-11 2017-01-11 System and method for realizing GSM module control in single chip microcomputer

Country Status (1)

Country Link
CN (1) CN106658688B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111615099B (en) * 2020-04-28 2023-07-04 深圳市有方科技股份有限公司 eSIM card interaction control method and related equipment
CN113179227B (en) * 2021-04-26 2023-05-19 哈尔滨铁路科研所科技有限公司 AT instruction control method based on queue

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853155A (en) * 2010-04-15 2010-10-06 中兴通讯股份有限公司 Method and device for automatically sending AT command
CN102256239A (en) * 2011-07-05 2011-11-23 华为终端有限公司 Multimode terminal and data processing method for multimode terminal
WO2014002968A1 (en) * 2012-06-25 2014-01-03 京セラ株式会社 Communication terminal and communication control method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101853155A (en) * 2010-04-15 2010-10-06 中兴通讯股份有限公司 Method and device for automatically sending AT command
CN102256239A (en) * 2011-07-05 2011-11-23 华为终端有限公司 Multimode terminal and data processing method for multimode terminal
WO2014002968A1 (en) * 2012-06-25 2014-01-03 京セラ株式会社 Communication terminal and communication control method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
单片机控制GSM模块实现短信收发的技术及应用;牛丹,等;《仪器仪表与分析监测》;20080831;全文 *

Also Published As

Publication number Publication date
CN106658688A (en) 2017-05-10

Similar Documents

Publication Publication Date Title
EP2701074B1 (en) Method, device, and system for performing scheduling in multi-processor core system
CN109688058B (en) Message processing method and device and network equipment
WO2007104330A1 (en) Task scheduling method and apparatus
US9928077B2 (en) Chip starting method, multi-core processor chip and storage medium
CN101887383B (en) Process real-time scheduling method
JPWO2009133669A1 (en) Virtual machine control device, virtual machine control method, and virtual machine control program
US8539509B2 (en) Event queue managing device and event queue managing method
CN106878164A (en) A kind of message transmitting method and device
CN106658688B (en) System and method for realizing GSM module control in single chip microcomputer
CN101788949A (en) Method and device for realizing embedded type system function monitoring
CN112910802B (en) Message processing method and device
US8201070B2 (en) System and method for pre-calculating checksums
CN111200541A (en) Network data processing method and device
Evers et al. Sensorscheme: Supply chain management automation using wireless sensor networks
CN111143034A (en) Method, device and system for controlling network data forwarding plane
CN114205183A (en) Communication method and system of AT instruction protocol stack based on real-time operating system
CN117544504A (en) Data processing unit thermal updating method, device, communication equipment and storage medium
CN101604270B (en) ARINC 429 communication redundancy method based on vxworks operation system
JP5244082B2 (en) Real-time distributed control system, real-time distributed control method, and robot
EP2592792B1 (en) Instruction processing method of network processor and network processor
CN110069042B (en) Production flow process control method, device, software system and control system
CN114327882A (en) Data forwarding method, device and system
CN113238855A (en) Path detection method and device
CN108616461B (en) Policy switching method and device
CN109932997A (en) A kind of programmable logic controller (PLC) core system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 215347 no.707, complex building, Kunshan Industrial Technology Research Institute, no.1699, Zuchongzhi South Road, Kunshan, Suzhou, Jiangsu Province

Patentee after: Kunshan Microelectronics Technology Research Institute

Address before: 215347 7th floor, IIR complex, 1699 Weicheng South Road, Kunshan City, Suzhou City, Jiangsu Province

Patentee before: KUNSHAN BRANCH, INSTITUTE OF MICROELECTRONICS OF CHINESE ACADEMY OF SCIENCES