CN114866367B - CAN equipment communication method and device, CAN optical cat equipment and medium - Google Patents
CAN equipment communication method and device, CAN optical cat equipment and medium Download PDFInfo
- Publication number
- CN114866367B CN114866367B CN202210385099.6A CN202210385099A CN114866367B CN 114866367 B CN114866367 B CN 114866367B CN 202210385099 A CN202210385099 A CN 202210385099A CN 114866367 B CN114866367 B CN 114866367B
- Authority
- CN
- China
- Prior art keywords
- baud rate
- local
- data stream
- opposite
- preset
- 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
- 230000003287 optical effect Effects 0.000 title claims abstract description 182
- 238000004891 communication Methods 0.000 title claims abstract description 151
- 238000000034 method Methods 0.000 title claims abstract description 104
- 241000282326 Felis catus Species 0.000 title claims abstract description 67
- 238000012795 verification Methods 0.000 claims description 45
- 230000003044 adaptive effect Effects 0.000 claims description 18
- 230000005540 biological transmission Effects 0.000 description 11
- 238000001514 detection method Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 239000013307 optical fiber Substances 0.000 description 5
- 238000012545 processing Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000001186 cumulative effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000005855 radiation Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 230000008054 signal transmission Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/4013—Management of data rate on the bus
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/40143—Bus networks involving priority mechanisms
- H04L12/40163—Bus networks involving priority mechanisms by assigning priority to messages according to a message field
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L2012/40208—Bus networks characterized by the use of a particular bus standard
- H04L2012/40215—Controller Area Network CAN
-
- 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
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/50—Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Quality & Reliability (AREA)
- Communication Control (AREA)
Abstract
The invention relates to the technical field of local area network equipment and discloses a CAN equipment communication method, a device, CAN optical cat equipment and a medium. After CAN optical cat equipment starts to work, judging whether a receiving end of a local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port or not; when the receiving end does not receive the CAN data stream of the opposite end, the receiving end acquires the local CAN data stream through a local CAN transceiver and sends the local CAN data stream to a processor and a remote opposite end optical port; according to a preset communication protocol, setting a baud rate timer set through a processor, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and a local CAN data stream; when the self-adaptive matching of the preset baud rate and the local CAN data stream is successful, the optical cat equipment and the optical cat equipment at the remote opposite end start normal communication; therefore, normal communication among different CAN optical cat devices is realized through baud rate self-adaption.
Description
Technical Field
The invention relates to the technical field of local area network equipment, in particular to a CAN equipment communication method and device, CAN optical cat equipment and medium.
Background
Controller area network (Controller Area Network, CAN) communication is a method of communicating between microprocessor-based devices.
At present, the traditional CAN bus distributed system based on twisted pair or coaxial cable has been widely used, such as automobile, elevator control, power system control, etc., and various technologies have already been mature. The low transmission loss based on optical fiber CAN greatly increase the CAN signal transmission distance compared with twisted pair or coaxial cable; the optical fiber also has the characteristics of no radiation energy, no electric conduction, no inductance and the like, so that the influence of crosstalk and mutual interference of optical signals does not exist, and the optical fiber has excellent anti-EMI and EMC characteristics. It is obvious that there is great advantage in converting a CAN bus based on conventional twisted pair or coaxial cable to a transmission based on optical fibers.
However, the CAN bus may use different baud rates in different application environments (mainly communication distance), and the CAN baud rates of all devices communicating using the same CAN bus must be identical, otherwise the devices will not be able to correctly receive and transmit CAN data. This presents a problem as to how to achieve fast adaptation of the baud rate between different CAN devices via the optical fiber transmission means.
Disclosure of Invention
The invention mainly aims to provide a baud rate self-adaption method, a baud rate self-adaption device, CAN optical cat equipment and medium, and aims to realize normal communication among different CAN optical cat equipment through baud rate self-adaption.
In order to achieve the above object, the present invention provides a CAN device communication method, which is applied to a CAN optical modem device, the CAN optical modem device includes a local CAN transceiver, a local optical port, and a processor, the local optical port includes a receiving end and a transmitting end, and the CAN device communication method includes the following steps:
after the CAN optical cat equipment is powered on and reset, judging whether a receiving end of the local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port or not;
if the receiving end does not receive the opposite-end CAN data stream, acquiring a local CAN data stream through the local CAN transceiver, and transmitting the local CAN data stream to the processor and the remote opposite-end optical port;
setting a baud rate timer set by the processor based on a preset communication protocol, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and the local CAN data stream;
And if the self-adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is successful, starting normal communication.
Preferably, the local CAN transceiver includes a local CAN bus, and after the step of determining whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port after the CAN optical cat device is powered on and reset, the CAN device communication method further includes:
if the receiving end receives the CAN data stream of the opposite end, closing the transmitting end of the local optical port, and transmitting the CAN data stream of the opposite end to a processor through the receiving end;
decoding the opposite-end CAN data stream by the processor to obtain a decoded opposite-end CAN data stream;
and sending the decoded opposite-end CAN data stream to a local CAN bus, and outputting the decoded opposite-end CAN data stream through the local CAN bus.
Preferably, after the step of sending the decoded opposite-end CAN data stream to a local CAN bus and outputting the decoded opposite-end CAN data stream through the local CAN bus, the CAN device communication method further includes:
and the next opposite-end CAN data stream received by the receiving end.
Preferably, the preset baud rate includes a standard baud rate of a preset communication protocol or a preset user-defined baud rate.
Preferably, the step of performing baud rate adaptive matching on each preset baud rate in the baud rate timer set and the local CAN data stream includes:
encoding the local CAN data stream through the processor to obtain an encoded local CAN data stream;
checking the start bit of the encoded local CAN data stream, and judging whether the start bit is compliant;
if the verification result of the start bit is in compliance, starting the standard baud rate timer set, verifying the standard frame baud rate of the encoded local CAN data stream, and judging whether the standard frame baud rate is in the preset baud rate;
if the standard frame baud rate is in the preset baud rate, checking the expansion frame baud rate of the encoded local CAN data stream, and judging whether the expansion frame baud rate is in the preset baud rate;
if the extended frame baud rate is in the preset baud rate, checking the CRC section baud rate of the encoded local CAN data stream, and judging whether the CRC section baud rate exists in the preset baud rate or not;
If the CRC section baud rate is in the preset baud rate, detecting whether the baud rate of the encoded local CAN data stream is consistent in the process of standard frame baud rate verification, extended frame baud rate verification and CRC section baud rate verification;
if the baud rates of the encoded local CAN data streams are kept consistent, the baud rate self-adaptive matching of the local CAN data streams is successful, and the baud rate self-adaptive matching is exited.
Preferably, if the CRC segment baud rate is in the preset baud rate, detecting whether the baud rate of the encoded local CAN data stream is consistent with the baud rate of the standard frame baud rate, the extended frame baud rate, and the CRC segment baud rate, and the CAN device communication method further includes:
if the baud rate of the encoded local CAN data stream is inconsistent in the process of the baud rate verification of the standard frame, the baud rate verification of the extension frame and the baud rate verification of the CRC section, the baud rate self-adaption matching of the local CAN data stream fails, and the next opposite-end CAN data stream received by the receiving end is passed.
Preferably, after the step of setting, by the processor, a set of baud rate timers and performing baud rate matching on each preset baud rate in the set of baud rate timers and the local CAN data stream based on a preset communication protocol, the CAN device communication method further includes:
If the self-adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is not successful, the CAN communication is abnormally ended, and the next opposite-end CAN data stream received by the receiving end is passed.
In addition, to achieve the above object, the present invention also provides a CAN device communication apparatus, including:
the receiving module is used for judging whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port or not after the CAN optical cat equipment is powered on and reset;
the sending module is used for acquiring a local CAN data stream through the local CAN transceiver and sending the local CAN data stream to the processor and the remote opposite-end optical port if the receiving end does not receive the opposite-end CAN data stream;
the matching module is used for setting a baud rate timer set through the processor based on a preset communication protocol, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and the local CAN data stream;
and the communication module is used for starting normal communication if the self-adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is successful.
In addition, to achieve the above object, the present invention also provides a CAN photo cat apparatus comprising: the CAN communication system comprises a memory, a processor and a CAN device communication program stored in the memory and capable of running on the processor, wherein the CAN device communication program realizes the steps of the CAN device communication method when being executed by the processor.
In addition, in order to achieve the above object, the present invention also provides a medium, which is a computer-readable storage medium, on which a CAN device communication program is stored, the CAN device communication program implementing the steps of the CAN device communication method described above when being executed by a processor.
The invention provides a CAN equipment communication method, a device, CAN optical cat equipment and a medium; the CAN equipment communication method is applied to CAN optical cat equipment, wherein the CAN optical cat equipment comprises a local CAN transceiver, a local optical port and a processor, and the local optical port comprises a receiving end and a transmitting end; the CAN equipment communication method comprises the following steps: after the CAN optical cat equipment is powered on and reset, judging whether a receiving end of the local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port or not; if the receiving end does not receive the opposite-end CAN data stream, acquiring a local CAN data stream through the local CAN transceiver, and transmitting the local CAN data stream to the processor and the remote opposite-end optical port; setting a baud rate timer set by the processor based on a preset communication protocol, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and the local CAN data stream; and if the self-adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is successful, starting normal communication. After CAN optical cat equipment starts to work, judging whether a receiving end of a local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port or not; when the receiving end does not receive the CAN data stream of the opposite end, the receiving end acquires the local CAN data stream through a local CAN transceiver and sends the local CAN data stream to a processor and a remote opposite end optical port; according to a preset communication protocol, setting a baud rate timer set through a processor, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and a local CAN data stream; when the self-adaptive matching of the preset baud rate and the local CAN data stream is successful, the optical cat equipment and the optical cat equipment at the remote opposite end start normal communication; therefore, normal communication among different CAN optical cat devices is realized through baud rate self-adaption.
Drawings
FIG. 1 is a schematic diagram of a device architecture of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a first embodiment of a communication method of the CAN device of the invention;
fig. 3 is a schematic hardware structure of a CAN optical cat device according to a first embodiment of the CAN device communication method of the present invention;
FIG. 4 is a schematic diagram of a frame structure of the baud rate of a data frame according to a first embodiment of the communication method of the CAN device of the invention;
FIG. 5 is a flow chart of a second embodiment of the CAN device communication method of the invention;
FIG. 6 is a schematic flow chart of a second embodiment of a communication method of CAN equipment according to the invention;
FIG. 7 is a flow chart of a third embodiment of the CAN device communication method of the invention;
FIG. 8 is a schematic flow chart of a third embodiment of a communication method of a CAN device of the invention;
FIG. 9 is a flow chart of a fourth embodiment of the CAN device communication method of the invention;
FIG. 10 is a flowchart of a fifth embodiment of the CAN device communication method of the invention;
fig. 11 is a schematic functional block diagram of a first embodiment of the CAN device communication apparatus of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic device structure of a hardware running environment according to an embodiment of the present invention.
The device of the embodiment of the invention can be a mobile terminal or a server device.
As shown in fig. 1, the apparatus may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
It will be appreciated by those skilled in the art that the device structure shown in fig. 1 is not limiting of the device and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
As shown in fig. 1, an operating system, a network communication module, a user interface module, and CAN device communication programs may be included in a memory 1005 as one type of computer storage medium.
The operating system is a program for managing and controlling CAN optical cat equipment and software resources and supports the operation of a network communication module, a user interface module, a CAN equipment communication program and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003.
In the CAN optical cat device shown in fig. 1, the CAN optical cat device invokes a CAN device communication program stored in a memory 1005 through a processor 1001 and performs operations in various embodiments of the CAN device communication method described below.
Based on the hardware structure, the embodiment of the CAN equipment communication method is provided.
Referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of a CAN device communication method according to the present invention, where the CAN device communication method includes:
step S10, judging whether a receiving end of the local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port or not after the CAN optical cat equipment is powered on and reset;
Step S20, if the receiving end does not receive the CAN data stream of the opposite end, acquiring a local CAN data stream through the local CAN transceiver, and transmitting the local CAN data stream to the processor and the remote opposite end optical port;
step S30, setting a baud rate timer set by the processor based on a preset communication protocol, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and the local CAN data stream;
and step S40, if the adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is successful, starting normal communication.
In this embodiment, after the CAN optical cat device starts to work, it is determined whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port; when the receiving end does not receive the CAN data stream of the opposite end, the receiving end acquires the local CAN data stream through a local CAN transceiver and sends the local CAN data stream to a processor and a remote opposite end optical port; according to a preset communication protocol, setting a baud rate timer set through a processor, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and a local CAN data stream; when the self-adaptive matching of the preset baud rate and the local CAN data stream is successful, the optical cat equipment and the optical cat equipment at the remote opposite end start normal communication; therefore, normal communication among different CAN optical cat devices is realized through baud rate self-adaption.
The following will explain each step in detail:
and step S10, judging whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port or not after the CAN optical cat equipment is powered on and reset.
In this embodiment, CAN (Control Area Network, controller area network) is a serial communication network capable of supporting distributed control and real-time control effectively; CAN-bus (Controller Area Network-bus) refers to controller area network bus technology.
Referring to fig. 3, fig. 3 is a hardware block diagram of the CAN optical cat device; the remote transmission method of the CAN optical cat equipment is applied to the CAN optical cat equipment; the CAN optical cat equipment comprises a local CAN transceiver, a local optical port and a processor, wherein the local CAN transceiver comprises a local CAN bus, and the local optical port comprises a receiving end and a transmitting end. The CAN optical cat equipment system CAN select one of an FPGA (programmable device), an MCU (processor) and an ASIC (custom chip) to be used as a processor, and the processing and the transmission of CAN data frames are carried out through the processor; when the CAN data frame is the opposite-end CAN data stream, the processor mainly decodes the opposite-end CAN data stream and sends the decoded opposite-end CAN data stream to the local CAN transceiver; when the CAN data frame is a local CAN data stream, the processor mainly encodes the local CAN data stream, the baud rate self-adaption matching is carried out after encoding, and when the baud rate self-adaption matching is successful, a local frame response signal is initiated and sent to the local CAN transceiver. In order to improve the anti-interference performance of the CAN optical cat equipment, the local CAN transceiver is connected with a processor FPGA after being isolated with DC-DC (isolated power supply); the local optical port CAN process the receiving or transmitting CAN data stream through the Ethernet PHY, or CAN directly process the optical signal receiving or transmitting CAN data stream by adopting the TTL optical head.
After the CAN optical cat equipment is powered on and reset, the local optical port processes optical signals through an Ethernet PHY or a TTL optical head to process and receive or send CAN data streams; the CAN data stream CAN be a local CAN data stream or an opposite-end CAN data stream input by a remote opposite-end optical port; the local optical port is used for preferentially processing the opposite-end CAN data stream input by the remote opposite-end optical port, and then the local CAN data stream is processed after all the opposite-end CAN data stream input by the remote opposite-end optical port is processed.
After the CAN optical cat equipment is powered on and reset, namely after the CAN optical cat equipment starts working, whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port or not needs to be judged.
Step S20, if the receiving end does not receive the opposite end CAN data stream, acquiring a local CAN data stream through the local CAN transceiver, and transmitting the local CAN data stream to the processor and the remote opposite end optical port.
In this embodiment, after the CAN optical cat device starts to operate, the receiving end of the local optical port is default to be in an on state, and the transmitting end of the local optical port is default to be in an off state.
When the receiving end of the local optical port does not receive the opposite-end CAN data stream input by the remote opposite-end optical port, closing the receiving end of the local optical port, and opening the transmitting end of the local optical port; the local CAN data stream is obtained through the local CAN transceiver, and is sent to the processor and the sending end of the local optical port, and then is sent to the remote opposite-end optical port through the sending end of the local optical port.
Step S30, based on a preset communication protocol, a baud rate timer set is set through the processor, and each preset baud rate in the baud rate timer set is matched with the local CAN data stream in a baud rate self-adaption mode.
In one embodiment, according to a preset communication protocol, a processor sets a plurality of standard baud rate timers, and constructs a baud rate timer set from the plurality of standard baud rate timers; wherein, the preset communication protocol is preferably CiA (CAN in Automation) protocol; each preset baud rate in the baud rate timer set comprises a standard frame type baud rate and an extended frame type baud rate; preferably, the preset baud rates in the baud rate timer set are arranged from large to small or from small to large. For example, the predetermined baud rate may include 10Kbps, 20Kbps, 25Kbps, 50Kbps, 100Kbps, 125Kbps, 200Kbps, 500Kbps, 800Kbps, 1Mbps. The number of actual baud rate timer sets may be set according to the actual situation.
The local CAN data stream is encoded by the processor, so that the encoded local CAN data stream has a frame structure with the same format as the preset baud rate, referring to fig. 4, fig. 4 is a schematic frame structure diagram of the baud rate of the data frame, for example, the baud rate of the data frame is formed by 7 segments, which are respectively: a start frame representing a segment from which the data frame starts; an arbitration section representing a section of the frame priority; a control section representing the number of bytes of data and a section of reserved bits; a data segment representing the content of data and capable of transmitting data of 0 to 8 bytes; a CRC section for checking a section of a transmission error of a frame; an ACK segment indicating a segment for acknowledging normal reception; end of frame, segment representing end of data frame.
And performing baud rate self-adaptive matching on each preset baud rate and the baud rate of the encoded local CAN data stream, and detecting whether the preset baud rate matched with the baud rate of the encoded local CAN data stream exists in the baud rate timer set or not.
Preferably, in an embodiment, all preset baud rates in the baud rate timer set are adaptively matched with the baud rate of the encoded local CAN data stream at the same time, and whether the preset baud rate matched with the baud rate of the encoded local CAN data stream exists in the baud rate timer set is detected.
If the preset baud rate and the baud rate of the encoded local CAN data stream are successfully matched in an adaptive manner, taking the successfully matched preset baud rate as a correct baud rate, recording the correct baud rate, and exiting the baud rate for self-adaptive matching;
if the self-adaptive matching of the preset baud rate and the baud rate of the encoded local CAN data stream is not successful, the next opposite-end CAN data stream received by the receiving end is received.
Therefore, the baud rate of the local CAN data stream CAN be intelligently and rapidly identified, the baud rate self-adaptive matching is accurate, and the matching efficiency is high.
Preferably, in another embodiment, the preset baud rates in the baud rate timer set are matched with the baud rates of the encoded local CAN data stream in a baud rate self-adaptive manner one by one, and whether the preset baud rates matched with the baud rates of the encoded local CAN data stream exist in the baud rate timer set is detected.
If the preset baud rate and the baud rate of the encoded local CAN data stream are successfully matched in an adaptive manner, taking the successfully matched preset baud rate as a correct baud rate, recording the correct baud rate, and exiting the baud rate for self-adaptive matching;
if the preset baud rate in the baud rate timer set does not exist, when the preset baud rate in the baud rate timer set is not used, the rest preset baud rates in the baud rate timer set possibly exist correct baud rates, and then the baud rate self-adaption matching is needed to be carried out on the unused preset baud rates in the baud rate timer set and the baud rates of the coded local CAN data stream one by one.
Therefore, the baud rate of the local CAN data stream CAN be intelligently and rapidly identified, the baud rate is self-adaptive and matched accurately, and the generation of matching errors CAN be reduced.
Further, in an embodiment, the preset baud rate in step S30 includes a standard baud rate of a preset communication protocol or a preset user-defined baud rate.
In one embodiment, the predetermined baud rate includes a standard baud rate of a predetermined CiA protocol or a predetermined user-defined baud rate; wherein, the preset communication protocol is preferably CiA (CAN in Automation) protocol; the standard baud rate of the preset communication protocol belongs to the universal standard baud rate and has a unified standardized format; the standard baud rate of the preset communication protocol can be compatible with the communication of various devices, and is easy to develop and maintain.
The preset user-defined baud rate refers to the baud rate which is user-defined according to the requirements of equipment communication according to a preset communication protocol, and the safety and privacy of the equipment communication can be realized.
And step S40, if the adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is successful, starting normal communication.
In one embodiment, when the baud rate of the local CAN data stream after the encoding is detected to be successfully matched with the baud rate of the local CAN data stream after the encoding in the baud rate timer set, taking the successfully matched preset baud rate as a correct baud rate, and recording the correct baud rate; and normal communication between the optical cat device and the optical cat device at the remote opposite end is realized through the correct baud rate.
In one embodiment, when the baud rate of the local CAN data stream after the encoding is detected to be successfully matched with the baud rate of the local CAN data stream after the encoding in the baud rate timer set, taking the successfully matched preset baud rate as a correct baud rate, and recording the correct baud rate; after normal communication between the optical cat equipment and the optical cat equipment at the remote opposite end is realized through the correct baud rate; returning to execute the step of judging whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port; then executing the next step; thereby improving the communication efficiency of the CAN optical cat equipment.
In the embodiment, after CAN optical cat equipment starts to work, whether a receiving end of a local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port is judged; when the receiving end does not receive the CAN data stream of the opposite end, the receiving end acquires the local CAN data stream through a local CAN transceiver and sends the local CAN data stream to a processor and a remote opposite end optical port; according to a preset communication protocol, setting a baud rate timer set through a processor, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and a local CAN data stream; when the self-adaptive matching of the preset baud rate and the local CAN data stream is successful, the optical cat equipment and the optical cat equipment at the remote opposite end start normal communication; therefore, normal communication among different CAN optical cat devices is realized through baud rate self-adaption.
Further, based on the first embodiment of the CAN device communication method of the present invention, a second embodiment of the CAN device communication method of the present invention is proposed.
The difference between the second embodiment of the CAN device communication method and the first embodiment of the CAN device communication method is that in this embodiment, in step S10, the local CAN transceiver includes a local CAN bus, and after the step of determining whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port after the CAN optical modem device is powered on and reset, referring to fig. 5, the CAN device communication method further includes:
step A10, if the receiving end receives the CAN data stream of the opposite end, closing the transmitting end of the local optical port and transmitting the CAN data stream of the opposite end to a processor through the receiving end;
step A20, decoding the opposite-end CAN data stream through the processor to obtain a decoded opposite-end CAN data stream;
and step A30, transmitting the decoded opposite-end CAN data stream to a local CAN bus, and outputting the decoded opposite-end CAN data stream through the local CAN bus.
In this embodiment, when the receiving end of the local optical port receives the opposite-end CAN data stream, the sending end of the local optical port is closed, and the receiving end of the local optical port sends the received opposite-end CAN data stream to the processor; decoding the opposite-end CAN data stream through a processor to obtain a decoded opposite-end CAN data stream; inputting the decoded opposite-end CAN data stream to a local CAN bus of a local CAN transceiver through a processor, and outputting the decoded opposite-end CAN data stream to equipment connected with a remote opposite end through the local CAN bus; thereby realizing normal communication with the opposite-end CAN signal.
The following will explain each step in detail:
and step A10, if the receiving end receives the opposite-end CAN data stream, closing the transmitting end of the local optical port, and transmitting the opposite-end CAN data stream to a processor through the receiving end.
In this embodiment, the local optical port includes a receiving end and a transmitting end; the receiving end is used for receiving the opposite-end CAN data stream input by the remote opposite-end optical port; the transmitting end is used for transmitting the local CAN data stream to the remote opposite end optical port. After the CAN optical cat equipment is powered on and reset, namely after the CAN optical cat equipment starts working, the receiving end of the local optical port is defaulted to be in an open state, and the transmitting end of the local optical port is in a closed state.
When the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port, closing the transmitting end of the local optical port; and the receiving end of the local optical port sends the received CAN data stream of the opposite end to the processor, and the CAN data stream of the opposite end is processed by the processor, so that the CAN data stream of the opposite end CAN be identified by the local CAN transceiver.
And step A20, decoding the opposite-end CAN data stream by the processor to obtain a decoded opposite-end CAN data stream.
In this embodiment, the processor decodes the opposite-end CAN data stream, where the decoding is to detect the opposite-end CAN data stream bit by bit, determine whether the opposite-end CAN data stream is correct, and if so, obtain the decoded opposite-end CAN data stream.
And step A30, transmitting the decoded opposite-end CAN data stream to a local CAN bus, and outputting the decoded opposite-end CAN data stream through the local CAN bus.
In one embodiment, the decoded opposite CAN data stream is transmitted to a local CAN bus of a local CAN transceiver through a local optical port; and outputting the decoded opposite-end CAN data stream to the remote opposite-end connected equipment through a local CAN bus of the local CAN transceiver.
Further, in an embodiment, referring to fig. 6, after step a30, the CAN device communication method further includes:
and step A40, receiving the next opposite-end CAN data stream by the receiving end.
In this embodiment, after the local CAN bus of the local CAN transceiver performs normal communication with the device connected to the remote peer through the decoded peer CAN data stream, the next peer CAN data stream received through the receiving end of the local optical port is then executed, and then the next step is executed.
In an embodiment, when the receiving end of the local optical port receives the opposite-end CAN data stream, the sending end of the local optical port is closed, and the receiving end of the local optical port sends the received opposite-end CAN data stream to the processor; decoding the opposite-end CAN data stream through a processor to obtain a decoded opposite-end CAN data stream; inputting the decoded opposite-end CAN data stream to a local CAN bus of a local CAN transceiver through a processor, and outputting the decoded opposite-end CAN data stream to equipment connected with a remote opposite end through the local CAN bus; thereby realizing normal communication with the opposite-end CAN signal.
Further, based on the first and second embodiments of the CAN device communication method of the present invention, a third embodiment of the CAN device communication method of the present invention is provided.
The third embodiment of the CAN device communication method differs from the first, second and third embodiments of the CAN device communication method in that in step S30, each preset baud rate in the baud rate timer set is refined by performing baud rate adaptive matching with the local CAN data stream, and referring to fig. 7, the steps specifically include:
step S31, the local CAN data stream is encoded through the processor, and the encoded local CAN data stream is obtained;
Step S32, checking the start bit of the encoded local CAN data stream, and judging whether the start bit is compliant;
step S33, if the verification result of the start bit is compliant, starting the standard baud rate timer set, verifying the standard frame baud rate of the encoded local CAN data stream, and judging whether the standard frame baud rate is in the preset baud rate;
step S34, if the standard frame baud rate is in the preset baud rate, checking the expansion frame baud rate of the encoded local CAN data stream, and judging whether the expansion frame baud rate is in the preset baud rate;
step S35, if the extended frame baud rate is in the preset baud rate, checking the CRC section baud rate of the encoded local CAN data stream, and judging whether the CRC section baud rate is in the preset baud rate or not;
step S36, if the CRC section baud rate is in the preset baud rate, detecting whether the baud rate of the encoded local CAN data stream is consistent in the process of standard frame baud rate verification, extended frame baud rate verification and CRC section baud rate verification;
Step S37, if the baud rates of the encoded local CAN data streams are kept consistent, the baud rate self-adaptive matching of the local CAN data streams is successful, and the baud rate self-adaptive matching is exited.
In the embodiment, the processor encodes the local CAN data stream to obtain an encoded local CAN data stream; carrying out baud rate self-adaptive matching on each preset baud rate and the encoded local CAN data stream; the baud rate self-adaptive matching comprises initial bit check, extended frame baud rate check and CRC section baud rate check, and detects whether the baud rate of the encoded local CAN data stream is consistent in the standard frame baud rate check, extended frame baud rate check and CRC section baud rate check processes; when the baud rate self-adaptive matching of the local CAN data stream is successful, the baud rate self-adaptive matching is exited; thereby realizing the normal communication of the CAN signal.
The following will explain each step in detail:
and step S31, encoding the local CAN data stream through the processor to obtain an encoded local CAN data stream.
In this embodiment, after the processor receives the local CAN data stream input by the local CAN transceiver, the processor needs to encode the local CAN data stream to obtain an encoded local CAN data stream; the remote opposite-end optical port CAN correctly identify the local CAN data stream; and after the processor codes the local CAN data stream, carrying out baud rate self-adaptive matching on the coded local CAN data stream.
And step S32, checking the start bit of the encoded local CAN data stream, and judging whether the start bit is compliant.
In this embodiment, the baud rate adaptive matching includes a start bit check, a standard frame baud rate check, an extended frame baud rate check, and a CRC segment baud rate check, and detecting whether the baud rate of the encoded local CAN data stream remains the same during the standard frame baud rate check, the extended frame baud rate check, and the CRC segment baud rate check. Referring to fig. 8, whether the start bit of the encoded local CAN data stream is compliant is determined by verifying the start bit of the encoded local CAN data stream; and when the start bit of the local CAN data stream is detected to be at a low level, the detection result of the start bit of the local CAN data stream is compliant.
When the detection result of the start bit of the local CAN data stream is not in compliance, the baud rate self-adaptive matching is exited; and returning to the step of judging whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port, receiving the opposite-end CAN data stream input by the next remote opposite-end optical port by the receiving end of the local optical port, and executing the next step.
Step S33, if the verification result of the start bit is compliant, starting the standard baud rate timer set, verifying the standard frame baud rate of the encoded local CAN data stream, and judging whether the standard frame baud rate is in the preset baud rate.
In this embodiment, referring to fig. 8, after the verification result of the start bit is compliant, a standard baud rate timer set is started, the encoded local CAN data stream is continuously advanced with a certain fixed baud rate, and at the same time, the standard frame baud rate of the encoded local CAN data stream is verified, and whether the standard frame baud rate of the local CAN data stream is within the preset baud rate is determined.
If the encoded local CAN data stream is checked to be compliant in the standard frame baud rate, the method has the following characteristics: for standard format frames, there are 18 bits of frame data in total, and bit 13 (the identifier extension bit, i.e., the IDE bit) is explicit. The standard frame type is classified into two types of a data frame format and a remote frame format, which are judged by a remote frame transmission identifier RTR bit (remote transfer request bit, that is, RTR bit), and the remote frame transmission identifier RTR bit of the standard frame type is located at bit 12. For the standard frame type, if the RTR bit is dominant, the encoded local CAN data stream is a standard type data frame; if the RTR bit is recessive, the encoded local CAN data stream is a standard type remote frame; and if the two conditions are satisfied, the detection result of the identifier extension bit of the local CAN data stream is compliant.
When the verification result of the standard frame baud rate of the local CAN data stream is not compliant, the baud rate self-adaptive matching is exited; and returning to the step of judging whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port, receiving the opposite-end CAN data stream input by the next remote opposite-end optical port by the receiving end of the local optical port, and executing the next step.
And if the coded local CAN data stream is in the standard frame baud rate check compliance, then continuously judging whether the standard frame baud rate of the local CAN data stream is in the preset baud rate.
And step S34, if the standard frame baud rate is in the preset baud rate, checking the expansion frame baud rate of the encoded local CAN data stream, and judging whether the expansion frame baud rate is in the preset baud rate.
In this embodiment, when the standard frame baud rate of the encoded local CAN data stream is within the preset baud rate, the encoded local CAN data stream is continuously advanced at a certain fixed baud rate, and the extended frame baud rate of the encoded local CAN data stream is checked at the same time; and judging whether the baud rate of the expansion frame of the encoded local CAN data stream is in a preset baud rate.
Referring to fig. 8, the extended frame baud rate check compliance of the encoded local CAN data stream is characterized as follows: a determination is made at the identifier extension bit IDE bit (bit 13): when the IDE bit is an recessive bit, the encoded local CAN data stream is an extended frame type; the extended frame type is divided into two formats, namely a data frame format and a remote frame format, wherein the two formats are judged by a remote frame transmission identifier RTR bit (remote transmission request bit, namely RTR bit), and if the RTR bit is dominant, the encoded local CAN data stream is an extended type data frame; and if the RTR bit is recessive, the encoded local CAN data stream is an extended type remote frame. And if the two conditions are satisfied, the detection result of the remote transmission request bit of the local CAN data stream is compliant.
When the verification result of the baud rate of the expansion frame of the local CAN data stream is not in compliance, the baud rate self-adaptive matching is exited; and returning to the step of judging whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port, receiving the opposite-end CAN data stream input by the next remote opposite-end optical port by the receiving end of the local optical port, and executing the next step.
And when the encoded local CAN data stream is in the check compliance of the expansion frame baud rate, then continuously judging whether the expansion frame baud rate of the local CAN data stream is in the preset baud rate.
Step S35, if the extended frame baud rate is in the preset baud rate, checking the CRC section baud rate of the encoded local CAN data stream, and determining whether the CRC section baud rate is in the preset baud rate.
In this embodiment, when the extended frame baud rate of the local CAN data stream is within the preset baud rate, the encoded local CAN data stream is continuously advanced with a certain fixed baud rate, and the CRC section baud rate of the encoded local CAN data stream is checked at the same time; and judging whether the CRC section baud rate of the encoded local CAN data stream is in a preset baud rate or not.
Referring to fig. 8, when the number of bits of the cumulative checksum of the encoded local CAN data stream reaches 16 bits, the CRC segment baud rate of the encoded local CAN data stream is checked to be compliant.
When the detection result of the CRC section baud rate of the local CAN data stream is not compliant, the baud rate self-adaptive matching is exited; and returning to the step of judging whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port, receiving the opposite-end CAN data stream input by the next remote opposite-end optical port by the receiving end of the local optical port, and executing the next step.
And when the encoded local CAN data stream is in the check compliance of the CRC section baud rate, then continuously judging whether the CRC section baud rate of the local CAN data stream is in the preset baud rate.
Step S36, if the CRC segment baud rate is in the preset baud rate, detecting whether the baud rate of the encoded local CAN data stream is consistent in the standard frame baud rate check, the extended frame baud rate check, and the CRC segment baud rate check.
In this embodiment, referring to fig. 8, when the CRC segment baud rate of the encoded local CAN data stream appears in the preset baud rate, then it is detected whether the baud rate of the encoded local CAN data stream changes in the process of standard frame baud rate check, extended frame baud rate check, and CRC segment baud rate check.
If the baud rate of the encoded local CAN data stream is different in the process of the baud rate check of the standard frame, the baud rate check of the extension frame and the baud rate check of the CRC section; the method and the device are characterized in that the method and the device continuously advance at a fixed baud rate a in the standard frame baud rate checking process, continuously advance at a fixed baud rate b in the extended frame baud rate checking process, and continuously advance at a fixed baud rate c in the CRC section baud rate checking process.
Or, the encoded local CAN data stream is continuously pushed forward with a fixed baud rate a in the process of checking the baud rate of the standard frame and the baud rate of the extension frame; and in the CRC section baud rate checking process, the baud rate of the encoded local CAN data stream continuously advances at a fixed baud rate b.
Step S37, if the baud rates of the encoded local CAN data streams are kept consistent, the baud rate self-adaptive matching of the local CAN data streams is successful, and the baud rate self-adaptive matching is exited.
In this embodiment, referring to fig. 8, when it is detected that the baud rate of the encoded local CAN data stream is the same in the standard frame baud rate verification, the extended frame baud rate verification, and the CRC segment baud rate verification, the baud rate adaptive matching of the local CAN data stream is successful, and the baud rate adaptive matching is exited.
In the embodiment, the processor encodes the local CAN data stream to obtain an encoded local CAN data stream; carrying out baud rate self-adaptive matching on each preset baud rate and the encoded local CAN data stream; the baud rate self-adaptive matching comprises initial bit check, extended frame baud rate check and CRC section baud rate check, and detects whether the baud rate of the encoded local CAN data stream is consistent in the standard frame baud rate check, extended frame baud rate check and CRC section baud rate check processes; when the baud rate self-adaptive matching of the local CAN data stream is successful, the baud rate self-adaptive matching is exited; thereby realizing the normal communication of the CAN signal.
Further, based on the first, second and third embodiments of the CAN device communication method of the present invention, a fourth embodiment of the CAN device communication method of the present invention is provided.
The fourth embodiment of the CAN device communication method is different from the first, second and third embodiments of the CAN device communication method in that in step S37, if the baud rates of the encoded local CAN data streams remain the same, the baud rate adaptive matching of the local CAN data streams is successful, and after the step of exiting the baud rate adaptive matching, referring to fig. 9, the CAN device communication method further includes:
and step B10, if the baud rate of the encoded local CAN data stream is inconsistent in the process of the baud rate verification of the standard frame, the baud rate verification of the extension frame and the baud rate verification of the CRC section, the baud rate self-adaption matching of the local CAN data stream fails, and the next opposite-end CAN data stream received by the receiving end is passed.
In this embodiment, when the baud rate of the local CAN data stream is inconsistent in the process of the standard frame baud rate check, the extended frame baud rate check and the CRC segment baud rate check, the baud rate self-adaptive matching of the local CAN data stream fails, and the next opposite end CAN data stream received by the receiving end is passed; carrying out baud rate self-adaptive matching on the next CAN data stream with the opposite end; thereby improving the communication efficiency of the CAN optical cat equipment.
The following will explain each step in detail:
and step B10, if the baud rate of the encoded local CAN data stream is inconsistent in the process of the baud rate verification of the standard frame, the baud rate verification of the extension frame and the baud rate verification of the CRC section, the baud rate self-adaption matching of the local CAN data stream fails, and the next opposite-end CAN data stream received by the receiving end is passed.
In this embodiment, by detecting whether the baud rate of the encoded local CAN data stream changes in the process of the standard frame baud rate check, the extended frame baud rate check and the CRC segment baud rate check, when it is detected that the baud rate of the local CAN data stream is inconsistent in the process of the standard frame baud rate check, the extended frame baud rate check and the CRC segment baud rate check, the baud rate self-adaptive matching of the local CAN data stream fails, and the next opposite end CAN data stream received by the receiving end; the next step is then performed.
In this embodiment, when the baud rate of the local CAN data stream is inconsistent in the process of the standard frame baud rate check, the extended frame baud rate check and the CRC segment baud rate check, the baud rate self-adaptive matching of the local CAN data stream fails, and the next opposite end CAN data stream received by the receiving end is passed; thereby improving the communication efficiency of the CAN optical cat equipment.
Further, based on the first, second, third and fourth embodiments of the CAN device communication method of the present invention, a fifth embodiment of the CAN device communication method of the present invention is provided.
The fifth embodiment of the CAN device communication method differs from the first, second, third and fourth embodiments of the CAN device communication method in that, in the present embodiment, for step S30, after setting, by the processor, a set of baud rate timers based on a preset communication protocol, and performing a baud rate matching step on each preset baud rate in the set of baud rate timers and the local CAN data stream, referring to fig. 10, the CAN device communication method further includes:
and step C10, if the self-adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is not successful, the CAN communication is abnormally ended, and the next opposite-end CAN data stream received by the receiving end is passed.
In this embodiment, when each preset baud rate in the baud rate timer set is not successfully matched with the baud rate of the local CAN data stream in an adaptive manner, the CAN communication is abnormally ended, and the next opposite-end CAN data stream received by the receiving end is passed; then processing the next opposite-end CAN data stream; thereby improving the execution efficiency of the CAN optical cat equipment.
The following will explain each step in detail:
and step C10, if the self-adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is not successful, the CAN communication is abnormally ended, and the next opposite-end CAN data stream received by the receiving end is passed.
In this embodiment, when each preset baud rate in the baud rate timer set is not successfully matched with the baud rate of the local CAN data stream in an adaptive manner, the CAN communication is abnormally ended, and the next opposite-end CAN data stream received by the receiving end is passed; and then processing the next opposite-end CAN data stream.
In the embodiment, when each preset baud rate in the baud rate timer set is not successfully matched with the baud rate self-adaption of the local CAN data stream, the CAN communication is abnormally ended, and the next opposite-end CAN data stream is received by the receiving end; then processing the next opposite-end CAN data stream; thereby improving the execution efficiency of the CAN optical cat equipment.
The invention also provides a CAN equipment communication device. Referring to fig. 11, the CAN device communication apparatus of the present invention includes:
the receiving module 10 is configured to determine whether a receiving end of the local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port after the CAN optical cat device is powered on and reset;
A sending module 20, configured to obtain a local CAN data stream through the local CAN transceiver and send the local CAN data stream to the processor and the remote peer optical port if the receiving end does not receive the peer CAN data stream;
a matching module 30, configured to set, by the processor, a baud rate timer set based on a preset communication protocol, and perform baud rate adaptive matching on each preset baud rate in the baud rate timer set and the local CAN data stream;
and the communication module 40 is configured to start normal communication if there is a successful adaptive matching between the preset baud rate and the baud rate of the local CAN data stream.
Preferably, the CAN device communication apparatus further includes:
the sending module is used for closing the sending end of the local optical port if the receiving end receives the opposite-end CAN data stream, and sending the opposite-end CAN data stream to a processor through the receiving end;
the decoding module is used for decoding the opposite-end CAN data stream through the processor to obtain a decoded opposite-end CAN data stream;
and the output module is used for sending the decoded opposite-end CAN data stream to a local CAN bus and outputting the decoded opposite-end CAN data stream through the local CAN bus.
Preferably, the CAN device communication apparatus further includes:
and the pass module is used for receiving the next opposite-end CAN data stream through the receiving end.
Preferably, the matching module 30 further includes:
the preset module unit is used for presetting the baud rate to comprise the standard baud rate of a preset communication protocol or the preset user-defined baud rate.
Preferably, the matching module 30 further includes:
the encoding unit is used for encoding the local CAN data stream through the processor to obtain an encoded local CAN data stream;
the starting bit verification unit is used for verifying the starting bit of the encoded local CAN data stream and judging whether the starting bit is compliant or not;
the standard frame baud rate verification unit is used for starting the standard baud rate timer set if the verification result of the start bit is in compliance, verifying the standard frame baud rate of the encoded local CAN data stream and judging whether the standard frame baud rate is in the preset baud rate or not;
an extended frame baud rate verification unit, configured to verify an extended frame baud rate of the encoded local CAN data stream if the standard frame baud rate is in the preset baud rate, and determine whether the extended frame baud rate is in the preset baud rate;
A CRC segment baud rate verification unit, configured to, if the extended frame baud rate is in the preset baud rate, verify the CRC segment baud rate of the encoded local CAN data stream, and determine whether the CRC segment baud rate exists in the preset baud rate;
the detection unit is used for detecting whether the baud rate of the encoded local CAN data stream is consistent in the process of standard frame baud rate verification, extended frame baud rate verification and CRC section baud rate verification if the CRC section baud rate is in the preset baud rate;
and the self-adapting unit is used for successfully carrying out the self-adapting matching of the baud rate of the local CAN data stream if the baud rate of the coded local CAN data stream is kept consistent, and exiting the self-adapting matching of the baud rate.
Preferably, the matching module 30 further includes:
and the receiving unit is used for failing the adaptive matching of the baud rate of the local CAN data stream if the baud rate of the coded local CAN data stream is inconsistent in the process of the baud rate verification of the standard frame, the baud rate verification of the extension frame and the baud rate verification of the CRC section, and receiving the next opposite-end CAN data stream through the receiving end.
Preferably, the CAN device communication apparatus further includes:
And the standard module is used for ending the CAN communication abnormally and receiving the next opposite-end CAN data stream through the receiving end if the adaptive matching of the standard baud rate and the baud rate of the local CAN data stream is not successful.
In addition, the invention also provides a medium which is a computer readable storage medium and is stored with a CAN device communication program, and the CAN device communication program realizes the steps of the CAN device communication method when being executed by a processor.
The method implemented when the CAN device communication program running on the processor is executed may refer to various embodiments of the CAN device communication method of the present invention, which are not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the invention, and all equivalent structures or equivalent flow modifications made by the present invention and the accompanying drawings, or direct or indirect application in other relevant technical fields, are included in the present invention.
Claims (9)
1. The CAN equipment communication method is characterized by being applied to CAN optical cat equipment, wherein the CAN optical cat equipment comprises a local CAN transceiver, a local optical port and a processor, the local optical port comprises a receiving end and a transmitting end, and the CAN equipment communication method comprises the following steps:
after the CAN optical cat equipment is powered on and reset, judging whether a receiving end of the local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port or not;
if the receiving end does not receive the opposite-end CAN data stream, acquiring a local CAN data stream through the local CAN transceiver, and transmitting the local CAN data stream to the processor and the remote opposite-end optical port;
setting a baud rate timer set by the processor based on a preset communication protocol, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and the local CAN data stream;
if the self-adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is successful, starting normal communication;
the local CAN transceiver includes a local CAN bus, after the step of determining whether the receiving end of the local optical port receives an opposite-end CAN data stream input by the remote opposite-end optical port after the CAN optical cat device is powered on and reset, the CAN device communication method further includes:
If the receiving end receives the CAN data stream of the opposite end, closing the transmitting end of the local optical port, and transmitting the CAN data stream of the opposite end to a processor through the receiving end;
decoding the opposite-end CAN data stream by the processor to obtain a decoded opposite-end CAN data stream;
and sending the decoded opposite-end CAN data stream to a local CAN bus, and outputting the decoded opposite-end CAN data stream through the local CAN bus.
2. The CAN device communication method of claim 1, wherein after the step of transmitting the decoded peer CAN data stream to a local CAN bus and outputting the decoded peer CAN data stream through the local CAN bus, the CAN device communication method further comprises:
and the next opposite-end CAN data stream received by the receiving end.
3. The CAN device communication method of claim 1, wherein the preset baud rate comprises a standard baud rate of a preset communication protocol or a preset user-defined baud rate.
4. The CAN device communication method of claim 1 wherein the step of performing baud rate adaptive matching of each preset baud rate in the set of baud rate timers with the local CAN data stream comprises:
Encoding the local CAN data stream through the processor to obtain an encoded local CAN data stream;
checking the start bit of the encoded local CAN data stream, and judging whether the start bit is compliant;
if the verification result of the start bit is in compliance, starting the baud rate timer set, verifying the standard frame baud rate of the encoded local CAN data stream, and judging whether the standard frame baud rate is in the preset baud rate;
if the standard frame baud rate is in the preset baud rate, checking the expansion frame baud rate of the encoded local CAN data stream, and judging whether the expansion frame baud rate is in the preset baud rate;
if the extended frame baud rate is in the preset baud rate, checking the CRC section baud rate of the encoded local CAN data stream, and judging whether the CRC section baud rate exists in the preset baud rate or not;
if the CRC section baud rate is in the preset baud rate, detecting whether the baud rate of the encoded local CAN data stream is consistent in the process of standard frame baud rate verification, extended frame baud rate verification and CRC section baud rate verification;
If the baud rates of the encoded local CAN data streams are kept consistent, the baud rate self-adaptive matching of the local CAN data streams is successful, and the baud rate self-adaptive matching is exited.
5. The CAN device communication method of claim 4 wherein if the CRC segment baud rate is within the preset baud rate, detecting whether the baud rate of the encoded local CAN data stream remains consistent during the steps of standard frame baud rate verification, extended frame baud rate verification, and CRC segment baud rate verification, the CAN device communication method further comprising:
if the baud rate of the encoded local CAN data stream is inconsistent in the process of the baud rate verification of the standard frame, the baud rate verification of the extension frame and the baud rate verification of the CRC section, the baud rate self-adaption matching of the local CAN data stream fails, and the next opposite-end CAN data stream received by the receiving end is passed.
6. The CAN device communication method of claim 1, wherein after the step of setting a set of baud rate timers by the processor based on a preset communication protocol and performing baud rate matching on each preset baud rate in the set of baud rate timers with the local CAN data stream, the CAN device communication method further comprises:
If the self-adaptive matching of the preset baud rate and the baud rate of the local CAN data stream is not successful, the CAN communication is abnormally ended, and the next opposite-end CAN data stream received by the receiving end is passed.
7. The utility model provides a CAN equipment communication device, its characterized in that, CAN equipment communication device applies to CAN light cat equipment, CAN light cat equipment includes local CAN transceiver, local optical port and treater, local optical port includes receiving terminal and transmitting terminal, CAN equipment communication device includes:
the receiving module is used for judging whether the receiving end of the local optical port receives the opposite-end CAN data stream input by the remote opposite-end optical port or not after the CAN optical cat equipment is powered on and reset;
the sending module is used for acquiring a local CAN data stream through the local CAN transceiver and sending the local CAN data stream to the processor and the remote opposite-end optical port if the receiving end does not receive the opposite-end CAN data stream;
the matching module is used for setting a baud rate timer set through the processor based on a preset communication protocol, and carrying out baud rate self-adaptive matching on each preset baud rate in the baud rate timer set and the local CAN data stream;
The communication module is used for starting normal communication if the self-adaptive matching between the preset baud rate and the baud rate of the local CAN data stream is successful;
the local CAN transceiver comprises a local CAN bus;
the CAN equipment communication device is used for closing the sending end of the local optical port if the receiving end receives the opposite-end CAN data stream and sending the opposite-end CAN data stream to the processor through the receiving end; decoding the opposite-end CAN data stream by the processor to obtain a decoded opposite-end CAN data stream; and sending the decoded opposite-end CAN data stream to a local CAN bus, and outputting the decoded opposite-end CAN data stream through the local CAN bus.
8. A CAN light cat apparatus, characterized in that the CAN light cat apparatus comprises: memory, a processor and a CAN device communication program stored on the memory and executable on the processor, which CAN device communication program when executed by the processor implements the steps of the CAN device communication method of any one of claims 1 to 6.
9. A medium which is a computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a CAN device communication program which, when executed by a processor, implements the steps of the CAN device communication method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210385099.6A CN114866367B (en) | 2022-04-13 | 2022-04-13 | CAN equipment communication method and device, CAN optical cat equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210385099.6A CN114866367B (en) | 2022-04-13 | 2022-04-13 | CAN equipment communication method and device, CAN optical cat equipment and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114866367A CN114866367A (en) | 2022-08-05 |
CN114866367B true CN114866367B (en) | 2023-12-05 |
Family
ID=82630757
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210385099.6A Active CN114866367B (en) | 2022-04-13 | 2022-04-13 | CAN equipment communication method and device, CAN optical cat equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114866367B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117640016B (en) * | 2024-01-26 | 2024-05-17 | 北京智芯微电子科技有限公司 | Baud rate negotiation method, device, computer equipment, chip and storage medium |
Citations (24)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5490209A (en) * | 1994-02-09 | 1996-02-06 | Harris Corporation | Autobaud rate detection mechanism |
US5507040A (en) * | 1993-06-10 | 1996-04-09 | Motorola, Inc. | Method and apparatus for battery saving in a radio communication device |
US6366610B1 (en) * | 1998-05-15 | 2002-04-02 | Advanced Micro Devices, Inc. | Autobauding with adjustment to a programmable baud rate |
US6847615B1 (en) * | 1997-11-13 | 2005-01-25 | Optimay Corporation | Baud rate detection in serial data transmission |
CN103777538A (en) * | 2012-10-19 | 2014-05-07 | 重庆长安汽车股份有限公司 | Baud-rate automatic matching method for controller and CAN bus |
CN103986610A (en) * | 2014-06-04 | 2014-08-13 | 珠海格力电器股份有限公司 | Communication interface matching method, device and controller |
CN104796222A (en) * | 2014-11-21 | 2015-07-22 | 湖南先步信息股份有限公司 | A CAN baud-rate automatic matching method |
CN106130856A (en) * | 2016-08-17 | 2016-11-16 | 天津市英贝特航天科技有限公司 | A kind of self adaptation baud rate RS485 communications protocol |
CN106411641A (en) * | 2016-09-20 | 2017-02-15 | 宁波中车时代传感技术有限公司 | Method for automatically detecting Baud rate of CAN bus |
CN106464559A (en) * | 2014-05-26 | 2017-02-22 | 康西欧控股有限公司 | High speed embedded protocol for distributed control system |
CN107038135A (en) * | 2017-03-24 | 2017-08-11 | 深圳市顺讯电子有限公司 | A kind of serial port baud rate Adaptable System and method |
CN108226598A (en) * | 2018-01-05 | 2018-06-29 | 深圳市道通科技股份有限公司 | A kind of oscilloscope signal interpretation method, device and oscillograph |
CN207560000U (en) * | 2017-10-30 | 2018-06-29 | 深圳市三旺通信技术有限公司 | The controller LAN optic fiber converter of baud rate self-adapting |
CN109274567A (en) * | 2018-09-27 | 2019-01-25 | 潍柴动力股份有限公司 | A kind of adaptive approach and system of baud rate |
CN110377304A (en) * | 2019-07-12 | 2019-10-25 | 安徽江淮汽车集团股份有限公司 | A kind of vehicle-mounted T-BOX method of hardware and software platform, system, storage medium and application |
CN110912914A (en) * | 2019-11-29 | 2020-03-24 | 株洲新奥燃气有限公司 | Gas pipe network monitoring data acquisition terminal and multi-protocol matching method |
CN111314018A (en) * | 2019-11-01 | 2020-06-19 | 珠海格力电器股份有限公司 | Baud rate self-adaptive adjustment processing system and method and information data processing terminal |
CN111371827A (en) * | 2018-12-26 | 2020-07-03 | 中兴通讯股份有限公司 | Data transmission method, device and computer readable storage medium |
CN111565138A (en) * | 2019-02-13 | 2020-08-21 | 厦门雅迅网络股份有限公司 | CAN bus baud rate self-adaption method based on dual systems and storage medium |
CN111796579A (en) * | 2020-06-30 | 2020-10-20 | 东风电驱动***有限公司 | CAN bus baud rate configuration method and system for vehicle remote monitoring terminal |
CN111913905A (en) * | 2020-06-30 | 2020-11-10 | 中国航发南方工业有限公司 | Variable self-adaptive serial port communication method, medium and electronic equipment |
CN112559412A (en) * | 2021-03-01 | 2021-03-26 | 上海灵动微电子股份有限公司 | Serial port baud rate self-adaptive receiving end, realization method and system |
WO2021173120A1 (en) * | 2020-02-25 | 2021-09-02 | Calamp Corp. | Systems and methods for detection of vehicle bus protocol using signal analysis |
CN113891183A (en) * | 2021-08-26 | 2022-01-04 | 宁波三星智能电气有限公司 | Bidirectional interactive communication baud rate self-adaption method |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7965734B2 (en) * | 2005-12-15 | 2011-06-21 | Paradox Security Systems Ltd. | Device network interface |
WO2015102579A1 (en) * | 2013-12-30 | 2015-07-09 | Schneider Electric It Corporation | System and method for automatically selecting baud rate in a can network |
US10171169B2 (en) * | 2016-06-07 | 2019-01-01 | Ciena Corporation | Software programmable flexible and dynamic optical transceivers |
US11561534B2 (en) * | 2018-08-06 | 2023-01-24 | Siemens Aktiengesellschaft | Adaptive repeater for industrial communication |
US20220061008A1 (en) * | 2020-08-21 | 2022-02-24 | Advanced Energy Industries, Inc. | Uart transmissions with two start bits for automatic baud detection and reduced clock skew |
-
2022
- 2022-04-13 CN CN202210385099.6A patent/CN114866367B/en active Active
Patent Citations (24)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5507040A (en) * | 1993-06-10 | 1996-04-09 | Motorola, Inc. | Method and apparatus for battery saving in a radio communication device |
US5490209A (en) * | 1994-02-09 | 1996-02-06 | Harris Corporation | Autobaud rate detection mechanism |
US6847615B1 (en) * | 1997-11-13 | 2005-01-25 | Optimay Corporation | Baud rate detection in serial data transmission |
US6366610B1 (en) * | 1998-05-15 | 2002-04-02 | Advanced Micro Devices, Inc. | Autobauding with adjustment to a programmable baud rate |
CN103777538A (en) * | 2012-10-19 | 2014-05-07 | 重庆长安汽车股份有限公司 | Baud-rate automatic matching method for controller and CAN bus |
CN106464559A (en) * | 2014-05-26 | 2017-02-22 | 康西欧控股有限公司 | High speed embedded protocol for distributed control system |
CN103986610A (en) * | 2014-06-04 | 2014-08-13 | 珠海格力电器股份有限公司 | Communication interface matching method, device and controller |
CN104796222A (en) * | 2014-11-21 | 2015-07-22 | 湖南先步信息股份有限公司 | A CAN baud-rate automatic matching method |
CN106130856A (en) * | 2016-08-17 | 2016-11-16 | 天津市英贝特航天科技有限公司 | A kind of self adaptation baud rate RS485 communications protocol |
CN106411641A (en) * | 2016-09-20 | 2017-02-15 | 宁波中车时代传感技术有限公司 | Method for automatically detecting Baud rate of CAN bus |
CN107038135A (en) * | 2017-03-24 | 2017-08-11 | 深圳市顺讯电子有限公司 | A kind of serial port baud rate Adaptable System and method |
CN207560000U (en) * | 2017-10-30 | 2018-06-29 | 深圳市三旺通信技术有限公司 | The controller LAN optic fiber converter of baud rate self-adapting |
CN108226598A (en) * | 2018-01-05 | 2018-06-29 | 深圳市道通科技股份有限公司 | A kind of oscilloscope signal interpretation method, device and oscillograph |
CN109274567A (en) * | 2018-09-27 | 2019-01-25 | 潍柴动力股份有限公司 | A kind of adaptive approach and system of baud rate |
CN111371827A (en) * | 2018-12-26 | 2020-07-03 | 中兴通讯股份有限公司 | Data transmission method, device and computer readable storage medium |
CN111565138A (en) * | 2019-02-13 | 2020-08-21 | 厦门雅迅网络股份有限公司 | CAN bus baud rate self-adaption method based on dual systems and storage medium |
CN110377304A (en) * | 2019-07-12 | 2019-10-25 | 安徽江淮汽车集团股份有限公司 | A kind of vehicle-mounted T-BOX method of hardware and software platform, system, storage medium and application |
CN111314018A (en) * | 2019-11-01 | 2020-06-19 | 珠海格力电器股份有限公司 | Baud rate self-adaptive adjustment processing system and method and information data processing terminal |
CN110912914A (en) * | 2019-11-29 | 2020-03-24 | 株洲新奥燃气有限公司 | Gas pipe network monitoring data acquisition terminal and multi-protocol matching method |
WO2021173120A1 (en) * | 2020-02-25 | 2021-09-02 | Calamp Corp. | Systems and methods for detection of vehicle bus protocol using signal analysis |
CN111796579A (en) * | 2020-06-30 | 2020-10-20 | 东风电驱动***有限公司 | CAN bus baud rate configuration method and system for vehicle remote monitoring terminal |
CN111913905A (en) * | 2020-06-30 | 2020-11-10 | 中国航发南方工业有限公司 | Variable self-adaptive serial port communication method, medium and electronic equipment |
CN112559412A (en) * | 2021-03-01 | 2021-03-26 | 上海灵动微电子股份有限公司 | Serial port baud rate self-adaptive receiving end, realization method and system |
CN113891183A (en) * | 2021-08-26 | 2022-01-04 | 宁波三星智能电气有限公司 | Bidirectional interactive communication baud rate self-adaption method |
Non-Patent Citations (3)
Title |
---|
"CAN总线波特率自适应程序设计";刘洁;《智能制造》;全文 * |
Modbus通讯参数的一种自动检测方法;魏祯毅,杨江;工业控制计算机(第07期);全文 * |
波特率自适应的CAN驱动在嵌入式Linux下的实现;史小燕;朱建鸿;;计算机***应用(第01期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN114866367A (en) | 2022-08-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN100366029C (en) | Communication controller, host-side controller, communication equipment, communication system and method | |
TWI332330B (en) | Quality of service differentiation in wireless networks | |
JP6100149B2 (en) | System and method for parallel communication with legacy WLAN receivers | |
US7852823B2 (en) | Communication management method, communication terminal, communication management program, recording medium containing the communication management program, and communication system | |
RU2010128579A (en) | METHOD AND DEVICE FOR SOLVING PROBLEMS OF BLIND NODE IN WIRELESS NETWORKS | |
JP4507005B2 (en) | Wireless communication system, wireless communication method and program | |
US8879531B2 (en) | Mobile router capable of automatically detecting network connection mode and performing network connection setting, and method thereof | |
CN104081797A (en) | Network system configured for resolving forward error correction during a data mode | |
EP3050342A2 (en) | Method for testing a wireless link of a wi-fi node, and circuit performing the method | |
CN114866367B (en) | CAN equipment communication method and device, CAN optical cat equipment and medium | |
US20230262775A1 (en) | Method and apparatus for implementing collision detection in data transmission | |
US20180219732A1 (en) | Negotiation Mode Processing Method and Intelligent Network Device | |
CN111601335B (en) | Wireless network performance test method and wireless AP | |
JP2007088775A (en) | Radio communication system, device, and method | |
US10153961B2 (en) | Communication device, communication method, and communication system | |
CN114020304A (en) | LoRaWan-based OTA implementation method, terminal device and computer storage medium | |
CN105100000B (en) | Interface conversion device and network system | |
WO2024031995A1 (en) | Data interaction method based on near field communication | |
CN114826315B (en) | Remote transmission method, device, equipment and medium of CAN (controller area network) optical cat equipment | |
CN208076997U (en) | A kind of equipment high in the clouds monitoring management system | |
WO2012155703A1 (en) | Link parameter autonegotiation method, terminal and system based on hdlc protocol | |
CN103795507B (en) | The instruction Retransmission timeout method of EPON system and instruction Retransmission timeout system | |
JP6181340B1 (en) | Control of power consumption in power amplifiers in communication devices | |
CN1550081A (en) | Data rate negotiation method using a mean square error technique | |
CN117992201A (en) | Interrupt information processing method, electronic device, and readable 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 |