CN101552785B - CAN bus communication method based on message mechanism used for massive data transmission - Google Patents

CAN bus communication method based on message mechanism used for massive data transmission Download PDF

Info

Publication number
CN101552785B
CN101552785B CN200910098417A CN200910098417A CN101552785B CN 101552785 B CN101552785 B CN 101552785B CN 200910098417 A CN200910098417 A CN 200910098417A CN 200910098417 A CN200910098417 A CN 200910098417A CN 101552785 B CN101552785 B CN 101552785B
Authority
CN
China
Prior art keywords
message
data
feedback
mass data
data transfers
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.)
Expired - Fee Related
Application number
CN200910098417A
Other languages
Chinese (zh)
Other versions
CN101552785A (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.)
Zhejiang University ZJU
Original Assignee
Zhejiang University ZJU
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 Zhejiang University ZJU filed Critical Zhejiang University ZJU
Priority to CN200910098417A priority Critical patent/CN101552785B/en
Publication of CN101552785A publication Critical patent/CN101552785A/en
Application granted granted Critical
Publication of CN101552785B publication Critical patent/CN101552785B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a CAN bus communication protocol based on message mechanism used for massive data transmission, which is characterized in that: the equipments are connected in master slaver mode, and the data transmission is realized by non-connection mode; the message mechanism is adopted in the data transmission, and one message can send data of 65536 bytes; when the sent data contains more than 65536 bytes, packing mode is adopted to realize the transmission of massive data of maximal 4G. The invention aims at the application and demand of small-sized system, develops upper layer protocol, realizes the massive data transmission of maximal 4G, guarantees the high efficiency and accuracy of data transmission by utilizing message mechanism and massive data transmission mechanism; and the because has a simple structure, has the advantages of less resource occupation and high efficiency.

Description

The CAN bus communication that is used for mass data transfers based on message mechanism
Technical field
The present invention relates to the embedded real time system of computer realm, in particular, relate to a kind of communication protocol that is applied to mass data based on the CAN bus that connects.
Background technology
Along with the development of Control Technique of Microcomputer and industrial field bus technology, Fieldbus Based communication mode is able to application more and more widely in Industry Control.Wherein the CAN bus is simple in structure with it, and is with low cost, good functional characteristics and high reliability, and on-the-spot antijamming capability reaches open characteristics by force and receives numerous developers' favor.
The CAN universal serial bus has the advantage that transmission range is long, transmission speed is fast, and it has perfect error detection mechanism, adopts frame transmission means of " multiple access conflict arbitration " mechanism, can guarantee not drop-out; Can transmit 8 byte datas in each frame at most, very high real-time or the like can be provided.Advantage on the performance has guaranteed that CAN can be applied in a lot of fields, can see the application of CAN at auto industry, ship, mechanical control, factory automation, building automatic etc.
The CAN field bus system is made up of for 3 layers physical layer, data link layer and application layer.The basic agreement standard of CAN has only PHY and data link layer protocol, is exactly the application layer protocol of designs C AN bus and utilize the CAN bus as one of core missions of the system of transmission mechanism.Current Business agreement based on the CAN bus mainly contains DeviceNet and two kinds of agreements of CANopen, and these two kinds of bus protocols are universal agreements, and multiple functional, complex structure, very flexible, efficiency of transmission are lower, and occupying system resources is more.And current embedded system often function singleness, simple in structure, resource-constrained, but require that transmission speed is fast, reliability is high with efficient, so a kind of new application layer protocol simple in structure of needs.A kind of communication protocol that is applied to mass data based on the CAN bus that connects of having been accomplished by people such as the Wu of Zhejiang University morning sunlight has at present realized the application layer protocol based on connection that data are sent greater than the message of 8 bytes.Though this agreement has realized the packing greater than 8 byte datas is sent, and lacks the response mechanism of transmission, therefore can not handle the situation of loading error occurring.Particularly this agreement can only realize maximum 256*7 byte data transmission, does not have mass data transfers mechanism, and can not guarantee the accuracy of transfer of data.This agreement is based on connection simultaneously, and each transmission need connect earlier, so efficiency of transmission is lower.
Summary of the invention
Main purpose of the present invention is to overcome deficiency of the prior art, and a kind of CAN bus communication protocol based on message mechanism that is applicable to mass data transfers is provided.
In order to solve the problems of the technologies described above, the present invention realizes through following technical scheme:
The CAN bus communication that is used for mass data transfers based on message mechanism is characterized in that: CAN controller 11 bit identifiers of define equipment, and adopt master-slave mode to connect between the equipment, data realize transmission with connectionless-mode; Transfer of data adopts message mechanism, and a piece of news can send 65536 byte datas at most; When sending greater than 65536 byte datas, adopt packing manner, realize maximum 4G mass data transfers.
As a kind of improvement; The frame number of described multiframe data from 0 to 255 sign; Sequence number distributes since 1, and cycle assignment independent packet to the last that goes down continuously, and packet also should begin order from first independent packet and sends separately.
As a kind of improvement, the multiframe data are except that first frame, and every frame data must comprise a sequence number and 7 byte datas.And first frame comprises data length information.
As a kind of improvement, during mass data transfers, packet header from 0 to 65535 sign since 0 distribution, and distribute the bag to the last that goes down continuously, and single bag also begins the order transmission from first packet.
As a kind of improvement, described communication protocol comprises: principal and subordinate's connection management, transmission of messages management and mass data transfers management.
As a kind of improvement, described principal and subordinate's connection management comprises: main equipment initialization and slave unit initialization.
As a kind of improvement, described principal and subordinate's connection management implementation procedure is following: whole system can only have a main equipment, and 14 slave units can be arranged at most.Principal and subordinate's connection management comprises main equipment initialization and slave unit initialization, the initialization slave unit tabulation of main equipment initialization elder generation, and then initial message formation and broadcast registration message are waited for the slave unit response.The slave unit initialization begins from the initial message formation, then responds main equipment broadcasting, gets into message circulation and handles.All transmission are initiated by main equipment.
As a kind of improvement, every message of described message mechanism can be the single frames data, also can be the multiframe data.
As a kind of improvement, described transmission of messages management comprises: message transmission, wait-for-response and message sink.
As a kind of improvement, described transmission of messages management implementation procedure is following: according to different functions code in the message message is packaged into multiframe and sends, receiving terminal is same to unpack message according to different functions code in the message that receives.After every message has been sent; Wait for recipient's feedback message (if send be feedback message then no longer wait to be feedback); Whether acknowledge message is by correct reception; Be the recipient after receiving entire message, all can send a feedback message (if the message that receives be feedback message not to this message feedback), notice transmit leg content is by correct reception.If transmit leg waits for that 1s does not receive feedback message or feedback message mistake, then resend this frame and wait for 1s once more.If be retransmitted to three times, then be judged to be fault, stop to send and pointing out and make mistakes.Otherwise continue to send a piece of news down.So just guaranteed every correctness that message is sent.
As a kind of improvement, described mass data transfers management comprises: packing data, data transmission, Data Receiving and data unpack.
As a kind of improvement; Described mass data transfers management implementation procedure is following: for the data greater than 65536 bytes; Transmitting terminal is broken down into the multiple messages that is 65536 bytes to the maximum and sends; Packet header of definition in every message, and receiving terminal unpacks the multiple messages that receives according to this packet header again.After receiving terminal is received a bag, carry out message response, reception makes mistakes if transmitting terminal is received receiving terminal prompting bag, then retransmits a bag.Packet header is made up of two byte datas, and the bag sequence number is up to 65535 since 0 distribution.
Compared with prior art, the invention has the beneficial effects as follows:
The present invention be directed to mini-system and use and demand, the upper-layer protocol of exploitation has been realized maximum 4GB mass data transfers.Utilize message mechanism and mass data transfers mechanism, ensured the high efficiency and the accuracy of transfer of data.Because protocol architecture is simple, it is few to have the resource of taking, the characteristics that efficient is high.
Description of drawings
Fig. 1 is a system construction drawing of the present invention.
Fig. 2 is the flow chart of transmission of messages of the present invention.
Fig. 3 is the flow chart of mass data transfers of the present invention.
Embodiment
In conjunction with accompanying drawing, through specific embodiment the present invention is elaborated below.
MicroCAN adopts principal and subordinate's connected mode of server/client mode.The CAN bus is a kind of multi-master bus, and each node can send message to other nodes on the bus.And in mini-system is used, by the transmission of messages and the state of each node of main frame control, and the real-time that guarantees message response, therefore adopt master slave mode can guarantee stability of data transmission and accuracy.
The CAN controller is judged priority, condition of acceptance, function etc. through identifier, so identifier is the core of CAN host-host protocol, the MicroCAN agreement is distributed 11 bit identifiers, and is as shown in table 1.
Table 1
Occupy-place number (high) to low 10 9~6 5~2 1~0
Implication 1 From node address Function code Subfunction
In the identifier agreement that MicroCAN distributes, 9~6bit representes node address, and host address is 0x0; Slave addresses can be 0x1~0xE; 0xF representes broadcast frame, and 5~2bit and 1~0bit be presentation function code and subfunction respectively, and content is distributed as shown in table 2.
Table 2
Figure G2009100984175D00041
Figure G2009100984175D00051
MicroCAN message mechanism standard Data Transport Protocol between the master-slave equipment, transfer of data is to be the unit with message between the master-slave equipment, process such as transmission course comprises transmission, receives, replys, repeating transmission.Every message can be the single frames data, also can be the multiframe data, and maximum can be sent 65536 byte datas.
The definition message structure is following:
typedef?struct_MCAN_MESSAGE_STRUCT{
BOOL bServerSend; The message that // sign main frame sends or receives
BYTE byAddress; // node address
MCANMajorFunction CommType; // the function of tonic chord is described
MCANDeviceType HostDeviceType; // main equipment type
MCANDeviceType ClientDeviceType; // slave unit type
BYTE byCommParam; // functional description
MCANMessageState MessageState; // message status
WORD wDataLen; // data length
BYTE*pData; // data
_ MCAN_MESSAGE_STRUCT*pNextMessage; // following a piece of news
}MCANMessage;
According to different functions code in the message message is packaged into multiframe and sends, receiving terminal is same to unpack message according to different functions code in the message that receives.
After every message has been sent; Wait for recipient's feedback message (if send be feedback message then no longer wait to be feedback); Whether acknowledge message is by correct reception; Be the recipient after receiving entire message, all can send a feedback message (if the message that receives be feedback message not to this message feedback), notice transmit leg content is by correct reception.If transmit leg waits for that 1s does not receive feedback message or feedback message mistake, then resend this frame and wait for 1s once more.If be retransmitted to three times, then be judged as fault, stop to send and pointing out and make mistakes.Otherwise continue to send a piece of news down.So just guaranteed every correctness that message is sent.As long as the content of sending is as required filled message structure; Transmit leg will be packed to sending message according to agreement automatically; And the recipient equally also will unpack according to agreement butt joint collection of letters breath, so message mechanism can guarantee the correctness that message is sent and received.
Can ensure that based on MicroCAN message mechanism host-host protocol is not more than 65536 byte data transmission of messages successes, but, then can't realize for the big bag transfer of data more than the 65K.In view of the defective of this agreement in the existence of big data quantity transmission course, need expand, make it satisfy the big data quantity transmission requirements.
The MicroCAN protocol specification big data quantity host-host protocol, comprise to big data decompose, repack, send, receive, unpack, step such as data splitting.
Whether once be the detection of greatly wrapping data, if unpack data splitting after receiving for all bags such as big Bao Ze if doing earlier when the recipient receives data at every turn.Packet header is made up of two byte datas, and 0x0000 representes initial bag, and maximum is 0xFFFF, because every message can be sent the data of 65535 bytes at most, therefore a data transfer heap(ed) capacity can reach 4G.
The distributed system that constitutes based on the CAN bus is except that having higher real-time, and multiple error detection mechanism has guaranteed the reliability and the anti-interference of communication in its agreement, is fit to very much in the boats and ships cabin narrow and small application scenarios, space such as communication.The MicroCAN agreement is utilized message mechanism and big data quantity transmission mechanism under the prerequisite that guarantees higher reliability and stability, it is few to have the resource of taking, and the characteristics that efficiency of transmission is high particularly have good practicability in the built-in small system.
What should be understood that is: the foregoing description is just to explanation of the present invention, rather than limitation of the present invention, and any innovation and creation that do not exceed in the connotation scope of the present invention all fall within protection scope of the present invention.

Claims (7)

1. based on the CAN bus communication that is used for mass data transfers of message mechanism, it is characterized in that: CAN controller 11 bit identifiers of define equipment, adopt master-slave mode to connect between the equipment, data realize transmission with connectionless-mode; Transfer of data adopts message mechanism, and a piece of news sends 65536 byte datas at most; When sending greater than 65536 byte datas, adopt packing manner, realize maximum 4G mass data transfers; Wherein, described message mechanism according to different functions code in the message message is packaged into single frames or multiframe is sent, and receiving terminal is same to unpack message according to different functions code in the message that receives; Described multiframe data comprise a frame number, 65536 byte datas of maximum transmission; Multiframe Frame sequence number from 0 to 255 sign, sequence number distribute since 1, and cycle assignment independent packet to the last that goes down continuously, and packet also should begin order from first independent packet and sends separately; The multiframe data are except that first frame, and every frame data must comprise a sequence number and 7 byte datas, and first frame comprises data length information; Less than the 4GB data volume, transmitting terminal becomes multiple messages to send data decomposition greater than 65536 bytes in described mass data transfers realization, packet header of definition in every message, and receiving terminal unpacks the multiple messages that receives according to this packet header again; The packet header of message is made up of two bytes in the described mass data transfers, and the bag sequence number is up to 65535 since 0 distribution; After described mass data transfers receiving terminal is received every bag, carry out message feedback one time,, then put in order bag and retransmit if transmitting terminal receives that the receiving terminal prompting receives one and contracts out mistake.
2. the CAN bus communication that is used for mass data transfers based on message mechanism according to claim 1 is characterized in that described principal and subordinate's connected mode can only have a main equipment, and 14 slave units are arranged at most; All transmission are initiated by main equipment, and main equipment is through each slave unit state of broadcast mode inquiry.
3. the CAN bus communication that is used for mass data transfers based on message mechanism according to claim 2 is characterized in that described broadcast mode sends message by main equipment, and each slave unit is realized the connection of master-slave equipment through the response broadcast.
4. the CAN bus communication that is used for mass data transfers based on message mechanism according to claim 1; It is characterized in that; Described transfer of data realizes with connectionless-mode; All data send to same bus, and each equipment judges whether to be received in the data on the bus through the frame identification code.
5. the CAN bus communication that is used for mass data transfers based on message mechanism according to claim 1; It is characterized in that; Described message mechanism comprises packing data, transmission, receives, unpacks, replys and retransmission process, and all message are all initiated by main equipment.
6. the CAN bus communication that is used for mass data transfers based on message mechanism according to claim 5 is characterized in that every message of described message mechanism is the single frames data, or the multiframe data.
7. the CAN bus communication that is used for mass data transfers based on message mechanism according to claim 5; It is characterized in that described message mechanism is waited for recipient's feedback message after every message has been sent; If that sends is feedback message then no longer waits to be feedback; Whether acknowledge message is by correct reception, and promptly the recipient can send a feedback message after receiving entire message; If the message that receives is feedback message then not to this message feedback, notifies the transmit leg content by correct reception; If transmit leg waits for that 1s does not receive feedback message or feedback message mistake, then resend this frame and wait for 1s once more; If be retransmitted to three times, then be judged to be fault, stop to send and pointing out and make mistakes; Otherwise continue to send a piece of news down.
CN200910098417A 2009-05-07 2009-05-07 CAN bus communication method based on message mechanism used for massive data transmission Expired - Fee Related CN101552785B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910098417A CN101552785B (en) 2009-05-07 2009-05-07 CAN bus communication method based on message mechanism used for massive data transmission

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910098417A CN101552785B (en) 2009-05-07 2009-05-07 CAN bus communication method based on message mechanism used for massive data transmission

Publications (2)

Publication Number Publication Date
CN101552785A CN101552785A (en) 2009-10-07
CN101552785B true CN101552785B (en) 2012-10-10

Family

ID=41156776

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910098417A Expired - Fee Related CN101552785B (en) 2009-05-07 2009-05-07 CAN bus communication method based on message mechanism used for massive data transmission

Country Status (1)

Country Link
CN (1) CN101552785B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE102011015966B4 (en) * 2011-04-04 2017-07-06 Wago Verwaltungsgesellschaft Mbh automation system
AU2012277904B2 (en) * 2011-06-29 2017-06-29 Robert Bosch Gmbh Method and device for serial data transmission having a flexible message size and a variable bit length
CN104486145B (en) * 2014-12-03 2017-09-08 中国航空工业集团公司第六三一研究所 A kind of method of testing of onboard networks data sequence integrality
CN106292403A (en) * 2015-06-01 2017-01-04 南京普爱医疗设备股份有限公司 A kind of CAN communication agreement of controlling system of medical equipments
CN105634894B (en) * 2015-12-31 2019-08-13 深圳市科陆智慧工业有限公司 A kind of enhanced CAN bus data re-transmitting method and device
CN106788916B (en) * 2016-12-30 2021-08-27 深圳市优必选科技股份有限公司 Data transmission method and data transmission device for bus
CN106712907B (en) * 2017-02-16 2019-08-20 北京中航通用科技有限公司 Data transmission method and equipment
CN110077279B (en) * 2019-05-08 2020-12-01 威马智慧出行科技(上海)有限公司 CAN bus data transmission method
CN111638687B (en) * 2020-05-12 2022-01-21 牧星机器人(江苏)有限公司 AGV communication method based on simplified communication protocol
CN114143136A (en) * 2021-11-19 2022-03-04 山东新一代信息产业技术研究院有限公司 IROS-based CAN (controller area network) large message communication method, equipment and storage medium
CN114697155B (en) * 2022-03-10 2023-11-24 北京精雕科技集团有限公司 Multi-device data interaction method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001020434A2 (en) * 1999-09-15 2001-03-22 Koninklijke Philips Electronics N.V. A method for conserving power in a can microcontroller and a can microcontroller that implements this method
CN1491008A (en) * 2003-08-28 2004-04-21 东南大学 Embedded gate for realizing interconnection between networks with different structures
CN1615611A (en) * 2002-01-11 2005-05-11 摩托罗拉公司 Dynamic can bus system configuration and messaging

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001020434A2 (en) * 1999-09-15 2001-03-22 Koninklijke Philips Electronics N.V. A method for conserving power in a can microcontroller and a can microcontroller that implements this method
CN1615611A (en) * 2002-01-11 2005-05-11 摩托罗拉公司 Dynamic can bus system configuration and messaging
CN1491008A (en) * 2003-08-28 2004-04-21 东南大学 Embedded gate for realizing interconnection between networks with different structures

Also Published As

Publication number Publication date
CN101552785A (en) 2009-10-07

Similar Documents

Publication Publication Date Title
CN101552785B (en) CAN bus communication method based on message mechanism used for massive data transmission
CN102577268B (en) Apparatus and method for transmitting a MAC PDU based on MAC header type information
US6438128B1 (en) Alternate use of data packet fields to convey information
CN105024861B (en) A kind of reliable remote communication means and its communicator based on big-dipper satellite
CN102833332B (en) A kind of distributed multi-to-multi devices communicating and management method
CN102624738B (en) Serial port server, protocol conversion chip and data transmission method
JP2005027289A5 (en)
CN103248467A (en) In-chip connection management-based RDMA communication method
CN101488941A (en) Method and system for implementing USB equipment shared using
CN106603506B (en) Data communication method, device and system based on multi-field bus
US20120099579A1 (en) Zigbee gateway and ip service server interworking with zigbee gateway through ip network
US10609125B2 (en) Method and system for transmitting communication data
CN111092854B (en) Method for transmitting packets transmitted from a source device to a destination device
Moons et al. Using SCHC for an optimized protocol stack in multimodal LPWAN solutions
CN104980257A (en) Internet of things communication method and device
CN105337895A (en) Network equipment host unit, network equipment daughter card and network equipment
CN101309169A (en) Network management method and network management system, network apparatus
CN106657377B (en) A kind of WIA-PA/ interconnects manufacture network information service adapter and implementation method entirely
CN101753486B (en) Industrial automation field bus gateway equipment
US20050141555A1 (en) Method for generating commands for network controller modules of peripheral devices
CN106506306A (en) A kind of method and apparatus of data-message transmission
US9762353B2 (en) Data packet for bidirectional transmission of data packets during data transmission between a first and a second communication appliance, and method for transmitting such a data packet
CN103825831A (en) Packet transmitting method and switch
CN116266800A (en) Multicast transmission method, device and system
US9661110B2 (en) System and method for enabling channel access enhancements in existing communication networks

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20121010

Termination date: 20140507