CN113177015B - Frame header-based serial port communication method and serial port chip - Google Patents

Frame header-based serial port communication method and serial port chip Download PDF

Info

Publication number
CN113177015B
CN113177015B CN202110565738.2A CN202110565738A CN113177015B CN 113177015 B CN113177015 B CN 113177015B CN 202110565738 A CN202110565738 A CN 202110565738A CN 113177015 B CN113177015 B CN 113177015B
Authority
CN
China
Prior art keywords
frame header
target
protocol
serial port
bottom layer
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
CN202110565738.2A
Other languages
Chinese (zh)
Other versions
CN113177015A (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.)
Shijiazhuang Tonghe Electronics Co Ltd
Original Assignee
Shijiazhuang Tonghe Electronics Co Ltd
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 Shijiazhuang Tonghe Electronics Co Ltd filed Critical Shijiazhuang Tonghe Electronics Co Ltd
Priority to CN202110565738.2A priority Critical patent/CN113177015B/en
Publication of CN113177015A publication Critical patent/CN113177015A/en
Application granted granted Critical
Publication of CN113177015B publication Critical patent/CN113177015B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C
    • 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

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 frame header-based serial communication method and a serial chip, wherein the frame header-based serial communication method comprises the following steps: receiving target data; wherein, the frame header of the target data is a target frame header; traversing a target frame header in a preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle; and under the condition that the target frame header is traversed in the preset frame header array, sending the target data to the protocol object corresponding to the target frame header. By adopting the invention, multiple protocols can be adapted without modifying internal programs by technicians.

Description

Frame header-based serial port communication method and serial port chip
Technical Field
The invention belongs to the technical field of data communication, and particularly relates to a frame header-based serial port communication method and a 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 utilize serial chips for module control and monitoring.
At present, a serial port chip can only be suitable for one protocol. In order to meet the requirements of different protocols, the adaptation protocol of the serial port chip can be changed by modifying the internal program of the serial port chip. However, the operation is complicated by modifying the internal program of the serial chip to change the adaptation protocol of the serial chip.
Disclosure of Invention
In view of this, embodiments of the present invention provide a frame header-based serial port communication method and a serial port chip, so as to solve the problem of complicated operation in the prior art that an adaptation protocol of the serial port chip is changed.
The first aspect of the embodiments of the present invention provides a frame header-based serial port communication method, including:
receiving target data; wherein, the frame header of the target data is a target frame header;
traversing a target frame header in a preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle;
and under the condition that the target frame header is traversed in the preset frame header array, sending the target data to the protocol object corresponding to the target frame header.
Optionally, traversing the target frame header in a preset frame header array includes:
and traversing the target frame header in a preset frame header array according to a binary search algorithm.
Optionally, the frame header-based serial port communication method is applied to a serial port chip, and the serial port chip comprises at least one serial port, a bottom layer configuration module and a protocol distribution module;
receiving target data, comprising:
the bottom layer configuration module acquires 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 so that the target bottom layer object sends target data to the protocol distribution module; the system comprises a bottom layer object, a serial port and a plurality of serial ports, wherein the bottom layer object is 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 protocol distribution module receives target data;
traversing a target frame header in a preset frame header array, comprising:
and the protocol distribution module traverses the target frame header in the preset frame header array.
Optionally, the serial port chip further includes a protocol parsing module;
sending the target data to the protocol object corresponding to the target frame header, including:
the protocol distribution module sends the target data and the frame header information to the protocol analysis module; the frame header information carries a protocol object corresponding to the target frame header;
and the protocol analysis module sends the target data to a protocol object corresponding to the target frame header.
Optionally, the frame header-based serial port communication method further includes:
receiving a frame header registration request for a target frame header; the frame header registration request carries a target frame header and a protocol object corresponding to the target frame header;
and adding the target frame header to a preset frame header array.
A second aspect of the embodiments of the present invention provides a serial port chip, configured to:
receiving target data; wherein, the frame header of the target data is a target frame header;
traversing a target frame header in a preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle;
and under the condition that the target frame header is traversed in the preset frame header array, sending the target data to the protocol object corresponding to the target frame header.
Optionally, the serial port chip is further configured to:
and traversing the target frame header in a preset frame header array corresponding to the target baud rate according to a binary search algorithm.
Optionally, the serial port chip includes at least one serial port, a bottom layer configuration module, and a protocol distribution module, where:
the bottom layer configuration module is used for:
acquiring 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 so that the target bottom layer object sends the target data to a protocol distribution module; 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 protocol allocation module is further configured to:
receiving target data;
the protocol allocation module is further configured to:
and traversing the target frame header in the preset frame header array.
Optionally, the serial port chip further includes a protocol parsing module;
the protocol allocation module is further configured to:
sending the target data and the frame header information to a protocol analysis module; the frame header information carries a protocol object corresponding to the target frame header;
the protocol analysis module is used for:
and sending the target data to the protocol object corresponding to the target frame header.
Optionally, the serial port chip further includes a configuration module, configured to:
receiving a frame header registration request for a target frame header; the frame header registration request carries a target frame header and a protocol object corresponding to the target frame header;
and adding the target frame header to a preset frame header array.
A third aspect of an embodiment of the present invention provides a 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 target data is received, the target frame header of the target data can be traversed in a preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle. And under the condition that the target frame header is traversed in the preset frame header array, sending the target data to a protocol object corresponding to the target frame header. Therefore, the serial port chip can be internally provided with various protocols, can decouple the protocols, can automatically find the protocol corresponding to the data based on the frame header of the received data, can adapt to the multiple protocols without modifying internal programs by technicians, and is convenient to operate.
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 flowchart illustrating steps of a frame header-based serial communication method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a serial port chip according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a signal flow provided by an embodiment of the present invention;
fig. 4 is a schematic diagram of a protocol allocation processing flow provided in an embodiment of the present invention;
fig. 5 is a schematic diagram of a serial port chip according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a serial 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, at present, a serial port chip can only be applied to one protocol, and although the internal program of the serial port chip can be modified to change the adaptation protocol of the serial port chip, this method requires technical personnel, which is not only time-consuming, but also is prone to error, thus having the problem of complex operation.
In order to solve the problems of the prior art, the embodiment of the invention provides a frame header-based serial port communication method and a serial port chip. First, a frame header-based serial communication method provided by the embodiment of the present invention is described below.
The execution main body of the frame header-based serial communication method can be a serial chip, such as a Digital Signal Processing (DSP) chip, a Field Programmable Gate Array (FPGA) chip, and the like, and the serial chip can be externally connected with 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 serial port chip can be a multi-serial port chip or a single serial port chip.
The embodiment of the invention provides a novel serial port communication architecture, based on which a plurality of protocols are built in a serial port chip, the protocols can be decoupled, and the protocol corresponding to the data can be automatically found based on the frame header of the received data, so that technical personnel are not required to modify an internal program, and the operation is convenient.
As shown in fig. 1, the method for frame header-based serial communication according to the embodiment of the present invention may include the following steps:
and step S110, receiving target data.
And the frame header of the target data is the target frame header.
In some embodiments, the target data may be any data received by the serial port chip.
Specifically, after receiving the target data, the serial port chip may identify a frame header in the target data, that is, a target frame header, according to a data communication format.
And step S120, traversing the target frame header in the preset frame header array.
The preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle.
In some embodiments, a preset frame header array and a preset protocol array may be configured in advance, and the preset frame header array and elements in the preset protocol array are associated, where the preset protocol array may record a protocol object associated with each frame header. Then, the target frame headers may be compared with the frame headers in the preset frame header array one by one.
In some embodiments, the target frame header may be traversed in a preset frame header array according to a binary search algorithm.
Specifically, the frame headers in the preset frame header array may be arranged in the sequence from small to large, as shown in table one below. And then comparing the target frame head with the frame head at the middle position in the preset frame head array, if the numerical value of the target frame head is greater than that of the frame head, searching from the middle position in the direction of large numerical value, otherwise, searching in the direction of small numerical value.
Watch 1
Frame header Actual value of frame header Protocol
Frame header
0 0x08 Protocol 0
Frame header 1 0x0F Protocol 1
Frame header 2 0x15 Protocol 2
Frame header 3 0xF5 Protocol 3
Optionally, the serial port chip may add a frame header in a preset frame header array based on the input frame header registration request to enlarge a protocol application range of the serial port chip, and the corresponding processing may be as follows: receiving a frame header registration request for a target frame header; and adding the target frame header to a preset frame header array.
The frame header registration request carries a target frame header and a protocol object corresponding to the target frame header.
In some embodiments, the serial port chip may further modify or delete the frame header in the preset frame header array based on the input frame header modification request, so as to update the protocol usage range of the serial port chip.
Step S130, under the condition that the target frame head is traversed in the preset frame head array, the target data is sent to the protocol object corresponding to the target frame head.
In some embodiments, when the serial port chip traverses the target frame header in the preset frame header array, it indicates that the protocol object corresponding to the target data is previously embedded in the internal program of the serial port chip, so that the target data can be sent to the protocol object corresponding to the target frame header to call the protocol object corresponding to the target data to process the target data, thereby implementing communication between the serial port chip and external equipment.
Optionally, an embodiment of the present invention provides a serial chip for implementing a frame header-based serial communication method, where the serial chip includes at least one serial port, a bottom layer configuration module, and a protocol allocation module.
Specifically, after the bottom layer configuration module obtains the 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, so that the target bottom layer object sends the target data to the protocol distribution module; 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. Then, the protocol distribution module may receive the target data and traverse the target frame header in a preset frame header array.
Optionally, the serial port chip capable of implementing the frame header-based serial port communication method may further include a protocol analysis module. Correspondingly, after the protocol distribution module sends the target data and the frame header information to the protocol analysis module, the protocol analysis module can send the target data to the protocol object corresponding to the target frame header according to the protocol object corresponding to the target frame header carried in the frame header information.
For better understanding of the frame header-based serial communication method provided in the embodiment of the present invention, the following description is made.
For a single serial port chip, considering that the single serial port chip can only be applied to a single baud rate each time, namely the baud rate is fixed during each communication, however, different protocols can exist under the fixed baud rate, and for the situation, the serial port communication method based on the frame header provided by the embodiment of the invention can be used for distinguishing. For a multi-serial port chip, any serial port number of the multi-serial port chip can be regarded as a single serial port chip. As shown in table two, the situation of multiple protocols faced by different serial chips is shown.
Watch two
Figure BDA0003080630700000071
As shown in fig. 2 and fig. 3, an architecture schematic diagram and a signal flow direction schematic diagram of a serial port chip are respectively shown, based on the architecture, for protocols requiring different frame headers from different manufacturers, no matter for a single serial port chip or a multi-serial port chip, a protocol distribution module can be used to solve the problem of protocol layer coupling of different chips, so as to achieve decoupling of protocol layers.
Specifically, for the data receiving process, the signal of the bottom layer configuration module may carry information such as a serial number, a data length, a buffer initial address, and the like, and is connected to the slot of the protocol distribution module, and the protocol distribution module performs protocol distribution on the received data according to different frame headers and distributes the data to the protocol object corresponding to the protocol layer. In the data sending process, the signal of the protocol layer is connected with the slot of the bottom layer configuration module, and the data to be sent is directly transmitted to the bottom layer configuration module for sending.
As shown in fig. 4, a protocol allocation processing flow is shown, which specifically includes the following steps:
1. and searching the registered frame head by using a dichotomy, namely reading data in a buffer, comparing the data with the frame head positioned in the middle position of a preset frame head array, and if the data is greater than the frame head value, searching downwards from the position, otherwise, searching upwards.
2. When the frame header consistent with the data in the read buffer is found, the protocol corresponding to the frame header is allocated for processing, in addition, no matter the consistent frame header is found, or no corresponding frame header is found after all the frame headers are traversed, the final read index value under the port number needs to be recorded, and the following purposes can be realized:
firstly, for a single serial port chip, the final read index value is recorded, and when the signal of the bottom layer configuration module is received again next time, the copied data is continuously processed from the end of the data processed last time.
Secondly, for the multi-serial port chip, the final reading index value under the port number can be respectively recorded according to the difference of the port number.
In the processing process, the protocol layer can decouple all protocols by connecting the signal of the bottom layer configuration module with the slot of the protocol distribution module and using the registration function of the protocol distribution module to connect the frame header and the protocol matched with the frame header, so that complete decoupling is realized, and the aim of universality is fulfilled without modifying codes.
It is worth mentioning that a multi-serial communication architecture can be designed based on an object-oriented method, such as C + +, and the architecture has the following functions:
and the function 1, the protocol distribution module is arranged between the bottom layer configuration module and the protocol analysis module, and registers frame headers of different protocols, and distributes the frame headers to corresponding protocols of the protocol layer after performing protocol screening on data of the bottom layer configuration module according to the frame headers.
Function 2, bottom configuration module establish different configurations to different chips, realize the receipt and the sending of data, no matter single serial ports chip or multiple serial ports chip all can link with agreement distribution module.
Function 3, protocol analysis module, concrete analysis protocol content, according to the different establishment different protocols of frame header, realize the frame header and one-to-one correspondence of agreement, solve the strong problem of agreement layer coupling.
Function 4, signal groove mechanism are applied to serial port communication framework, and all modules are decoupled from each other and do not interfere with each other.
Therefore, the problem of protocol coupling of the protocol layer can be solved, and the protocol decoupling of the protocol layer is realized, so that after the serial port chip receives data, a protocol object of the protocol can be called for processing after the corresponding protocol is found.
In the embodiment of the invention, after the target data is received, the target frame header of the target data can be traversed in a preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle. And under the condition that the target frame header is traversed in the preset frame header array, sending the target data to a protocol object corresponding to the target frame header. Therefore, the serial port chip can be internally provided with various protocols, can decouple the protocols, can automatically find the protocol corresponding to the data based on the frame header of the received data, can adapt to the multiple protocols without modifying internal programs by technicians, and is convenient to operate.
Based on the frame header-based serial port communication method provided by the embodiment, correspondingly, the invention also provides a specific implementation mode of the serial port chip applied to the frame header-based serial port communication method. Please see the examples below.
A serial port chip is provided, which is used for:
receiving target data; wherein, the frame header of the target data is a target frame header;
traversing a target frame header in a preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle;
and under the condition that the target frame header is traversed in the preset frame header array, sending the target data to the protocol object corresponding to the target frame header.
Optionally, the serial port chip is further configured to:
and traversing the target frame header in a preset frame header array corresponding to the target baud rate according to a binary search algorithm.
Optionally, as shown in fig. 5, the serial chip 500 includes at least one serial port, a bottom layer configuration module 510 and a protocol distribution module 520, where:
the bottom layer configuration module 510 is configured to:
acquiring 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 so that the target bottom layer object sends the target data to the protocol distribution module 520; 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 protocol assignment module 520 is further configured to:
receiving target data;
the protocol assignment module 520 is further configured to:
and traversing the target frame header in the preset frame header array.
Optionally, the serial port chip further includes a protocol parsing module;
the protocol allocation module is further configured to:
sending the target data and the frame header information to a protocol analysis module; the frame header information carries a protocol object corresponding to the target frame header;
the protocol analysis module is used for:
and sending the target data to the protocol object corresponding to the target frame header.
Optionally, the serial port chip further includes a configuration module, configured to:
receiving a frame header registration request for the target frame header; the frame header registration request carries the target frame header and a protocol object corresponding to the target frame header;
and adding the target frame header to the preset frame header array.
In the embodiment of the invention, after the target data is received, the target frame header of the target data can be traversed in the preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle. And under the condition that the target frame header is traversed in the preset frame header array, sending the target data to a protocol object corresponding to the target frame header. Therefore, the serial port chip can be internally provided with various protocols, can decouple the protocols, can automatically find the protocol corresponding to the data based on the frame header of the received data, does not need technicians to modify internal programs, and is convenient and fast to operate.
Fig. 6 is a schematic diagram of a serial chip according to an embodiment of the present invention. As shown in fig. 6, the serial chip 6 of this embodiment includes: a processor 60, a memory 61 and a computer program 62 stored in said memory 61 and executable on said processor 60. The processor 60 implements the steps of the above embodiments of the serial port frame based communication method when executing the computer program 62. Alternatively, the processor 60 implements the functions of the modules/units in the above-described device embodiments when executing the computer program 62.
Illustratively, the computer program 62 may be partitioned into one or more modules/units, which are stored in the memory 61 and executed by the processor 60 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, and the instruction segments are used for describing the execution process of the computer program 62 in the serial port chip 6.
The serial port chip 6 may be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The serial port chip may include, but is not limited to, a processor 60 and a memory 61. Those skilled in the art will appreciate that fig. 6 is only an example of the serial port chip 6, and does not constitute a limitation to the serial port chip 6, and may include more or less components than those shown, or combine some components, or different components, for example, the serial port chip may further include an input-output device, a network access device, a bus, and the like.
The Processor 60 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 61 may be an internal storage unit of the serial chip 6, such as a hard disk or a memory of the serial chip 6. The memory 61 may also be an external storage device of the serial port chip 6, 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 provided on the serial port chip 6. Further, the memory 61 may also include both an internal storage unit and an external storage device of the serial chip 6. The memory 61 is used for storing the computer program and other programs and data required by the serial port chip. The memory 61 may also be used to temporarily store data that has been output or is to be output.
It should be clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional units and modules is only used for illustration, and in practical applications, the above function distribution may be performed by different functional units and modules as needed, that is, the internal structure of the apparatus may be divided into different functional units or modules to perform 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. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and 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 described above 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 suitable additions or subtractions depending on the requirements of legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer-readable media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used to illustrate the technical solution of the present invention, and not to limit 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 (10)

1. A frame header-based serial port communication method is characterized by comprising the following steps:
receiving target data; wherein, the frame header of the target data is a target frame header;
traversing the target frame header in a preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle;
under the condition that the target frame header is traversed in the preset frame header array, the target data is sent to a protocol object corresponding to the target frame header;
the method is applied to a serial port chip, and the serial port chip comprises at least one serial port, a bottom layer configuration module and a protocol distribution module;
the receiving target data includes:
the bottom layer configuration module acquires 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 so that the target bottom layer object sends the target data to the protocol distribution module; 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.
2. A frame header-based serial port communication method according to claim 1, wherein traversing the target frame header in a preset frame header array comprises:
and traversing the target frame header in the preset frame header array according to a binary search algorithm.
3. The frame header-based serial port communication method according to claim 1, wherein the serial port chip further comprises a protocol distribution module;
the protocol distribution module receives the target data;
traversing the target frame header in a preset frame header array comprises the following steps:
and traversing the target frame header in a preset frame header array by the protocol distribution module.
4. The frame header-based serial port communication method according to claim 3, wherein the serial port chip further comprises a protocol parsing module;
the sending the target data to the protocol object corresponding to the target frame header includes:
the protocol distribution module sends the target data and the frame header information to the protocol analysis module; the frame header information carries a protocol object corresponding to the target frame header;
and the protocol analysis module sends the target data to a protocol object corresponding to the target frame header.
5. The frame header-based serial port communication method according to claim 1, further comprising:
receiving a frame header registration request for the target frame header; the frame header registration request carries the target frame header and a protocol object corresponding to the target frame header;
and adding the target frame header to the preset frame header array.
6. The serial port chip is characterized in that the serial port chip is used for:
receiving target data; wherein, the frame header of the target data is a target frame header;
traversing the target frame header in a preset frame header array; the preset frame header array comprises a plurality of frame headers, and each frame header uniquely corresponds to a protocol object constructed in advance based on an object-oriented principle;
under the condition that the target frame header is traversed in the preset frame header array, the target data is sent to a protocol object corresponding to the target frame header;
the serial port chip comprises at least one serial port, a bottom layer configuration module and a protocol distribution module, wherein:
the bottom layer configuration module is used for:
acquiring 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 so that the target bottom layer object sends the target data to the protocol distribution module; 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.
7. The serial chip of claim 6, wherein the serial chip is further configured to:
and traversing the target frame header in a preset frame header array corresponding to the target baud rate according to a binary search algorithm.
8. The serial chip of claim 6, further comprising a protocol assignment module, wherein:
the protocol allocation module is configured to: receiving the target data;
the protocol allocation module is further configured to: and traversing the target frame header in a preset frame header array.
9. The serial port chip of claim 8, wherein the serial port chip further comprises a protocol parsing module;
the protocol allocation module is further configured to:
sending the target data and the frame header information to the protocol analysis module; the frame header information carries a protocol object corresponding to the target frame header;
the protocol analysis module is used for:
and sending the target data to a protocol object corresponding to the target frame header.
10. A serial chip comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the steps of the method according to any of claims 1 to 5 are implemented when the computer program is executed by the processor.
CN202110565738.2A 2021-05-24 2021-05-24 Frame header-based serial port communication method and serial port chip Active CN113177015B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110565738.2A CN113177015B (en) 2021-05-24 2021-05-24 Frame header-based serial port communication method and serial port chip

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110565738.2A CN113177015B (en) 2021-05-24 2021-05-24 Frame header-based serial port communication method and serial port chip

Publications (2)

Publication Number Publication Date
CN113177015A CN113177015A (en) 2021-07-27
CN113177015B true CN113177015B (en) 2023-04-11

Family

ID=76929689

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110565738.2A Active CN113177015B (en) 2021-05-24 2021-05-24 Frame header-based serial port communication method and serial port chip

Country Status (1)

Country Link
CN (1) CN113177015B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113824621B (en) * 2021-09-22 2023-04-14 石家庄通合电子科技股份有限公司 CAN communication method based on signals and CAN controller
CN113852532B (en) * 2021-09-22 2023-01-06 河北通合新能源科技有限公司 CAN communication method for machine number matching and CAN controller

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110601892A (en) * 2019-09-18 2019-12-20 南方电网科学研究院有限责任公司 Main module access method, device and equipment based on object-oriented protocol
CN112153048A (en) * 2020-09-24 2020-12-29 珠海格力电器股份有限公司 Information analysis method, information analysis device, information analysis system, storage medium, and electronic device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105068947B (en) * 2015-08-20 2018-01-16 浪潮软件集团有限公司 Method for processing serial port communication based on driver layer
CN109936553A (en) * 2017-12-18 2019-06-25 宁波中科集成电路设计中心有限公司 A kind of serial communication protocol automatic adaptation middleware
CN110049137A (en) * 2019-04-25 2019-07-23 广东工业大学 A kind of instruction transmission method, collecting method and relevant apparatus
CN110351242A (en) * 2019-05-31 2019-10-18 惠州市蓝微电子有限公司 The means of communication, device and the electronic equipment of compatible multi-protocols

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110601892A (en) * 2019-09-18 2019-12-20 南方电网科学研究院有限责任公司 Main module access method, device and equipment based on object-oriented protocol
CN112153048A (en) * 2020-09-24 2020-12-29 珠海格力电器股份有限公司 Information analysis method, information analysis device, information analysis system, storage medium, and electronic device

Also Published As

Publication number Publication date
CN113177015A (en) 2021-07-27

Similar Documents

Publication Publication Date Title
CN108363737B (en) Data format conversion method, device and equipment
CN113177015B (en) Frame header-based serial port communication method and serial port chip
CN114048164B (en) Chip interconnection method, system, device and readable storage medium
CN111190842B (en) Direct memory access, processor, electronic device, and data transfer method
US20230350831A1 (en) Bandwidth allocation method and apparatus for pcie external plug-in card, and device and storage medium
CN109446145A (en) A kind of channel server master board I2C extended chip, circuit and control method
CN112422485B (en) Communication method and device of transmission control protocol
US20220327339A1 (en) Smart card management device and smart card management method
CN112732982A (en) Fault code storage method and device, terminal equipment and readable storage medium
CN116032746B (en) Information processing method and device of resource pool, storage medium and electronic device
CN113177014B (en) Serial port communication method and serial port chip based on inspection mode
CN110659143B (en) Communication method and device between containers and electronic equipment
CN112511441A (en) Message processing method and device
CN113177013B (en) Baud rate-based serial communication method and multi-serial chip
CN114500688B (en) Method, device, terminal and storage medium for identifying equipment protocol
CN211628234U (en) Multi-serial port extension circuit and multi-serial port television board card
CN114356541B (en) Configuration method, device and system of computing core and electronic equipment
CN115599311B (en) Polarity inversion method and apparatus, storage medium, and electronic apparatus
CN103605622B (en) A kind of method and apparatus transmitting data
US11822797B1 (en) Object computational storage system, data processing method, client and storage medium
CN113157610B (en) Data storage method and device, storage medium and electronic device
CN220085381U (en) Device for remote reading and writing of serial port equipment
CN116069476A (en) Device collaboration system
WO2021237518A1 (en) Data storage method and apparatus, processor and computer storage medium
CN115883645A (en) Communication configuration method, electronic device, and storage medium

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