CN105389278B - A kind of slave serial communication method based on CAN bus - Google Patents

A kind of slave serial communication method based on CAN bus Download PDF

Info

Publication number
CN105389278B
CN105389278B CN201510670674.7A CN201510670674A CN105389278B CN 105389278 B CN105389278 B CN 105389278B CN 201510670674 A CN201510670674 A CN 201510670674A CN 105389278 B CN105389278 B CN 105389278B
Authority
CN
China
Prior art keywords
node
bus address
subordinate computer
host
computer node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510670674.7A
Other languages
Chinese (zh)
Other versions
CN105389278A (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.)
Guangdong Kedi Intelligent Engineering Co., Ltd
Original Assignee
Guangdong Tri-Sun Electronics Technology 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 Guangdong Tri-Sun Electronics Technology Co Ltd filed Critical Guangdong Tri-Sun Electronics Technology Co Ltd
Priority to CN201510670674.7A priority Critical patent/CN105389278B/en
Publication of CN105389278A publication Critical patent/CN105389278A/en
Application granted granted Critical
Publication of CN105389278B publication Critical patent/CN105389278B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/14Handling requests for interconnection or transfer
    • G06F13/36Handling requests for interconnection or transfer for access to common bus or bus system
    • G06F13/362Handling requests for interconnection or transfer for access to common bus or bus system with centralised access control

Abstract

The invention discloses a kind of slave serial communication method of CAN bus, including:Host node accesses CAN bus, and host bus address and slave bus address pond are configured in host node;Host node monitors CAN bus, obtains the broadcast message that at least one subordinate computer node is sent;Destination host bus address and slave bus address is configured for the subordinate computer node in subordinate computer node physical address and network connection state of the host node in the broadcast message;The host node carries out point-to-point communication according to the slave bus address and network connection state with the subordinate computer node.The problem of a kind of slave serial communication method of CAN bus of the present invention by realizing the serial communication between host node and subordinate computer node, is solved in existing CAN bus communication mode, the data congestion for needing mass data node and thus bringing.

Description

A kind of slave serial communication method based on CAN bus
Technical field
The present invention relates to CAN bus technical field more particularly to a kind of slave serial communication sides based on CAN bus Method.
Background technology
CAN (Controller Area Network, controller local area network) is most widely used in the world at present One of fieldbus.Phase controller local area network CAN is applied to the fieldbus of automotive interior in the early stage.With science skill The continuous development of art, controller local area network CAN are also gradually applied to Medical Devices, industrial production, building facility, communications and transportation In the fields of grade.
At present, mostly led in existing communication technology using RS232 serial communications, RS485 serial communications and general CAN bus Letter.But there are a degree of deficiencies for above-mentioned communication mode.RS232 serial communications first only allow point-to-point communication, and away from From limited;Message transmission rate is low and easy generate is interfered, and the chip of interface circuit is due to the high level of interface signal in addition Easily damage.Secondly, RS485 serial communications configuration is relatively complicated, takes longer;General CAN bus data communication node There is no master-slave, arbitrary node can initiate data communication to any other node, it is therefore desirable to each information node processing Mass data, and thereby resulted in that bus node number is more, and then will appear the situation of data congestion.
Invention content
The present invention is completed to solve of the prior art above-mentioned insufficient, and it is an object of the invention to propose one kind The serial communication method of slave based on CAN bus, this method solve existing communication mode, especially general CAN bus Communicate the problem of bus node number occurred in use is more, and data cause congestion.
For this purpose, the present invention uses following technical scheme:
A kind of slave serial communication method of CAN bus, including:
Host node accesses CAN bus, and host bus address and slave bus address pond are configured in host node;
Host node monitors CAN bus, obtains the broadcast message that at least one subordinate computer node is sent;
Subordinate computer node physical address and network connection state of the host node in the broadcast message, are described Destination host bus address and slave bus address is configured in subordinate computer node;
The host node carries out a little pair according to the slave bus address and network connection state and the subordinate computer node Point communication.
A kind of slave serial communication method of CAN bus of the present invention is accessed by host node and monitors CAN Bus obtains the broadcast message that subordinate computer node is sent, and destination host bus and slave bus address, final basis is configured with this Slave bus address realizes the point-to-point communication with subordinate computer node with network connection state.The communication protocols of CAN are utilized in this method The address of slave is configured by host for view, realizes point-to-point communication, solves in existing CAN bus communication mode, needs a large amount of The problem of back end and the data congestion thus brought.
Description of the drawings
In order to clearly illustrate the technical solution of exemplary embodiment of the present, below to required in description embodiment The attached drawing to be used does a simple introduction.Obviously, the attached drawing introduced is the part of the embodiment of the invention to be described The attached drawing of attached drawing rather than whole, for those of ordinary skill in the art, without creative efforts, may be used also To obtain other attached drawings according to these attached drawings.
Fig. 1 is a kind of flow chart of the slave serial communication method for CAN bus that the embodiment of the present invention one provides.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below with reference to attached in the embodiment of the present invention Figure, by specific embodiment, is fully described by technical scheme of the present invention.Obviously, described embodiment is of the invention Part of the embodiment, instead of all the embodiments, based on the embodiment of the present invention, those of ordinary skill in the art are not doing The every other embodiment obtained under the premise of going out creative work, each falls within protection scope of the present invention.
Embodiment one:
Fig. 1 gives a kind of flow chart of the slave serial communication method of CAN bus of the offer of the present embodiment one.
Such as Fig. 1, the slave serial communication method for the CAN bus that the present embodiment one provides, including:
S100, host node access CAN bus, and host bus address and slave bus address are configured in host node Pond.
Wherein, host bus address refers to the bus address of host node.The bus address is formed and is had by 2 bytes Have uniqueness, that is to say, that host node be the multiple nodes of CAN bus in main node, and only there are one.
Slave bus address pond refers to the bus address pond of subordinate computer node.The bus address pond is assignable for subordinate computer node Effective address range.
S200, host node monitor CAN bus, obtain the broadcast message that at least one subordinate computer node is sent.
Subordinate computer node access CAN bus first, can send broadcast message in the form of broadcast later.Wherein, it broadcasts the message Physical address and network connection state including subordinate computer node.
It should be noted that in the case where slave bus address has not been obtained in subordinate computer node, the physical address of subordinate computer node It is the uniquely tagged that it identifies subordinate computer node.Physical address can be MAC Address, be made of 6 bytes.
The subordinate computer node physical address and network connection state of S300, the host node in the broadcast message, Destination host bus address and slave bus address is configured for the subordinate computer node.
Wherein, the process that destination host bus address and slave bus address are configured for the subordinate computer node includes:
The host node obtains subordinate computer node physical address and network connection state from the broadcast message, and to institute Network connection state is stated to be identified.
The content of identification includes:
Whether the host node is configured according to destination host bus address, whether slave bus address is configured and net The sequence whether network connects obtains recognition result.
The result of identification includes following several:
Target bus address is not configured, and slave bus address is not configured, and network is not connected with;
Target bus address is configured, and slave bus address is not configured, and network is not connected with;
Target bus address is configured, and slave bus address is configured, and network is not connected with;
Target bus address is configured, and slave bus address is configured, and network has connected.
The host node generates configuration-direct according to recognition result, and broadcast or unicast are sent to the subordinate computer node, with Indicate that the subordinate computer node is configured and changed network connection state according to the configuration-direct.Subordinate computer node can according to The instruction type for putting instruction determines which kind of configuration should be carried out.
Corresponding configuration-direct is generated according to above-mentioned recognition result, it is final it is expected that subordinate computer node is reached using the configuration-direct It is configured to the destination host node bus address of subordinate computer node and its own bus address, subordinate computer node with host node just The effect of normal point-to-point connection.
In addition, whether the host node is configured according to destination host bus address, whether slave bus address is configured, with And it after the sequence that whether connects of network obtains recognition result, further includes:
The host node records the network connection state of the subordinate computer node to subordinate computer node pipe according to recognition result It manages in list.
Wherein, the purpose that host establishes slave management list is, by controlling the slave to communicate with the host node The quantity of node monitors the CAN bus address of the host node, manages the physical address of subordinate computer node and CAN bus address.
S400, the host node are carried out according to the slave bus address and network connection state with the subordinate computer node Point-to-point communication.
After host node and subordinate computer node can carry out point-to-point communication, the slave bus address and network connection State carries out point-to-point communication with the subordinate computer node and includes:
The host node receives the data that external interface is sent to subordinate computer node;
The host node is according to the network connection status of the subordinate computer node and slave bus address, by the data point The subordinate computer node is sent to point.
Such as:When needing to complete data transmission between subordinate computer node and external device (ED), host can be utilized outside it Data-interface receives the outgoing data in external device (ED), and utilizes its point-to-point communication between subordinate computer node by data transmission To subordinate computer node.
The embodiment of the present invention one proposes a kind of slave serial communication method of CAN bus, is monitored by host node CAN bus obtains the broadcast message that subordinate computer node is sent, and destination host bus and slave bus address is configured with this, finally Point-to-point communication with subordinate computer node is realized, and further realize subordinate computer node by slave bus address and network connection state It with the data transmission of external device (ED), and then overcomes in existing CAN bus communication mode, mass data node is needed to handle number According to, and thus bring data congestion the problem of.
Embodiment two:
The embodiment of the present invention further points out second is that on the basis of embodiment one:The host node is tied according to identification Fruit generates configuration-direct, broadcasts to the subordinate computer node, to indicate that the subordinate computer node is carried out according to the configuration-direct Configuration and change network connection state include:
If recognizing the network connection state not to be configured for destination host bus address, the host node generates The physical address of local host bus address and the subordinate computer node is added to institute by destination host bus address configuration-direct It states in destination host bus address configuration-direct, carries out broadcast transmission.
Host node monitors entire CAN network bus data by subordinate computer node management list, and then obtains subordinate computer node Broadcast message.This, which broadcasts the message, includes the physical address and network connection state of subordinate computer node.Wherein, if listening to network Destination host bus address in connection status is not configured, and host node is by its configured host bus address and slave section The physical address of point is configured to corresponding configuration-direct, and the instruction is sent to CAN bus in the form of broadcasting.
The subordinate computer node of broadcast configuration instruction is received, if recognizing the physical address and local physical address Match, then the host bus address in the destination host bus address configuration-direct is configured to local destination host bus Location, and it is configured that local network connection status is changed to destination host bus address.
Multiple subordinate computer nodes receive configuration-direct by CAN bus, and by the physical address in configuration-direct and slave section The physical address of point is matched.Once successful match then illustrates that this subordinate computer node is corresponding with configuration-direct, then refers to configuration Host bus address in order is configured to the bus address of destination host.Subordinate computer node repaiies its network connection state message simultaneously It is configured to be changed to destination host bus address.
On the basis of destination host bus address is configured, host node generates configuration-direct according to recognition result, extensively It broadcasts and gives the subordinate computer node, to indicate that the subordinate computer node is configured and changed network connection according to the configuration-direct State includes:
If recognizing the network connection state not to be configured for slave bus address, the host node generates slave Bus address configuration-direct extracts slave bus address, the physical address with the subordinate computer node in slave bus address pond It is added to together in the slave bus address configuration-direct, carries out broadcast transmission.
If the slave bus address listened in network connection state is not configured, host node can be total from configured slave Corresponding slave bus address is chosen in line address pool, due to the assignable effective address range of address pool subordinate computer node, Wherein address can arbitrarily be chosen.Later, host node matches the physical address of the slave bus address chosen and subordinate computer node Corresponding configuration-direct is set to, and the instruction is sent to CAN bus in the form of broadcasting.
The subordinate computer node of broadcast configuration instruction is received, if recognizing the physical address and local physical address Match, then the slave bus address in the slave bus address configuration-direct is configured to local slave bus address, and will It is configured that local network connection status is changed to slave bus address.
Multiple subordinate computer nodes receive configuration-direct by CAN bus, and by the physical address in configuration-direct and slave section The physical address of point is matched.Once successful match then illustrates that this subordinate computer node is corresponding with configuration-direct, then refers to configuration Slave bus address in order is configured to local slave bus address.Subordinate computer node is by its network connection state message modification simultaneously It is configured for slave bus address.
Include it should be noted that subordinate computer node is configured and changed network connection state according to the configuration-direct:
If recognizing the network connection state to be not connected with for network, the host node is from the broadcast message The slave bus address of the subordinate computer node, and Configuration network link order are obtained, by the slave bus of the subordinate computer node Location is added in the Configuration network link order, and unicast is sent to the subordinate computer node.
That is, in the initial state, subordinate computer node access CAN bus, and be sent to network connection state Broadcast message, if in the case that network state therein is not connected with and assumes that slave bus address is configured for network, it is main Machine node is included wherein using the slave bus address Configuration network link order in broadcast message, and by slave bus address, Subordinate computer node is issued in the form of unicast.
The subordinate computer node receives the Configuration network link order, and local network connection state has been changed to network Connection.
It may also be noted that subordinate computer node needs that destination host bus address is configured first, after otherwise accessing CAN bus It will be unable to realize and monitor CAN bus.
A kind of slave serial communication method for CAN bus that the embodiment of the present invention two proposes includes the mesh of subordinate computer node Mark three kinds of network connection states that bus address is not configured, slave bus address is not configured and network connection state is not connected with, Corresponding configuration-direct or link order are generated by host node, and then realize the point-to-point of host node and subordinate computer node Communication, overcomes in existing CAN bus communication mode, mass data node is needed to be gathered around come the data for handling data and thus bringing The problem of stifled.
The technical principle that above are only presently preferred embodiments of the present invention and used.The present invention is not limited to spies described here Determine embodiment, the various significant changes that can carry out for a person skilled in the art, readjust and substitute all without departing from Protection scope of the present invention.Therefore, although being described in further detail by above example to the present invention, this hair It is bright to be not limited only to above example, without departing from the inventive concept, other more equivalence enforcements can also be included Example, and the scope of the present invention is determined by the scope of the claims.

Claims (5)

1. a kind of slave serial communication method of CAN bus, which is characterized in that including:
Host node accesses CAN bus, and host bus address and slave bus address pond are configured in host node;
Host node monitors CAN bus, obtains the broadcast message that at least one subordinate computer node is sent;
The host node obtains subordinate computer node physical address and network connection state from the broadcast message, and to the net Network connection status is identified;
Whether the host node is configured according to destination host bus address, whether slave bus address is configured and network is The sequence of no connection obtains recognition result;
The host node generates configuration-direct according to recognition result, and broadcast or unicast are sent to the subordinate computer node, with instruction The subordinate computer node is configured and is changed network connection state according to the configuration-direct, including:If recognize the net Network connection status is not configured for destination host bus address, then the host node generates the configuration of destination host bus address and refers to It enables, the physical address of local host bus address and the subordinate computer node is added to the destination host bus address is configured In instruction, broadcast transmission is carried out;The subordinate computer node of the destination host bus address configuration-direct of broadcast is received, if known The physical address is clipped to match with local physical address, then it is the host in the destination host bus address configuration-direct is total Line address configuration is local destination host bus address, and local network connection status is changed to destination host bus address It is configured;
The host node carries out point-to-point logical according to the slave bus address and network connection state with the subordinate computer node Letter.
2. according to the method described in claim 1, it is characterized in that, the host node refers to according to recognition result generation configuration It enables, the subordinate computer node is broadcast to, to indicate that the subordinate computer node is configured and changed net according to the configuration-direct Network connection status includes:
If recognizing the network connection state not to be configured for slave bus address, the host node generates slave bus Address configuration instructs, and slave bus address is extracted in slave bus address pond, together with the physical address of the subordinate computer node It is added in the slave bus address configuration-direct, carries out broadcast transmission;
The subordinate computer node of the slave bus address configuration-direct of broadcast is received, if recognizing the physical address and this Physical addresses match, then it is total the slave bus address in the slave bus address configuration-direct to be configured to local slave Line address, and it is configured that local network connection status is changed to slave bus address.
3. according to the method described in claim 1, it is characterized in that, the host node refers to according to recognition result generation configuration It enables, unicast is sent to the subordinate computer node, to indicate that the subordinate computer node is configured and changed net according to the configuration-direct Network connection status includes:
If recognizing the network connection state to be not connected with for network, the host node is obtained from the broadcast message The slave bus address of the subordinate computer node, and Configuration network link order add the slave bus address of the subordinate computer node It adds in the network connection instruction, unicast is sent to the subordinate computer node;
The subordinate computer node receives the network connection instruction, and local network connection state is changed to network and has been connected.
4. according to the method described in claim 1, it is characterized in that, the host node according to destination host bus address whether After configuration, the sequence that whether slave bus address is configured and whether network connects obtain recognition result, further include:
The network connection state of the subordinate computer node according to recognition result is recorded to subordinate computer node management and arranged by the host node In table.
5. according to the method described in claim 1, it is characterized in that, the host node is according to the slave bus address and net Network connection status carries out point-to-point communication with the subordinate computer node and includes:
The host node receives the data that external interface is sent to subordinate computer node;
The host node is point-to-point by the data according to the network connection status of the subordinate computer node and slave bus address It is sent to the subordinate computer node.
CN201510670674.7A 2015-10-13 2015-10-13 A kind of slave serial communication method based on CAN bus Active CN105389278B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510670674.7A CN105389278B (en) 2015-10-13 2015-10-13 A kind of slave serial communication method based on CAN bus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510670674.7A CN105389278B (en) 2015-10-13 2015-10-13 A kind of slave serial communication method based on CAN bus

Publications (2)

Publication Number Publication Date
CN105389278A CN105389278A (en) 2016-03-09
CN105389278B true CN105389278B (en) 2018-06-12

Family

ID=55421579

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510670674.7A Active CN105389278B (en) 2015-10-13 2015-10-13 A kind of slave serial communication method based on CAN bus

Country Status (1)

Country Link
CN (1) CN105389278B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107786403A (en) * 2016-08-31 2018-03-09 常州太平通讯科技有限公司 For burst between more slave devices and the Communication processing method of concurrent transmission
CN106802832B (en) * 2017-01-06 2020-04-17 网易(杭州)网络有限公司 Jenkins node state management method and device
CN109799737A (en) * 2017-11-16 2019-05-24 长沙闽壹湖电子科技有限责任公司 A kind of CAN bus based slave Communication System Design
CN111597123B (en) * 2020-04-08 2023-05-02 广东开利暖通空调股份有限公司 Automatic address allocation method, automatic address allocation device, computer equipment and storage medium
CN112579490A (en) * 2020-12-21 2021-03-30 太原智林信息技术股份有限公司 Programmable electronic building block connecting bus
CN113395198B (en) * 2021-06-16 2022-12-27 广州极飞科技股份有限公司 Networking method and device of equipment and data transmission system
CN114265352A (en) * 2021-12-22 2022-04-01 深圳埃瑞斯瓦特新能源有限公司 Automatic configuration system and method for CAN bus ID

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1677945A (en) * 2004-03-31 2005-10-05 联想(北京)有限公司 Master-slave mode multi-address communication method
CN101763333A (en) * 2008-12-08 2010-06-30 北京谊安医疗系统股份有限公司 Bus controller and method for realizing multi-host communication
CN101852472A (en) * 2009-04-01 2010-10-06 欧威尔空调(中国)有限公司 Automatic addressing method for air conditioning system and air conditioning controller

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102023945B (en) * 2009-09-22 2012-03-28 鸿富锦精密工业(深圳)有限公司 Serial peripheral interface bus-based equipment and data transmission method thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1677945A (en) * 2004-03-31 2005-10-05 联想(北京)有限公司 Master-slave mode multi-address communication method
CN101763333A (en) * 2008-12-08 2010-06-30 北京谊安医疗系统股份有限公司 Bus controller and method for realizing multi-host communication
CN101852472A (en) * 2009-04-01 2010-10-06 欧威尔空调(中国)有限公司 Automatic addressing method for air conditioning system and air conditioning controller

Also Published As

Publication number Publication date
CN105389278A (en) 2016-03-09

Similar Documents

Publication Publication Date Title
CN105389278B (en) A kind of slave serial communication method based on CAN bus
CN103248526B (en) Realize signal equipment, the method for out-of-band supervision control management
CN105577420B (en) Automatically generate the method and system of servomechanism network topology
CN104901858A (en) System communication method based on CAN bus
CN105323330B (en) Using the Internet protocol addressing of the industrial control device of network ring topology
CN106100955B (en) Industrial internet field layer broadband bus data depth detection implementation method
CN104937896A (en) Method for processing address resolution protocol message, forwarder and controller
CN106982222A (en) The multi-protocol data cut-in method and device that can configure under a kind of industrial 4.0 environment
CN105577500A (en) Association method of VXLAN and tunnel and apparatus thereof
CN101631148A (en) Communication method for allocating dynamic addresses in serial communication protocols
CN107124481B (en) A kind of configuration method, system and the equipment of KNX group address
CN105049312A (en) Industrial control ring network system and networking method thereof
CN107205059A (en) Manage method, acquisition terminal and the meter equipment of meter device address
CN109032704A (en) A kind of method and apparatus of data processing
CN109947689A (en) A kind of method of automobile-used lithium ion battery case automatic numbering
CN112235325B (en) Method and system for performing access control on functional module connected with intelligent terminal
CN104699649A (en) Multi-branch serial bus interface and data exchange method
CN105681229A (en) Method for extending port serial numbers and switch
CN104780120A (en) Method and device for transmitting files in local area network
CN105897936B (en) The processing method of control configuration information based on industry internet, apparatus and system
CN109753012A (en) A kind of processing machine long-range control method, apparatus and system based on cloud platform
CN104853447A (en) Method and device for processing data information
CN209962605U (en) LED display screen and display system
CN105656814B (en) A kind of SDN network repeater system and method
CN104104594B (en) VSU protocol massages are sent and method of reseptance, equipment and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20210521

Address after: 523000 room 805, unit 2, building 1, No.2, headquarters 2nd Road, Songshanhu Park, Dongguan City, Guangdong Province

Patentee after: Guangdong Kedi Intelligent Engineering Co., Ltd

Address before: 523000 Building 1, Caiyi Plaza, Dongcheng Science Park, Dongcheng District, Dongguan City, Guangdong Province

Patentee before: GUANGDONG TRI-SUN ELECTRONICS TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right