[go: up one dir, main page]

CN114866367A - CAN equipment communication method and device, CAN optical modem equipment and medium - Google Patents

CAN equipment communication method and device, CAN optical modem equipment and medium Download PDF

Info

Publication number
CN114866367A
CN114866367A CN202210385099.6A CN202210385099A CN114866367A CN 114866367 A CN114866367 A CN 114866367A CN 202210385099 A CN202210385099 A CN 202210385099A CN 114866367 A CN114866367 A CN 114866367A
Authority
CN
China
Prior art keywords
baud rate
data stream
local
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.)
Granted
Application number
CN202210385099.6A
Other languages
Chinese (zh)
Other versions
CN114866367B (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.)
3onedata Co ltd
Original Assignee
3onedata 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 3onedata Co ltd filed Critical 3onedata Co ltd
Priority to CN202210385099.6A priority Critical patent/CN114866367B/en
Publication of CN114866367A publication Critical patent/CN114866367A/en
Application granted granted Critical
Publication of CN114866367B publication Critical patent/CN114866367B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/4013Management of data rate on the bus
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40143Bus networks involving priority mechanisms
    • H04L12/40163Bus networks involving priority mechanisms by assigning priority to messages according to a message field
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40215Controller Area Network CAN
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing 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 and device, CAN optical modem equipment and a medium. After the CAN optical modem device 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 local CAN data stream is obtained through the local CAN transceiver and is sent to the processor and the 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 preset baud rate is successfully matched with the local CAN data stream in a self-adaptive manner, the optical modem equipment and the optical modem equipment at the remote opposite end start normal communication; therefore, normal communication among different CAN optical modem devices is realized through baud rate self-adaption.

Description

CAN equipment communication method and device, CAN optical modem equipment and medium
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 modem equipment and a medium.
Background
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 applied, such as automobile, elevator control, power system control, etc., and various technologies have been mature. Compared with the cable based on twisted pair or coaxial cable, the low transmission loss based on the optical fiber CAN greatly increase the CAN signal transmission distance; the optical fiber has the characteristics of no energy radiation, no electricity conduction, no inductance and the like, so that the optical fiber does not have the influence of crosstalk and mutual interference of optical signals and has excellent EMI resistance and EMC characteristics. It is clear that it would be a great advantage to convert a CAN bus based on conventional twisted pair or coaxial cable to a CAN bus based on fiber optic transmission.
However, the CAN bus uses different baud rates in different application environments (mainly communication distance), and the CAN baud rates of all devices using the same CAN bus for communication must be consistent, otherwise the devices cannot correctly receive and transmit CAN data. This will bring a problem of how to realize fast baud rate adaptation between different CAN devices through the optical fiber transmission device.
Disclosure of Invention
The invention mainly aims to provide a baud rate self-adaption method and device, CAN optical modem equipment and a medium, and aims to realize normal communication between different CAN optical modem 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, where 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 modem 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 CAN data stream of the opposite end, the local CAN data stream is obtained through the local CAN transceiver and is sent to the processor and the remote opposite end optical port;
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 if the preset baud rate is successfully matched with the baud rate of the local CAN data stream in a self-adaptive manner, 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 modem 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, the sending end of the local optical port is closed, and the CAN data stream of the opposite end is sent to a processor through the receiving end;
decoding the opposite-end CAN data stream through the processor to obtain a decoded opposite-end CAN data stream;
and sending the decoded CAN data stream of the opposite terminal to a local CAN bus, and outputting the decoded CAN data stream of the opposite terminal through the local CAN bus.
Preferably, after the step of sending 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 includes:
and receiving the CAN data stream of the next opposite terminal through the receiving terminal.
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:
coding the local CAN data stream through the processor to obtain a coded local CAN data stream;
checking the initial bit of the coded local CAN data stream, and judging whether the initial bit is in compliance;
if the check result of the start bit is in compliance, starting the standard baud rate timer set, checking the standard frame baud rate of the coded 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 an extended frame baud rate of the coded local CAN data stream, and judging whether the extended frame baud rate is in the preset baud rate;
if the extended frame baud rate is in the preset baud rate, checking the CRC segment baud rate of the coded local CAN data stream, and judging whether the CRC segment baud rate exists in the preset baud rate;
if the CRC section baud rate is in the preset baud rate, detecting whether the baud rate of the coded local CAN data stream is consistent in standard frame baud rate verification, extended frame baud rate verification and CRC section baud rate verification;
and if the baud rate of the coded local CAN data stream is consistent, the baud rate self-adaptive matching of the local CAN data stream is successful, and the baud rate self-adaptive matching is exited.
Preferably, if the CRC segment baud rate is within the preset baud rate, after detecting whether the baud rate of the encoded local CAN data stream is consistent in the standard frame baud rate verification, the extended frame baud rate verification, and the CRC segment baud rate verification, the CAN device communication method further includes:
if the baud rate of the coded local CAN data stream is inconsistent in the standard frame baud rate checking process, the extended frame baud rate checking process and the CRC section baud rate checking process, the baud rate self-adaption matching of the local CAN data stream fails, and the next opposite-end CAN data stream is received by the receiving end.
Preferably, after the step of setting a baud rate timer set by the processor based on a preset communication protocol and performing baud rate matching between each preset baud rate in the baud rate timer set and the local CAN data stream, the CAN device communication method further includes:
and if the self-adaptive matching between 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 is received by the receiving end.
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 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 modem device is powered on and reset;
a sending module, configured to obtain a local CAN data stream through the local CAN transceiver if the receiving end does not receive the opposite-end CAN data stream, and send the local CAN data stream to the processor and the remote-end optical port;
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 preset baud rate is successfully matched with the baud rate of the local CAN data stream in a self-adaptive manner.
In addition, to achieve the above object, the present invention further provides a CAN optical modem device, including: the CAN device communication method comprises a memory, a processor and a CAN device communication program which is stored on the memory and CAN run on the processor, wherein the CAN device communication program realizes the steps of the CAN device communication method when being executed by the processor.
Further, to achieve the above object, the present invention also provides a medium which is a computer-readable storage medium having a CAN device communication program stored thereon, the CAN device communication program, when executed by a processor, implementing the steps of the CAN device communication method as described above.
The invention provides a CAN equipment communication method, a device, CAN optical modem equipment and a medium; the CAN equipment communication method is applied to CAN optical modem equipment, the CAN optical modem 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 modem 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 CAN data stream of the opposite end, the local CAN data stream is obtained through the local CAN transceiver and is sent to the processor and the remote opposite end optical port; 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 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 the CAN optical modem device 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 local CAN data stream is obtained through the local CAN transceiver and is sent to the processor and the 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 preset baud rate is successfully matched with the local CAN data stream in a self-adaptive manner, the optical modem equipment and the optical modem equipment at the remote opposite end start normal communication; therefore, normal communication among different CAN optical modem devices is realized through baud rate self-adaption.
Drawings
FIG. 1 is a schematic diagram of an apparatus architecture of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart diagram of a first embodiment of a CAN device communication method of the present invention;
fig. 3 is a schematic diagram of a hardware structure of a CAN optical modem 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 a data frame baud rate according to a first embodiment of the CAN device communication method of the present invention;
FIG. 5 is a flowchart illustrating a CAN device communication method according to a second embodiment of the present invention;
FIG. 6 is a schematic view of a sub-flow of a second embodiment of a CAN device communication method according to the present invention;
FIG. 7 is a flowchart illustrating a CAN device communication method according to a third embodiment of the present invention;
FIG. 8 is a schematic sub-flow diagram of a CAN device communication method according to a third embodiment of the present invention;
FIG. 9 is a schematic flow chart of a communication method for CAN devices according to a fourth embodiment of the present invention;
fig. 10 is a schematic flow chart of a fifth embodiment of a CAN device communication method according to the present invention;
fig. 11 is a functional block diagram of a CAN device communication apparatus according to a first embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, fig. 1 is a schematic device structure diagram of a hardware operating 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 a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also 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 non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 1 is not intended to be limiting of the apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a CAN device communication program.
The operating system is a program for managing and controlling CAN optical modem 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 for managing and controlling the network interface 1002; the user interface module is used to manage and control the user interface 1003.
In the CAN optical modem device shown in fig. 1, the CAN optical modem device calls a CAN device communication program stored in a memory 1005 by a processor 1001 and performs operations in the following CAN device communication method embodiments.
Based on the hardware structure, the embodiment of the communication method of the CAN equipment 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, after the CAN optical modem device is powered on and reset, determining whether the receiving end of the local optical port receives an opposite-end CAN data stream input from a remote-end optical port;
step S20, if the receiving end does not receive the opposite-end CAN data stream, obtaining a local CAN data stream through the local CAN transceiver, and sending the local CAN data stream to the processor and the remote-end optical port;
step S30, 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 step S40, if the preset baud rate is successfully matched with the baud rate of the local CAN data stream in a self-adaptive mode, normal communication is started.
In this embodiment, after the CAN optical modem device starts working, it is determined whether the receiving end of the local optical port receives an opposite-end CAN data stream input from the remote opposite-end optical port; when the receiving end does not receive the CAN data stream of the opposite end, the local CAN data stream is obtained through the local CAN transceiver and is sent to the processor and the 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 preset baud rate is successfully matched with the local CAN data stream in a self-adaptive manner, the optical modem equipment and the optical modem equipment at the remote opposite end start normal communication; therefore, normal communication among different CAN optical modem devices is realized through baud rate self-adaption.
The respective steps will be described in detail below:
step S10, after the CAN optical modem device is powered on and reset, 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.
In this embodiment, a CAN (Control Area Network) is a serial communication Network that CAN effectively support distributed Control and real-time Control; 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 a CAN optical modem device; the remote transmission method of the CAN optical modem equipment is applied to the CAN optical modem equipment; the CAN optical modem device 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 modem equipment system CAN select one of FPGA (programmable gate array), MCU (processor) and ASIC (custom chip) as a processor, and the processor is used for processing and transmitting CAN data frames; when the CAN data frame is an 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, performs baud rate adaptive matching after encoding, initiates a local frame response signal when the baud rate adaptive matching is successful, and sends the local frame response signal to the local CAN transceiver. In order to improve the anti-interference performance of the CAN optical modem equipment, the local CAN transceiver is connected with the FPGA (field programmable gate array) after passing through an isolated DC-DC (isolated power supply); the local optical port receives or transmits the CAN data flow through Ethernet PHY processing, or directly adopts TTL optical head to receive or transmit the CAN data flow through optical signal processing.
After the CAN optical modem device is powered on and reset, a local optical port processes an optical signal through an Ethernet PHY or a TTL optical head to receive or send a CAN data stream; the CAN data stream CAN be a local CAN data stream, and CAN also be an opposite terminal CAN data stream which is remotely input to an optical port; usually, the local optical port preferentially processes the opposite-end CAN data stream input by the remote opposite-end optical port, and then the local CAN data stream is processed only after the opposite-end CAN data stream input by the remote opposite-end optical port is completely processed.
After the CAN optical modem device is powered on and reset, that is, after the CAN optical modem device starts to work, it needs to be 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.
Step S20, if the receiving end does not receive the opposite-end CAN data stream, obtaining a local CAN data stream through the local CAN transceiver, and sending the local CAN data stream to the processor and the remote-end optical port.
In this embodiment, after the CAN optical modem device starts to operate, the receiving end of the local optical port is in an open state by default, and the sending end of the local optical port is in a closed state.
When the receiving end of the local optical port does not receive the CAN data stream of the opposite end input by the remote opposite end optical port, closing the receiving end of the local optical port and opening the sending end of the local optical port; and the local CAN data stream is acquired 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.
And step S30, 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.
In one embodiment, according to a preset communication protocol, a processor sets various standard baud rate timers, and constructs a baud rate timer set by the various 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 rates include 10Kbps, 20Kbps, 25Kbps, 50Kbps, 100Kbps, 125Kbps, 200Kbps, 500Kbps, 800Kbps, and 1 Mbps. The number of actual baud rate timer sets may be set according to actual circumstances.
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 frame structure diagram of the data frame baud rate, for example, the data frame baud rate is composed of 7 segments, which are respectively: a start frame indicating a segment from which the data frame starts; an arbitration segment indicating a priority of the frame; a control section indicating a section of the number of bytes and reserved bits of the data; a data segment which represents the content of data and can transmit 0-8 bytes of data; a CRC section which checks a transmission error section of the frame; an ACK segment indicating a segment for which normal reception is acknowledged; end of frame, segment indicating end of data frame.
And carrying out baud rate self-adaptive matching on each preset baud rate and the baud rate of the coded local CAN data stream, and detecting whether a preset baud rate matched with the baud rate of the coded local CAN data stream exists in the baud rate timer set.
Preferably, in an embodiment, all the preset baud rates in the baud rate timer set are simultaneously subjected to baud rate adaptive matching with the baud rate of the encoded local CAN data stream, and whether a 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 baud rate self-adaptive matching of the preset baud rate and the coded local CAN data stream is successful, taking the successfully matched preset baud rate as a correct baud rate, recording the correct baud rate, and quitting the baud rate self-adaptive matching;
and if the self-adaptive matching between the preset baud rate and the baud rate of the coded local CAN data stream is not successful, receiving the next opposite-end CAN data stream through the receiving end.
Therefore, the baud rate of the local CAN data stream CAN be intelligently and quickly identified, the baud rate is accurately matched in a self-adaptive mode, and the matching efficiency is high.
Preferably, in another embodiment, the baud rate self-adaptive matching is performed on the preset baud rates in the baud rate timer set and the baud rate of the encoded local CAN data stream one by one, 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 baud rate self-adaptive matching of the preset baud rate and the coded local CAN data stream is successful, taking the successfully matched preset baud rate as a correct baud rate, recording the correct baud rate, and quitting the baud rate self-adaptive matching;
if the current baud rate does not exist, when the preset baud rate in the baud rate timer set is not used, the correct baud rate may exist in the rest preset baud rates in the baud rate timer set, and then baud rate self-adaptive matching is performed with the baud rates of the coded local CAN data streams one by one according to the unused preset baud rates in the baud rate timer set.
Therefore, the baud rate of the local CAN data stream CAN be intelligently and quickly identified, the baud rate is accurately matched in a self-adaptive mode, 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 preset baud rate comprises a standard baud rate of a preset CiA protocol or a preset 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 a universal standard baud rate and has a unified and standardized format; the standard baud rate of the preset communication protocol can make the communication of various devices easily compatible, and is easy to develop and maintain.
The preset user-defined baud rate refers to the baud rate defined by the user according to the requirements of equipment communication according to a preset communication protocol, and the safety and the privacy of the equipment communication can be realized.
And step S40, if the preset baud rate is successfully matched with the baud rate of the local CAN data stream in a self-adaptive mode, normal communication is started.
In one embodiment, when a preset baud rate is detected in the baud rate timer set and the baud rate of the coded local CAN data stream is successfully matched in a self-adaptive manner, the successfully matched preset baud rate is used as a correct baud rate, and the correct baud rate is recorded; and realizing normal communication between the optical modem equipment and the optical modem equipment at the remote opposite end through the correct baud rate.
In one embodiment, when a preset baud rate is detected in the baud rate timer set and the baud rate of the coded local CAN data stream is successfully matched in a self-adaptive manner, the successfully matched preset baud rate is used as a correct baud rate, and the correct baud rate is recorded; after the optical modem device and the optical modem device at the remote opposite end are normally communicated through the correct baud rate; returning to execute the step of judging whether the receiving end of the local optical port receives the CAN data stream of the opposite end input by the remote opposite end optical port; then executing the next step; therefore, the communication efficiency of the CAN optical modem equipment is improved.
In this embodiment, after the CAN optical modem device starts working, it is determined whether the receiving end of the local optical port receives an opposite-end CAN data stream input from the remote opposite-end optical port; when the receiving end does not receive the CAN data stream of the opposite end, the local CAN data stream is obtained through the local CAN transceiver and is sent to the processor and the 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 preset baud rate is successfully matched with the local CAN data stream in a self-adaptive manner, the optical modem equipment and the optical modem equipment at the remote opposite end start normal communication; therefore, normal communication among different CAN optical modem 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 second embodiment of the CAN device communication method is different from the first embodiment of the CAN device communication method in that in this embodiment, for 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 peer CAN data stream input by the remote peer 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 sending end of the local optical interface, and sending 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 A30, sending the decoded CAN data stream of the opposite terminal to a local CAN bus, and outputting the decoded CAN data stream of the opposite terminal through the local CAN bus.
In this embodiment, when the receiving end of the local optical port receives the CAN data stream of the opposite end, the sending end of the local optical port is closed, and the received CAN data stream of the opposite end is sent to the processor through the receiving end of the local optical port; decoding the CAN data stream of the opposite terminal through a processor to obtain the decoded CAN data stream of the opposite terminal; inputting the decoded CAN data stream of the opposite terminal into a local CAN bus of a local CAN transceiver through a processor, and outputting the decoded CAN data stream of the opposite terminal to equipment connected with a remote opposite terminal through the local CAN bus; therefore, normal communication with the CAN signal of the opposite terminal is realized.
The respective steps will be described in detail below:
step a10, if the receiving end receives the opposite-end CAN data stream, closing the sending end of the local optical interface, and sending the opposite-end CAN data stream to a processor through the receiving end.
In this embodiment, the local optical interface includes a receiving end and a transmitting end; the receiving end is used for receiving an 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 modem device is powered on and reset, namely after the CAN optical modem device starts to work, the receiving end of the local optical port is in an open state by default, and the sending end of the local optical port is in a closed state.
When the receiving end of the local optical port receives the CAN data stream of the opposite end input by the remote opposite end optical port, the sending end of the local optical port is closed; and the received CAN data stream of the opposite terminal is sent to the processor by the receiving end of the local optical port, and the CAN data stream of the opposite terminal is processed by the processor, so that the CAN data stream of the opposite terminal CAN be identified by the local CAN transceiver.
And A20, decoding the opposite-end CAN data stream through 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 perform bit-by-bit detection on the opposite-end CAN data stream, determine whether the opposite-end CAN data stream is correct, and if the opposite-end CAN data stream is correct, obtain the decoded opposite-end CAN data stream.
And A30, sending the decoded CAN data stream of the opposite terminal to a local CAN bus, and outputting the decoded CAN data stream of the opposite terminal through the local CAN bus.
In one embodiment, the decoded CAN data stream of the opposite terminal is transmitted to a local CAN bus of a local CAN transceiver through a local optical port; and outputting the decoded CAN data stream of the opposite terminal to a device connected with the remote opposite terminal 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:
step a40, receiving the next peer CAN data stream through 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 end through the decoded peer end CAN data stream, the next peer end CAN data stream received by the receiving end of the local optical port is used, and then the next step is performed.
In an embodiment, when a receiving end of a local optical port receives an opposite-end CAN data stream, the sending end of the local optical port is closed, and the received opposite-end CAN data stream is sent to a processor through the receiving end of the local optical port; decoding the CAN data stream of the opposite terminal through a processor to obtain the decoded CAN data stream of the opposite terminal; inputting the decoded CAN data stream of the opposite terminal into a local CAN bus of a local CAN transceiver through a processor, and outputting the decoded CAN data stream of the opposite terminal to equipment connected with a remote opposite terminal through the local CAN bus; therefore, normal communication with the CAN signal of the opposite terminal is realized.
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 is different from the first, second, and third embodiments of the CAN device communication method in that the third embodiment of the CAN device communication method is that in this embodiment, in step S30, each preset baud rate in the baud rate timer set and the local CAN data stream are refined in baud rate adaptive matching, and with reference to fig. 7, the step specifically includes:
step S31, the processor encodes the local CAN data stream to obtain an encoded local CAN data stream;
step S32, checking the start bit of the coded local CAN data stream, and judging whether the start bit is in compliance;
step S33, if the check result of the start bit is in compliance, starting the standard baud rate timer set, checking the standard frame baud rate of the coded 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 extension frame baud rate of the coded local CAN data stream, and judging whether the extension 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 coded local CAN data stream, and judging whether the CRC section baud rate exists in the preset baud rate;
step S36, if the CRC section baud rate is in the preset baud rate, detecting whether the baud rate of the coded local CAN data stream is consistent in the standard frame baud rate verification, the extended frame baud rate verification and the CRC section baud rate verification;
step S37, if the baud rates of the coded local CAN data streams are consistent, the baud rate adaptive matching of the local CAN data streams is successful, and the baud rate adaptive matching is exited.
In the embodiment, a local CAN data stream is encoded by a processor to obtain an encoded local CAN data stream; carrying out baud rate adaptive matching on each preset baud rate and the coded local CAN data stream; the baud rate self-adaptive matching comprises initial bit check, extended frame baud rate check, CRC section baud rate check, and detection of whether the baud rate of the coded local CAN data stream is consistent in standard frame baud rate check, extended frame baud rate check and CRC section baud rate check; when the baud rate self-adaptive matching of the local CAN data stream is successful, the baud rate self-adaptive matching is exited; therefore, normal communication of CAN signals is realized.
The respective steps will be described in detail below:
and step S31, coding the local CAN data stream through the processor to obtain a coded 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 optical port of the remote opposite terminal CAN correctly identify the local CAN data stream; after the processor encodes the local CAN data stream, the baud rate self-adaption matching is carried out on the encoded local CAN data stream.
And step S32, checking the start bit of the coded local CAN data stream, and judging whether the start bit is in compliance.
In this embodiment, the baud rate adaptive matching includes start bit check, standard frame baud rate check, extended frame baud rate check, CRC segment baud rate check, and detection of 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 segment baud rate check processes. Referring to fig. 8, whether the start bit of the encoded local CAN data stream is compliant is determined by checking the start bit of the encoded local CAN data stream; and when the initial bit of the local CAN data stream is detected to be low level, the detection result of the initial bit of the local CAN data stream is in compliance.
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 quitted; and then 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 or not, receiving the opposite-end CAN data stream input by the next remote opposite-end optical port through the receiving end of the local optical port, and then executing the next step.
Step S33, if the check result of the start bit is compliant, starting the standard baud rate timer set, checking the standard frame baud rate of the encoded local CAN data stream, and determining whether the standard frame baud rate is in the preset baud rate.
In this embodiment, referring to fig. 8, when 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 at a certain fixed baud rate, and meanwhile, the standard frame baud rate of the encoded local CAN data stream is verified, and it is determined whether the standard frame baud rate of the local CAN data stream is within the preset baud rate.
If the coded local CAN data stream is in standard frame baud rate verification compliance, the coded local CAN data stream has the following characteristics: for standard format frames, there is a total of 18 bits of frame data, and the 13 th bit (identifier extension bit, i.e., IDE bit) is dominant. The standard frame type is divided into two formats, namely a data frame format and a remote frame format, which are judged by a remote frame transmission identifier RTR bit (remote transfer request bit, also called RTR bit), and the remote frame transmission identifier RTR bit of the standard frame type is located at the 12 th bit. For the standard frame type, if the RTR bit is dominant, the coded local CAN data stream is a standard type data frame; if the RTR bit is hidden, the coded local CAN data stream is a standard type remote frame; if these 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 in compliance, quitting baud rate self-adaptive matching; and then 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 or not, receiving the opposite-end CAN data stream input by the next remote opposite-end optical port through the receiving end of the local optical port, and then executing the next step.
And when the coded local CAN data stream is in standard frame baud rate check compliance, continuously judging whether the standard frame baud rate of the local CAN data stream is in the preset baud rate.
Step S34, if the standard frame baud rate is in the preset baud rate, checking the extended frame baud rate of the encoded local CAN data stream, and determining whether the extended 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 forward at a certain fixed baud rate, and the encoded local CAN data stream extension frame baud rate is verified; and judging whether the Baud rate of the extended frame of the coded local CAN data stream is in a preset Baud rate or not.
Referring to fig. 8, the extended frame baud rate verification compliance of the encoded local CAN data stream has the following characteristics: a determination is made at the identifier extension bit IDE bit (bit 13): when the identifier extension bit IDE bit is a recessive bit, the coded local CAN data stream is of an extension frame type; the type of the extended frame is divided into a data frame format and a remote frame format, the two formats are judged by a remote frame sending identifier RTR bit (remote transmission request bit, namely RTR bit), if the RTR bit is dominant, the coded local CAN data stream is an extended type data frame; and if the RTR bit is hidden, the coded local CAN data stream is an extended type remote frame. If these two conditions are met, then the detection of the remote transmission request bit of the local CAN data stream is compliant.
When the verification result of the baud rate of the extended frame of the local CAN data stream is not in compliance, the baud rate self-adaptive matching is quitted; and then 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 or not, receiving the opposite-end CAN data stream input by the next remote opposite-end optical port through the receiving end of the local optical port, and then executing the next step.
And when the coded local CAN data stream is in the extended frame baud rate verification compliance, continuously judging whether the extended 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 segment baud rate of the encoded local CAN data stream, and determining whether the CRC segment baud rate exists in the preset baud rate.
In this embodiment, when the baud rate of the extension frame of the local CAN data stream is within the preset baud rate, the encoded local CAN data stream is continuously advanced forward at a certain fixed baud rate, and meanwhile, the encoded local CAN data stream CRC segment baud rate is verified; and judging whether the CRC section baud rate of the coded local CAN data stream is in a preset baud rate or not.
Referring to fig. 8, when the number of bits of the checksum accumulated in the encoded local CAN data stream reaches 16 bits, the check result of the CRC section baud rate of the encoded local CAN data stream is compliant.
When the detection result of the CRC section baud rate of the local CAN data stream is not in compliance, the baud rate self-adaptive matching is quitted; and then 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 or not, receiving the opposite-end CAN data stream input by the next remote opposite-end optical port through the receiving end of the local optical port, and then executing the next step.
And when the encoded local CAN data stream is in the CRC section baud rate verification compliance, 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 within 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, it is detected whether the baud rate of the encoded local CAN data stream has a change in the standard frame baud rate verification, the extended frame baud rate verification, and the CRC segment baud rate verification processes.
If the baud rate of the coded local CAN data stream is different in the standard frame baud rate verification process, the extended frame baud rate verification process and the CRC section baud rate verification process; the method comprises the steps of continuously advancing with a fixed baud rate a in the standard frame baud rate checking process, continuously advancing with a fixed baud rate b in the extended frame baud rate checking process, and continuously advancing with a fixed baud rate c in the CRC section baud rate checking process.
Or the coded local CAN data stream is continuously pushed forward at a fixed baud rate a in the standard frame baud rate verification and the extended frame baud rate verification processes; and in the CRC section baud rate checking process, the baud rate of the coded local CAN data stream is continuously pushed forward at a fixed baud rate b.
Step S37, if the baud rates of the coded local CAN data streams are consistent, the baud rate adaptive matching of the local CAN data streams is successful, and the baud rate 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 section baud rate verification processes, the baud rate adaptive matching of the local CAN data stream is successful, and the baud rate adaptive matching is exited.
In this embodiment, a processor encodes a 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 coded local CAN data stream; the baud rate self-adaptive matching comprises initial bit check, extended frame baud rate check, CRC section baud rate check, and detection of whether the baud rate of the coded local CAN data stream is consistent in standard frame baud rate check, extended frame baud rate check and CRC section baud rate check; when the baud rate self-adaptive matching of the local CAN data stream is successful, the baud rate self-adaptive matching is exited; therefore, normal communication of CAN signals is realized.
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 the present embodiment is to step S37, and after the step of performing baud rate adaptive matching on the local CAN data stream is exited after the step of performing baud rate adaptive matching is successful if the baud rate of the coded local CAN data stream is consistent, referring to fig. 9, the CAN device communication method further includes:
step B10, if the baud rate of the coded local CAN data stream is inconsistent in the standard frame baud rate check, the extended frame baud rate check and the CRC segment baud rate check, the baud rate of the local CAN data stream fails to be adaptively matched, 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 standard frame baud rate verification, the extended frame baud rate verification and the CRC segment baud rate verification processes, the baud rate of the local CAN data stream fails to be adaptively matched, and the next opposite-end CAN data stream is received by the receiving end; carrying out baud rate adaptive matching on the CAN data stream of the next opposite terminal; therefore, the communication efficiency of the CAN optical modem device is improved.
The respective steps will be described in detail below:
step B10, if the baud rate of the coded local CAN data stream is inconsistent in the standard frame baud rate check, the extended frame baud rate check and the CRC segment baud rate check, the baud rate of the local CAN data stream fails to be adaptively matched, 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 coded local CAN data stream changes in the standard frame baud rate verification, the extended frame baud rate verification, and the CRC segment baud rate verification processes, when it is detected that the baud rates of the local CAN data streams are inconsistent in the standard frame baud rate verification, the extended frame baud rate verification, and the CRC segment baud rate verification processes, the baud rate of the local CAN data stream fails in adaptive matching, and the next opposite-end CAN data stream is 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 standard frame baud rate verification, the extended frame baud rate verification and the CRC segment baud rate verification processes, the baud rate of the local CAN data stream fails to be adaptively matched, and the next opposite-end CAN data stream is received by the receiving end; therefore, the communication efficiency of the CAN optical modem equipment is improved.
Further, a fifth embodiment of the CAN device communication method of the present invention is proposed based on the first, second, third, and fourth embodiments of the CAN device communication method of the present invention.
The fifth embodiment of the CAN device communication method is different from the first, second, third, and fourth embodiments of the CAN device communication method in that after the step S30 of setting a baud rate timer set by the processor based on a preset communication protocol and performing a baud rate matching between each preset baud rate in the baud rate timer set 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 between 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 is received by the receiving end.
In this embodiment, when each preset baud rate in the baud rate timer set is not successfully adaptively matched with the baud rate 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; processing the CAN data stream of the next opposite terminal; therefore, the execution efficiency of the CAN optical modem device is improved.
The respective steps will be described in detail below:
and step C10, if the self-adaptive matching between 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 is received by the receiving end.
In this embodiment, when each preset baud rate in the baud rate timer set is not successfully adaptively matched with the baud rate 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; and processing the CAN data stream of the next opposite terminal.
In the 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 a self-adaptive manner, the CAN communication is abnormally ended, and the next opposite-end CAN data stream is received by the receiving end; processing the CAN data stream of the next opposite terminal; therefore, the execution efficiency of the CAN optical modem device is improved.
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, after the CAN optical modem device is powered on and reset, whether a receiving end of the local optical port receives an opposite-end CAN data stream input by a remote opposite-end optical port;
a sending module 20, configured to obtain a local CAN data stream through the local CAN transceiver if the receiving end does not receive the opposite-end CAN data stream, and send the local CAN data stream to the processor and the remote-end optical port;
the matching module 30 is configured to set a baud rate timer set through the processor 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 used for starting normal communication if the preset baud rate is successfully matched with the baud rate of the local CAN data stream in a self-adaptive manner.
Preferably, the CAN device communication apparatus further includes:
a sending module 50, configured to close a sending end of the local optical interface if the receiving end receives the opposite-end CAN data stream, and send the opposite-end CAN data stream to a processor through the receiving end;
a decoding module 60, configured to decode, by the processor, the peer-to-peer CAN data stream to obtain a decoded peer-to-peer CAN data stream;
and the output module 70 is configured to send the decoded peer-to-peer CAN data stream to a local CAN bus, and output the decoded peer-to-peer CAN data stream through the local CAN bus.
Preferably, the CAN device communication apparatus further includes:
the pass module 80 is configured to receive a next peer CAN data stream via the receiving end.
Preferably, the matching module 30 further includes:
presetting a module unit 10: the preset baud rate comprises a standard baud rate of a preset communication protocol or a user-defined baud rate of a preset user.
Preferably, the matching module 30 further comprises:
the encoding unit 20 is configured to encode the local CAN data stream through the processor to obtain an encoded local CAN data stream;
a start bit checking unit 30, configured to check a start bit of the encoded local CAN data stream, and determine whether the start bit is compliant;
a standard frame baud rate checking unit 40, configured to start the standard baud rate timer set if the check result of the start bit is compliant, check the standard frame baud rate of the encoded local CAN data stream, and determine whether the standard frame baud rate is within the preset baud rate;
an extended frame baud rate checking unit 50, configured to check the extended frame baud rate of the encoded local CAN data stream if the standard frame baud rate is within the preset baud rate, and determine whether the extended frame baud rate is within the preset baud rate;
a CRC segment baud rate checking unit 60, configured to check the CRC segment baud rate of the encoded local CAN data stream if the extended frame baud rate is within the preset baud rate, and determine whether the CRC segment baud rate is within the preset baud rate;
the detection unit 70 is configured to detect whether the baud rate of the encoded local CAN data stream is consistent in the standard frame baud rate verification, the extended frame baud rate verification, and the CRC section baud rate verification processes if the CRC section baud rate is within the preset baud rate;
and the adaptive unit 80 is configured to, if the baud rates of the encoded local CAN data streams are consistent, successfully perform adaptive matching on the baud rates of the local CAN data streams, and quit the baud rate adaptive matching.
Preferably, the matching module 30 further comprises:
and the receiving unit 90 is configured to, if the baud rate of the encoded local CAN data stream is inconsistent in the standard frame baud rate verification, the extended frame baud rate verification, and the CRC section baud rate verification processes, fail to adaptively match the baud rate of the local CAN data stream, and pass through a next opposite-end CAN data stream received by the receiving end.
Preferably, the CAN device communication apparatus further includes:
and the standard module 90 is configured to end the CAN communication abnormally if there is no baud rate of the standard and the baud rate of the local CAN data stream are successfully matched in a self-adaptive manner, and receive the next opposite-end CAN data stream through the receiving end.
Furthermore, the present invention also provides a medium, which is a computer-readable storage medium, on which the CAN device communication program is stored, and the CAN device communication program, when executed by a processor, implements the steps of the CAN device communication method as described above.
The method implemented when the CAN device communication program running on the processor is executed may refer to each embodiment of the CAN device communication method of the present invention, and details are not described herein.
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 an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention or the portions contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) as described above and includes several instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention, and all equivalent structures or equivalent processes performed by the present specification and the attached drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A CAN equipment communication method is characterized in that the CAN equipment communication method is applied to CAN optical modem equipment, the CAN optical modem 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 modem 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 CAN data stream of the opposite end, the local CAN data stream is obtained through the local CAN transceiver and is sent to the processor and the remote opposite end optical port;
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 if the preset baud rate is successfully matched with the baud rate of the local CAN data stream in a self-adaptive manner, starting normal communication.
2. The CAN device communication method of claim 1, wherein the local CAN transceiver comprises a local CAN bus, and wherein after the step of determining whether a receiving end of the local optical port receives an opposite-end CAN data stream input from a remote opposite-end optical port after the CAN optical modem device is powered on and reset, the CAN device communication method further comprises:
if the receiving end receives the CAN data stream of the opposite end, the sending end of the local optical port is closed, and the CAN data stream of the opposite end is sent to a processor through the receiving end;
decoding the opposite-end CAN data stream through the processor to obtain a decoded opposite-end CAN data stream;
and sending the decoded CAN data stream of the opposite terminal to a local CAN bus, and outputting the decoded CAN data stream of the opposite terminal through the local CAN bus.
3. The CAN device communication method of claim 2, wherein after the step of sending the decoded peer CAN data stream to a local CAN bus and outputting the decoded peer CAN data stream over the local CAN bus, the CAN device communication method further comprises:
and receiving the next opposite-end CAN data stream through the receiving end.
4. The CAN device communication method of claim 1 wherein the predetermined baud rate comprises a standard baud rate of a predetermined communication protocol or a predetermined user-defined baud rate.
5. The CAN device communication method of claim 1 wherein said step of baud rate adaptively matching each preset baud rate in said set of baud rate timers to said local CAN data stream comprises:
coding the local CAN data stream through the processor to obtain a coded local CAN data stream;
checking the initial bit of the coded local CAN data stream, and judging whether the initial bit is in compliance;
if the check result of the start bit is in compliance, starting the standard baud rate timer set, checking the standard frame baud rate of the coded 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 an extended frame baud rate of the coded local CAN data stream, and judging whether the extended frame baud rate is in the preset baud rate;
if the extended frame baud rate is in the preset baud rate, checking the CRC segment baud rate of the coded local CAN data stream, and judging whether the CRC segment baud rate exists in the preset baud rate;
if the CRC section baud rate is in the preset baud rate, detecting whether the baud rate of the coded local CAN data stream is consistent in standard frame baud rate verification, extended frame baud rate verification and CRC section baud rate verification;
and if the baud rate of the coded local CAN data stream is consistent, the baud rate self-adaptive matching of the local CAN data stream is successful, and the baud rate self-adaptive matching is exited.
6. The CAN device communication method of claim 5, wherein, after the step of detecting whether the baud rate of the encoded local CAN data stream is consistent during the standard frame baud rate check, the extended frame baud rate check, and the CRC segment baud rate check if the CRC segment baud rate is within the preset baud rate, the CAN device communication method further comprises:
if the baud rate of the coded local CAN data stream is inconsistent in the standard frame baud rate verification process, the extended frame baud rate verification process and the CRC section baud rate verification process, 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 passes through.
7. 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 predetermined communication protocol and baud rate matching each predetermined baud rate in the set of baud rate timers with the local CAN data stream, the CAN device communication method further comprises:
and if the self-adaptive matching between 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 is received by the receiving end.
8. A CAN device communication apparatus, comprising:
the receiving module is used for 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 modem device is powered on and reset;
a sending module, configured to obtain a local CAN data stream through the local CAN transceiver if the receiving end does not receive the opposite-end CAN data stream, and send the local CAN data stream to the processor and the remote opposite-end optical port;
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 preset baud rate is successfully matched with the baud rate of the local CAN data stream in a self-adaptive manner.
9. A CAN optical modem device, the CAN optical modem device comprising: memory, a processor and a CAN device communication program stored on the memory and executable on the processor, the CAN device communication program when executed by the processor implementing the steps of the CAN device communication method according to any one of claims 1 to 7.
10. 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, realizes the steps of the CAN device communication method according to any one of claims 1 to 7.
CN202210385099.6A 2022-04-13 2022-04-13 CAN equipment communication method and device, CAN optical cat equipment and medium Active CN114866367B (en)

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 true CN114866367A (en) 2022-08-05
CN114866367B 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)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117640016A (en) * 2024-01-26 2024-03-01 北京智芯微电子科技有限公司 Baud rate negotiation method, device, computer equipment, chip and storage medium

Citations (29)

* Cited by examiner, † Cited by third party
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
US20070140290A1 (en) * 2005-12-15 2007-06-21 Jean-Francois Poirier Device network interface
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
US20160330044A1 (en) * 2013-12-30 2016-11-10 Schneider Electric It Corporation System and method for automatically selecting baud rate in a can network
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
US20170353246A1 (en) * 2016-06-07 2017-12-07 Ciena Corporation Software programmable flexible and dynamic optical transceivers
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 潍柴动力股份有限公司 Adaptive method and system for 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
US20210294306A1 (en) * 2018-08-06 2021-09-23 Siemens Aktiengesellschaft Adaptive repeater for industrial communication
CN113891183A (en) * 2021-08-26 2022-01-04 宁波三星智能电气有限公司 Bidirectional interactive communication baud rate self-adaption method
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

Patent Citations (29)

* Cited by examiner, † Cited by third party
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
US20070140290A1 (en) * 2005-12-15 2007-06-21 Jean-Francois Poirier Device network interface
CN103777538A (en) * 2012-10-19 2014-05-07 重庆长安汽车股份有限公司 Baud-rate automatic matching method for controller and CAN bus
US20160330044A1 (en) * 2013-12-30 2016-11-10 Schneider Electric It Corporation System and method for automatically selecting baud rate in a can network
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
US20170353246A1 (en) * 2016-06-07 2017-12-07 Ciena Corporation Software programmable flexible and dynamic optical transceivers
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
US20210294306A1 (en) * 2018-08-06 2021-09-23 Siemens Aktiengesellschaft Adaptive repeater for industrial communication
CN109274567A (en) * 2018-09-27 2019-01-25 潍柴动力股份有限公司 Adaptive method and system for 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
CN111913905A (en) * 2020-06-30 2020-11-10 中国航发南方工业有限公司 Variable self-adaptive serial port communication method, medium and electronic equipment
CN111796579A (en) * 2020-06-30 2020-10-20 东风电驱动系统有限公司 CAN bus baud rate configuration method and system for vehicle remote monitoring terminal
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
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 (4)

* Cited by examiner, † Cited by third party
Title
刘洁: ""CAN总线波特率自适应程序设计"", 《智能制造》 *
史小燕;朱建鸿;: "波特率自适应的CAN驱动在嵌入式Linux下的实现", 计算机系统应用, no. 01 *
薛定喵的颚: "\"串口波特率自适应算法(仿真通过)\"", Retrieved from the Internet <URL:https://blog.csdn.net/weixin_43550363/article/details/123568971> *
魏祯毅,杨江: "Modbus通讯参数的一种自动检测方法", 工业控制计算机, no. 07 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117640016A (en) * 2024-01-26 2024-03-01 北京智芯微电子科技有限公司 Baud rate negotiation method, device, computer equipment, chip and storage medium
CN117640016B (en) * 2024-01-26 2024-05-17 北京智芯微电子科技有限公司 Baud rate negotiation method, device, computer equipment, chip and storage medium

Also Published As

Publication number Publication date
CN114866367B (en) 2023-12-05

Similar Documents

Publication Publication Date Title
US20230353474A1 (en) Method for testing a wireless link of a wi-fi node, and circuit performing the method
JP4507005B2 (en) Wireless communication system, wireless communication method and program
RU2010128579A (en) METHOD AND DEVICE FOR SOLVING PROBLEMS OF BLIND NODE IN WIRELESS NETWORKS
CN101964705A (en) Communication device, communication system, communication method, communication program and communication circuit
CN104902583A (en) Infrared transmission WIFI networking method and system
US8879531B2 (en) Mobile router capable of automatically detecting network connection mode and performing network connection setting, and method thereof
JP2014509483A (en) Mechanisms to improve the performance of transmission control protocols in wireless networks
EP3082285B1 (en) Ethernet data rate selection based on cable parameters
CN109495157B (en) Full-duplex high-throughput rate bidirectional ARQ communication system and method based on CCSDS protocol
KR20080017170A (en) Method and apparatus for data transmission using information on communication environment
US10659297B2 (en) Negotiation mode processing method and intelligent network device
CN114866367B (en) CAN equipment communication method and device, CAN optical cat equipment and medium
KR20050078096A (en) Method for frame retransmission and network apparatus employing the method
CN101132217A (en) Method and device for implementing internal information interaction of repeater by using AT command
US20200137203A1 (en) Data transmission method and system, and apparatus
RU2295838C2 (en) Method for transferring packet data
CN101112069B (en) Communication device, communication system, communication method, communication circuit
WO2012155703A1 (en) Link parameter autonegotiation method, terminal and system based on hdlc protocol
CN114826315B (en) Remote transmission method, device, equipment and medium of CAN (controller area network) optical cat equipment
CN113543208B (en) Wireless transmission control method, wireless communication system, and computer storage medium
JP2004537216A (en) Data Rate Negotiation Method Using Mean-Square Error Technique
CN115622835A (en) A sending conversion device and a receiving conversion device
CN106576310B (en) Power consumption in power amplifier in communication equipment is controlled
CN102740415B (en) One is applied to wireless video system, control method and intelligent gateway
CN105472304A (en) Power grid emergency communication video coding and decoding dynamic adaptation method and system thereof

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