CN113177013B - Baud rate-based serial communication method and multi-serial chip - Google Patents
Baud rate-based serial communication method and multi-serial chip Download PDFInfo
- Publication number
- CN113177013B CN113177013B CN202110564471.5A CN202110564471A CN113177013B CN 113177013 B CN113177013 B CN 113177013B CN 202110564471 A CN202110564471 A CN 202110564471A CN 113177013 B CN113177013 B CN 113177013B
- Authority
- CN
- China
- Prior art keywords
- target
- bottom layer
- protocol
- serial port
- serial
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2213/00—Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F2213/0002—Serial port, e.g. RS232C
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02T—CLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
- Y02T90/00—Enabling technologies or technologies with a potential or indirect contribution to GHG emissions mitigation
- Y02T90/10—Technologies relating to charging of electric vehicles
- Y02T90/16—Information or communication technologies improving the operation of electric vehicles
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Communication Control (AREA)
Abstract
The invention is suitable for the technical field of data communication, and provides a serial communication method based on a baud rate and a multi-serial chip, wherein the method comprises the following steps: the bottom layer configuration module receives first target data of a target serial port; the bottom layer configuration module determines a target bottom layer object corresponding to the target serial port in the bottom layer objects; the bottom layer objects are constructed in advance based on an object-oriented principle, each bottom layer object only corresponds to one serial port, and the serial ports corresponding to the bottom layer objects are different; the target bottom layer object sends the first target data to the protocol analysis module; the protocol analysis module determines a target protocol object corresponding to a target bottom layer object in the plurality of bottom layer objects according to a preset bottom layer object and a protocol slot of the protocol object; the protocol object is constructed in advance based on an object-oriented principle; the target protocol object receives first target data. The invention can enable the multi-serial port chip to process data with different baud rates, thereby enriching the application scene.
Description
Technical Field
The invention belongs to the technical field of data communication, and particularly relates to a serial port communication method based on baud rate and a multi-serial port chip.
Background
With the rapid development of computer technology, more and more electronic devices utilize serial chips for communication, for example, power modules in electric vehicles and charging piles thereof use the serial chips for module control and monitoring. With more and more complex functional requirements, multi-serial chips are often used.
However, each serial port in the current multi-serial port chip can only process data with the same baud rate, and the application scene is single.
Disclosure of Invention
In view of this, embodiments of the present invention provide a serial communication method based on baud rate and a multi-serial chip, which can enrich application scenarios of the multi-serial chip.
The first aspect of the embodiments of the present invention provides a serial port communication method based on baud rate, which is applied to a multi-serial port chip, where the multi-serial port chip includes multiple serial ports, a bottom layer configuration module, and a protocol analysis module, and the method includes:
the bottom layer configuration module receives first target data of a target serial port;
the bottom layer configuration module determines a target bottom layer object corresponding to the target serial port in the plurality of bottom layer objects; the bottom layer objects are constructed in advance based on an object-oriented principle, each bottom layer object only corresponds to one serial port, and the serial ports corresponding to the bottom layer objects are different;
the target bottom layer object sends the first target data to the protocol analysis module;
the protocol analysis module determines a target protocol object corresponding to a target bottom layer object in the plurality of bottom layer objects according to a preset bottom layer object and a protocol slot of the protocol object; the protocol object is constructed in advance based on an object-oriented principle;
the target protocol object receives first target data.
A second aspect of the embodiments of the present invention provides a multi-serial port chip, including a plurality of serial ports, a bottom layer configuration module, and a protocol analysis module, where:
the bottom layer configuration module is used for receiving first target data of a target serial port and determining a target bottom layer object corresponding to the target serial port in the plurality of bottom layer objects; the bottom layer objects are constructed in advance based on an object-oriented principle, each bottom layer object only corresponds to one serial port, and the serial ports corresponding to the bottom layer objects are different;
the target bottom layer object is used for sending the first target data to the protocol analysis module;
the protocol analysis module is used for determining a target protocol object corresponding to the target bottom layer object in the bottom layer objects according to a preset bottom layer object and a protocol slot of the protocol object; the protocol object is constructed in advance based on an object-oriented principle;
a target protocol object to receive first target data.
A third aspect of the embodiments of the present invention provides a multi-serial port chip, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method according to the first aspect when executing the computer program.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, after the bottom layer configuration module of the multi-serial port chip receives the first target data of the target serial port, the target bottom layer object corresponding to the target serial port can be determined in the plurality of bottom layer objects. And then, the target bottom layer object sends the first target data to the protocol analysis module. And then, the protocol analysis module determines a target protocol object corresponding to the target bottom layer object in the plurality of bottom layer objects according to the preset bottom layer objects and the protocol slots of the protocol objects. Finally, the target protocol object receives the first target data. Therefore, a group of bottom layer objects and protocol objects are established for each serial port of the multi-serial port chip, when a certain serial port is externally connected with hardware, the data of the hardware can be processed by the bottom layer objects and the protocol objects corresponding to the serial port, and the serial port communication of the hardware and the multi-serial port chip is completed. Therefore, the multi-serial port chip can process data with different kinds of baud rates, and application scenes of the multi-serial port chip are enriched.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic diagram of an architecture of a multi-serial port chip according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating steps of a baud rate-based serial communication method according to an embodiment of the present invention;
fig. 3 is a schematic signal flow diagram of a multi-serial port communication architecture according to an embodiment of the present invention;
FIG. 4 is a flow chart of object construction according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a data receiving process of a bottom layer configuration module according to an embodiment of the present invention;
fig. 6 is a schematic diagram illustrating a sending processing flow of a bottom layer configuration module according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a multi-serial port chip according to an embodiment of the present invention;
fig. 8 is a schematic diagram of a multi-serial-port chip according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
As described in the background art, in the current multi-serial-port chip, each serial port can only process data of the same baud rate, and the application scene is single, which greatly limits the application prospect of the multi-serial-port chip.
In order to solve the problems in the prior art, the embodiment of the invention provides a serial communication method based on baud rate and a multi-serial chip. The following first describes a multi-serial-port chip provided in an embodiment of the present invention.
An execution main body of a serial communication method based on baud rate may be a multi-serial chip, and as shown in fig. 1, a schematic diagram of an architecture of the multi-serial chip is shown, where the multi-serial chip may be a chip with multiple serial ports (serial ports 1-n), such as a Digital Signal Processing (DSP) chip, a Field Programmable Gate Array (FPGA) chip, and the like, and each serial port may be externally connected to hardware, such as a charging module of an electric vehicle, a power module of a charging pile, a monitoring device, and the like.
In addition, the multi-serial port chip also comprises software processing modules such as a bottom layer configuration module and a protocol analysis module, wherein the bottom layer configuration module can send data input by each serial port to the protocol analysis module, and the protocol analysis module can analyze a protocol (protocol 0-n) corresponding to each data and send the data to a corresponding protocol unit for processing.
As shown in fig. 2, the serial port communication method based on baud rate according to the embodiment of the present invention may include the following steps:
step S210, the bottom layer configuration module receives first target data of the target serial port.
In some embodiments, each serial port of the multi-serial port chip will be collected in the bottom layer configuration module after receiving externally input data. The target serial port may be any serial port in the plurality of serial ports, and data transmitted through the target serial port may be referred to as first target data.
Step S220, the bottom layer configuration module determines a target bottom layer object corresponding to the target serial port in the bottom layer objects.
The bottom layer objects are constructed in advance based on an object-oriented principle, each bottom layer object uniquely corresponds to one serial port, and the serial ports corresponding to the bottom layer objects are different.
The following describes a specific implementation of the constructed object.
The objects can be divided into a bottom layer object and a protocol object, and each object construction request carries a serial port number, a baud rate, a buffer length and a total count value, wherein the serial port number or the baud rate is a key for distinguishing different objects, and the serial port number and the baud rate are also uniquely corresponding.
The object may be constructed as follows:
receiving an object construction request; and constructing a bottom layer object and a protocol object corresponding to the object construction request according to the serial port number, the baud rate, the buffer area length and the total count value. During the construction process, the bottom layer object and the protocol object can be associated and communicated through a signal slot mechanism. The construction algorithm may use the C + + programming language.
Therefore, the bottom layer configuration module can determine the target bottom layer object corresponding to the target serial port in the plurality of bottom layer objects according to the target serial port.
Step S230, the target underlying object sends the first target data to the protocol parsing module.
In some embodiments, after the target underlying object is determined, the target underlying object sends the first target data.
Optionally, when the serial port of the multi-serial-port chip has a function of processing data with different baud rates, because the data lengths and the data packing times of the data with different baud rates are different, the corresponding data lengths and the data packing times can be set for various types of baud rate data according to the characteristics of the data with different baud rates, and the setting process can be completed in an object construction stage, namely the buffer length and the total count value in the object construction request.
Specifically, the target bottom layer object writes first target data into a buffer area in batches by taking the length of the buffer area as a unit, and packs and counts the data written into the buffer area in each batch; when the value of the packing calculation is equal to the total count value, the data obtained by packing is sent to the protocol analysis module until the first target data is sent to the protocol analysis module, so that the problem that one frame of data is sent without being completely received can be solved.
Therefore, the problem that invalid memory occupies a large space due to the adoption of fixed data length and packing time can be avoided, and the memory utilization rate is optimized. In addition, a timing sending mechanism can be introduced, when the packing time exceeds the timing time, the packed data can be sent to the protocol analysis module, so that a channel can be provided for users who want to set the packing time by themselves, and the use experience can be improved.
Step S240, the protocol analysis module determines a target protocol object corresponding to the target bottom layer object in the plurality of bottom layer objects according to the preset bottom layer objects and the protocol slots of the protocol objects;
the protocol object is constructed in advance based on an object-oriented principle.
Step S250, the target protocol object receives the first target data.
In some embodiments, after the target protocol object is determined, the target protocol object receives the first target data and processes the first target data according to the protocol content.
Optionally, after the target protocol object receives the first target data, the following processing may be performed:
the target protocol object sends second target data corresponding to the first target data to the bottom layer configuration module; and the bottom layer configuration module sends the second target data to the target serial port.
In some embodiments, similar to the process of sending the first target data, the target protocol object may write the second target data into the buffer in batches of the buffer length, and perform packing counting on the data written into the buffer in each batch; and when the value of the packing calculation is equal to the total count value, sending the packed data to the bottom layer configuration module until the second target data is sent to the bottom layer configuration module.
Specifically, the second target data carries a serial number of the target serial port. Therefore, the bottom layer configuration module can send the second target data to the target serial port according to the serial port number of the target serial port.
Taking a charging pile scene as an example, a communication line of the electric vehicle may be connected to a target serial port of the multi-serial port chip, and issue a charging start instruction, that is, first target data. After the communication processing, the target protocol object can generate response data corresponding to the charging instruction, namely second target data, and can return the response data to the electric automobile through the target serial port. In addition, the target protocol object can also generate an instruction for triggering charging of the charging pile, and the instruction for triggering charging of the charging pile is sent to the charging pile through a serial port connected with the charging pile, so that the charging pile can charge the electric automobile.
In order to better understand the serial port communication method based on the baud rate provided by the embodiment of the present invention, it can be considered that the multi-serial port chip executing the serial port communication method based on the baud rate is a chip having different serial ports corresponding to different baud rates, that is, having a plurality of serial ports, each of which can correspond to different baud rates. As shown in table one, table one shows the difference between a single serial port chip and a multi-serial port chip.
Watch 1
It can be found that the above serial ports correspond to architectures of a plurality of protocols with different baud rates, and the key point is how the serial ports are associated with the protocols. Therefore, a multi-serial communication architecture can be designed based on an object-oriented method, such as C + +, and the architecture has the following functions:
function 1, apply the signal slot mechanism in the serial communication framework, make the bottom layer configuration and agreement of the whole serial communication analyze the module function decoupling.
And 2, dividing the whole serial communication architecture into a bottom layer configuration module and a protocol analysis module, wherein the modules are isolated from each other and do not interfere with each other.
Function 3, bottom configuration module, can be to facing to the producer of different baud rate demands, establish different configurations for the multi-serial ports chip, realize the receipt and the sending of data, specific:
first, different serial numbers can be selected and linked with the slots of the protocol analysis module.
And secondly, the configuration can be carried out according to different protocol baud rates required by different manufacturer protocols and matching with serial port numbers.
And thirdly, dynamically designing the lengths of a sending buffer area and a receiving buffer area and the time for packing and sending the data to a protocol analysis module according to different data lengths required by protocols of different manufacturers.
Function 4, agreement analysis module can utilize the difference of serial number to establish different agreements as required in advance, realizes the one-to-one of serial number and agreement, has avoided the strong problem of agreement analysis module coupling nature.
As shown in fig. 3, a signal flow diagram of a multi-serial communication architecture is provided.
For the bottom layer configuration module, different registers can be selected according to serial port numbers; designing different baud rate registers according to the baud rate; and designing the length of a receiving buffer area, the length of a sending buffer area and the time for packaging and sending the receiving buffer area and the sending buffer area to a protocol analysis module according to different data lengths. The method comprises the following steps that (1) a unique serial port number can be selected to create a unique bottom layer object according to different protocol baud rates and different data lengths of different manufacturers, as shown in a table II;
watch two
Manufacturer of the product | Baud rate | Data length | Serial number | Creating |
Manufacturer | ||||
0 | 9600 | 10 | 0 | Usart0 |
Manufacturer 1 | 19200 | 12 | 1 | Usart1 |
Manufacturer 2 | 4800 | 8 | 2 | Usart2 |
Therefore, different serial port numbers are constructed to correspond to the bottom layer objects with different baud rates (the data lengths can be the same or different), the created bottom layer objects have uniqueness according to different manufacturers required by protocol baud rates and the like, namely one manufacturer corresponds to one bottom layer object. In addition, the bottom layer configuration module does not need to be modified, and only needs to select the corresponding serial port number, baud rate and received data length during creation, and the specific construction process of the object can be as shown in fig. 4.
Accordingly, as shown in fig. 5 and fig. 6, a data receiving and sending process flow of the underlying configuration module is provided. Specifically, for the receiving process, according to the setting of the configuration initialization process, the length of the receiving buffer and the total packed sending count value are determined, the data in the receiving register is written into the receiving buffer, and the data are counted at the same time, and when the count value reaches the total packed sending count value or the timing time is up, the protocol analysis module is signaled. And for the sending process, a signal of the protocol analysis module is received, the data of the protocol analysis module is copied to a sending buffer area of the serial port bottom layer configuration module, and then the data in the sending buffer area is sent out through a sending register.
Therefore, information such as serial port numbers, baud rates, data lengths and the like is fused into the bottom configuration module, complete decoupling can be realized only by connecting the module with signal slots of all protocols of the protocol analysis module and decoupling all the protocols by the protocol analysis module, and codes do not need to be modified so as to achieve the purpose of universality.
In addition, in order to implement complete decoupling of the program, the protocol analysis module needs to be decoupled, and if the protocol analysis module cannot distinguish each protocol, all the protocols are mixed together, and all the protocols need to be searched one by one, which occupies a lot of operating space. The protocol can be distinguished through the serial number, and specifically, the root for distinguishing the serial number is as follows: different manufacturers require different baud rates, so that each protocol object can be constructed according to different serial port numbers. As shown in table three:
watch III
Serial number | Creating underlying objects | Creating |
0 | Usart0 | Prol0 |
1 | Usart1 | Prol1 |
n | Usartn | Proln |
It is easy to understand that, through serial port numbers, a plurality of bottom layer objects can be constructed, and a plurality of protocol objects can also be constructed, and protocols corresponding to different serial ports can be distinguished only by connecting the bottom layer objects with the protocol objects one by one.
It should be noted that, the connection between the bottom layer configuration module and the signal slot of the protocol analysis module is a key, and specifically, the following is:
1. data reception: the bottom layer configuration module is connected with the groove of the protocol analysis module through signals, and when the bottom layer configuration module sends the signals, the signals are sent to the protocol analysis module together with data length (including receiving length and sending length), so that the protocol analysis module can apply for receiving and sending buffer zones according to the received and sent data length.
2. Data transmission: the signal of the protocol analysis module is connected with the groove of the bottom layer configuration module, the protocol analysis module automatically controls the sending period of the self protocol, only the signal needs to be sent to the bottom layer configuration module at regular time, and the bottom layer configuration module sends the signal after receiving the signal.
In the embodiment of the invention, after the bottom layer configuration module of the multi-serial port chip receives the first target data of the target serial port, the target bottom layer object corresponding to the target serial port can be determined in the plurality of bottom layer objects. And then, the target bottom layer object sends the first target data to the protocol analysis module. And then, the protocol analysis module determines a target protocol object corresponding to the target bottom layer object in the plurality of bottom layer objects according to the preset bottom layer objects and the protocol slots of the protocol objects. Finally, the target protocol object receives the first target data. Therefore, a group of bottom layer objects and protocol objects are established for each serial port of the multi-serial port chip, when a certain serial port is externally connected with hardware, the data of the hardware can be processed by the bottom layer objects and the protocol objects corresponding to the serial port, and the serial port communication of the hardware and the multi-serial port chip is completed. Therefore, the multi-serial port chip can process data with different kinds of baud rates, and application scenes of the multi-serial port chip are enriched.
Based on the serial port communication method based on the baud rate provided by the embodiment, correspondingly, the invention also provides a specific implementation mode of the multi-serial port chip applied to the serial port communication method based on the baud rate. Please see the examples below.
As shown in fig. 7, a multi-serial chip 700 is provided, which includes a plurality of serial ports 710, an underlying configuration module 720 and a protocol parsing module 730, wherein:
the bottom layer configuration module 720 is configured to receive first target data of a target serial port, and determine a target bottom layer object corresponding to the target serial port from among the plurality of bottom layer objects; the bottom layer objects are constructed in advance based on an object-oriented principle, each bottom layer object only corresponds to one serial port, and the serial ports corresponding to the bottom layer objects are different;
the target bottom layer object is used for sending the first target data to the protocol analysis module 730;
the protocol analysis module 730 is configured to determine a target protocol object corresponding to the target underlying object from the plurality of underlying objects according to a preset underlying object and a protocol slot of the protocol object; the protocol object is constructed in advance based on an object-oriented principle;
a target protocol object to receive first target data.
In some embodiments, the multi-serial port chip further comprises a configuration module configured to:
receiving an object construction request; the object construction request carries a serial port number, a baud rate, a buffer area length and a total count value;
and constructing a bottom layer object and a protocol object corresponding to the object construction request according to the serial port number, the baud rate, the buffer area length and the total count value.
In some embodiments, the target underlying object is further to:
writing the first target data into a buffer area in batches by taking the length of the buffer area as a unit, and packing and counting the data written into the buffer area in each batch;
and when the numerical value of the packing calculation is equal to the total counting value, sending the packed data to the protocol analysis module until the first target data is sent to the protocol analysis module.
In some embodiments, the target protocol object is further to:
sending second target data corresponding to the first target data to a bottom layer configuration module;
correspondingly, the bottom layer configuration module is further configured to:
and sending the second target data to the target serial port.
Optionally, the target protocol object is further configured to:
writing the second target data into the buffer area in batches by taking the length of the buffer area as a unit, and packing and counting the data written into the buffer area in each batch;
and when the value of the packing calculation is equal to the total count value, sending the packed data to the bottom layer configuration module until the second target data is sent to the bottom layer configuration module.
Optionally, the second target data carries a serial number of the target serial port;
correspondingly, the bottom layer configuration module is further configured to:
and sending the second target data to the target serial port according to the serial port number of the target serial port.
In the embodiment of the invention, after the bottom layer configuration module of the multi-serial port chip receives the first target data of the target serial port, the target bottom layer object corresponding to the target serial port can be determined in the plurality of bottom layer objects. And then, the target bottom layer object sends the first target data to the protocol analysis module. And then, the protocol analysis module determines a target protocol object corresponding to the target bottom layer object in the plurality of bottom layer objects according to the preset bottom layer objects and the protocol slots of the protocol objects. Finally, the target protocol object receives the first target data. Therefore, a group of bottom layer objects and protocol objects are established for each serial port of the multi-serial port chip, when a certain serial port is externally connected with hardware, the data of the hardware can be processed by the bottom layer objects and the protocol objects corresponding to the serial port, and the serial port communication of the hardware and the multi-serial port chip is completed. Therefore, the multi-serial port chip can process data with different kinds of baud rates, and application scenes of the multi-serial port chip are enriched.
Fig. 8 is a schematic diagram of a multi-serial chip according to an embodiment of the present invention. As shown in fig. 8, the multi-serial chip 8 of this embodiment includes: a processor 80, a memory 81 and a computer program 82 stored in said memory 81 and executable on said processor 80. The processor 80 implements the steps in each of the foregoing embodiments of the serial port communication method based on baud rate when executing the computer program 82. Alternatively, the processor 80 executes the computer program 82 to implement the functions of the modules/units in the embodiments of the multiple serial port chip.
Illustratively, the computer program 82 may be partitioned into one or more modules/units that are stored in the memory 81 and executed by the processor 80 to implement the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 82 in the multi-serial port chip 8. For example, the computer program 82 may be divided into an underlying configuration module and a protocol parsing module, and the specific functions of each module are as follows:
the bottom layer configuration module is used for receiving first target data of a target serial port and determining a target bottom layer object corresponding to the target serial port in the plurality of bottom layer objects; the bottom layer objects are constructed in advance based on an object-oriented principle, each bottom layer object only corresponds to one serial port, and the serial ports corresponding to the bottom layer objects are different;
the target bottom layer object is used for sending the first target data to the protocol analysis module;
the protocol analysis module is used for determining a target protocol object corresponding to the target bottom layer object in the bottom layer objects according to a preset bottom layer object and a protocol slot of the protocol object; the protocol object is constructed in advance based on an object-oriented principle;
a target protocol object to receive first target data.
The multi-serial port chip 8 can be a desktop computer, a notebook computer, a palm computer, a cloud server and other computing devices. The multi-serial port chip may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will appreciate that fig. 8 is only an example of a multi-serial port chip 8, and does not constitute a limitation to the multi-serial port chip 8, and may include more or less components than those shown, or combine some components, or different components, for example, the multi-serial port chip may further include input and output devices, network access devices, buses, etc.
The Processor 80 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 81 may be an internal storage unit of the multi-serial port chip 8, such as a hard disk or a memory of the multi-serial port chip 8. The memory 81 may also be an external storage device of the multi-serial port chip 8, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are equipped on the multi-serial port chip 8. Further, the memory 81 may include both an internal storage unit and an external storage device of the multi-serial port chip 8. The memory 81 is used for storing the computer program and other programs and data required by the multi-serial port chip. The memory 81 may also be used to temporarily store data that has been output or is to be output.
It should be clearly understood by those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional units and modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional units and modules as needed, that is, the internal structure of the multi-serial port chip is divided into different functional units or modules to complete all or part of the above described functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. For the specific working processes of the units and modules in the system, reference may be made to the corresponding processes in the foregoing method embodiments, which are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.
Claims (6)
1. A serial port communication method based on baud rate is characterized in that the method is applied to a multi-serial port chip, the multi-serial port chip comprises a plurality of serial ports, a bottom layer configuration module and a protocol analysis module, and the method comprises the following steps:
the bottom layer configuration module receives first target data of a target serial port;
the bottom layer configuration module determines a target bottom layer object corresponding to the target serial port in a plurality of bottom layer objects; the bottom layer objects are constructed in advance based on an object-oriented principle, each bottom layer object uniquely corresponds to one serial port, and the serial ports corresponding to the bottom layer objects are different;
the target bottom layer object sends the first target data to the protocol analysis module;
the protocol analysis module determines a target protocol object corresponding to the target bottom layer object in the bottom layer objects according to the preset bottom layer object and a protocol slot of the protocol object; the protocol object is constructed in advance based on an object-oriented principle; the bottom layer object and the protocol object are constructed in advance based on an object construction request, and the object construction request carries a serial port number, a baud rate, a buffer area length and a total count value;
the target protocol object receives the first target data;
the sending, by the target underlying object, the first target data to the protocol parsing module includes:
the target bottom layer object writes the first target data into a buffer area in batches by taking the length of the buffer area as a unit, and packs and counts the data written into the buffer area in each batch; and when the numerical value of the packing calculation is equal to the total counting value, sending the packed data to the protocol analysis module until the first target data is sent to the protocol analysis module.
2. The baud rate-based serial communication method of claim 1, wherein after the target protocol object receives the first target data, the method further comprises:
the target protocol object sends second target data corresponding to the first target data to the bottom layer configuration module;
and the bottom layer configuration module sends the second target data to the target serial port.
3. The baud rate-based serial port communication method of claim 2, wherein the target protocol object sends second target data corresponding to the first target data to the underlying configuration module, and the method comprises:
the target protocol object writes the second target data into a buffer area in batches by taking the length of the buffer area as a unit, and packs and counts the data written into the buffer area in each batch;
and when the numerical value of the packing calculation is equal to the total count value, sending the packed data to the bottom layer configuration module until the second target data is sent to the bottom layer configuration module.
4. The baud rate-based serial communication method of claim 2, wherein the second target data carries a serial number of the target serial;
the bottom layer configuration module sends the second target data to the target serial port, and the method comprises the following steps:
and the bottom layer configuration module sends the second target data to the target serial port according to the serial port number of the target serial port.
5. The utility model provides a multi-serial port chip which characterized in that, includes a plurality of serial ports, bottom configuration module and agreement analysis module, wherein:
the bottom layer configuration module is used for receiving first target data of a target serial port and determining a target bottom layer object corresponding to the target serial port in a plurality of bottom layer objects; the bottom layer objects are constructed in advance based on an object-oriented principle, each bottom layer object uniquely corresponds to one serial port, and the serial ports corresponding to the bottom layer objects are different;
the target bottom layer object is used for sending the first target data to the protocol analysis module;
the protocol analysis module is used for determining a target protocol object corresponding to the target bottom layer object in the bottom layer objects according to the preset bottom layer object and a protocol slot of the protocol object; the protocol object is constructed in advance based on an object-oriented principle; the bottom layer object and the protocol object are constructed in advance based on an object construction request, and the object construction request carries a serial port number, a baud rate, a buffer area length and a total count value;
the target protocol object is used for receiving the first target data;
the target bottom layer object is also used for writing the first target data into a buffer area in batches by taking the length of the buffer area as a unit, and packing and counting the data written into the buffer area in each batch; and when the numerical value of the packing calculation is equal to the total counting value, sending the packed data to the protocol analysis module until the first target data is sent to the protocol analysis module.
6. A multi-serial chip comprising a memory, a processor and a computer program stored in said memory and executable on said processor, wherein said processor implements the steps of the method according to any one of claims 1 to 4 when executing said computer program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110564471.5A CN113177013B (en) | 2021-05-24 | 2021-05-24 | Baud rate-based serial communication method and multi-serial chip |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110564471.5A CN113177013B (en) | 2021-05-24 | 2021-05-24 | Baud rate-based serial communication method and multi-serial chip |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113177013A CN113177013A (en) | 2021-07-27 |
CN113177013B true CN113177013B (en) | 2022-09-02 |
Family
ID=76929675
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110564471.5A Active CN113177013B (en) | 2021-05-24 | 2021-05-24 | Baud rate-based serial communication method and multi-serial chip |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113177013B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102270168A (en) * | 2011-08-09 | 2011-12-07 | 西安辉炜信息科技有限公司 | Method for automatically detecting serial port information |
CN106357617A (en) * | 2016-08-28 | 2017-01-25 | 上海新时达电气股份有限公司 | Adaptive method, device, elevator communication system of the communication protocol |
CN107147657A (en) * | 2017-05-31 | 2017-09-08 | 飞智控(天津)科技有限公司 | Suitable for the communication protocol of multimachine reliable communication, decoding method and communication apparatus |
CN108449398A (en) * | 2018-03-06 | 2018-08-24 | 江阴长仪集团有限公司 | A kind of implementation method and electric energy meter of object-oriented data exchange agreement |
CN108600017A (en) * | 2018-04-27 | 2018-09-28 | 中国科学院长春光学精密机械与物理研究所 | Multi-protocols serial ports expansion method |
CN110232038A (en) * | 2019-05-20 | 2019-09-13 | 湖北三江航天红峰控制有限公司 | A kind of industrial personal computer intelligent communication serial port device |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110417766B (en) * | 2019-07-22 | 2021-10-22 | 深圳市酷达通讯有限公司 | Protocol analysis method and device |
-
2021
- 2021-05-24 CN CN202110564471.5A patent/CN113177013B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102270168A (en) * | 2011-08-09 | 2011-12-07 | 西安辉炜信息科技有限公司 | Method for automatically detecting serial port information |
CN106357617A (en) * | 2016-08-28 | 2017-01-25 | 上海新时达电气股份有限公司 | Adaptive method, device, elevator communication system of the communication protocol |
CN107147657A (en) * | 2017-05-31 | 2017-09-08 | 飞智控(天津)科技有限公司 | Suitable for the communication protocol of multimachine reliable communication, decoding method and communication apparatus |
CN108449398A (en) * | 2018-03-06 | 2018-08-24 | 江阴长仪集团有限公司 | A kind of implementation method and electric energy meter of object-oriented data exchange agreement |
CN108600017A (en) * | 2018-04-27 | 2018-09-28 | 中国科学院长春光学精密机械与物理研究所 | Multi-protocols serial ports expansion method |
CN110232038A (en) * | 2019-05-20 | 2019-09-13 | 湖北三江航天红峰控制有限公司 | A kind of industrial personal computer intelligent communication serial port device |
Also Published As
Publication number | Publication date |
---|---|
CN113177013A (en) | 2021-07-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN100568187C (en) | A kind of method and apparatus that is used for debugging message is carried out mask | |
CN107273331A (en) | A kind of heterogeneous computing system and method based on CPU+GPU+FPGA frameworks | |
EP1723532B1 (en) | Multiple burst protocol device controller | |
CN109542398B (en) | Business system generation method and device and computer readable storage medium | |
CN110569038B (en) | Random verification parameter design method, device, computer equipment and storage medium | |
CN113177015B (en) | Frame header-based serial port communication method and serial port chip | |
CN210983400U (en) | System on chip and microcontroller | |
CN115632976A (en) | PCIE transaction layer message generation method, device and storage medium | |
CN111736866A (en) | One-to-one and one-to-many compatible online upgrading method and terminal equipment | |
CN113177013B (en) | Baud rate-based serial communication method and multi-serial chip | |
CN109408035B (en) | Flow configuration method, storage medium and server of business system | |
CN112422485B (en) | Communication method and device of transmission control protocol | |
CN114510299A (en) | Method, device and storage medium for processing artificial intelligence service | |
CN109933553B (en) | Control system and design method thereof, group of control systems and electronic device | |
CN116961696A (en) | Dual-mode module communication method and device, electronic equipment and storage medium | |
CN111382856B (en) | Data processing device, method, chip and electronic equipment | |
CN111382852B (en) | Data processing device, method, chip and electronic equipment | |
CN109976778B (en) | Software updating method and system of vehicle electronic product, upper computer and storage medium | |
CN113849951A (en) | Chip simulation method, device, equipment, system and storage medium | |
CN112396186B (en) | Execution method, execution device and related product | |
CN113220456B (en) | Bill data processing method and related device | |
CN113419988B (en) | Heterogeneous multi-core data transmission method, device, equipment and storage medium | |
CN118132567B (en) | Multi-pipeline heterogeneous filtering acceleration method and system for column type storage database | |
CN115883645B (en) | Communication configuration method, electronic device and storage medium | |
CN109902044B (en) | Control system, group of control systems, design method of control systems and electronic device |
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 |