CN105306323A - Method and device for CAN bus communication - Google Patents

Method and device for CAN bus communication Download PDF

Info

Publication number
CN105306323A
CN105306323A CN201510606609.8A CN201510606609A CN105306323A CN 105306323 A CN105306323 A CN 105306323A CN 201510606609 A CN201510606609 A CN 201510606609A CN 105306323 A CN105306323 A CN 105306323A
Authority
CN
China
Prior art keywords
chip
uart
data
bus
frame
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.)
Pending
Application number
CN201510606609.8A
Other languages
Chinese (zh)
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.)
Shandong Chaoyue Numerical Control Electronics Co Ltd
Original Assignee
Shandong Chaoyue Numerical Control Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Chaoyue Numerical Control Electronics Co Ltd filed Critical Shandong Chaoyue Numerical Control Electronics Co Ltd
Priority to CN201510606609.8A priority Critical patent/CN105306323A/en
Publication of CN105306323A publication Critical patent/CN105306323A/en
Pending legal-status Critical Current

Links

Abstract

The invention provides a method and device for CAN bus communication. The method comprises the following steps: mounting a first chip used for switchover between a USB and a UART bus on the USB of a host, wherein the host is configured with a second chip used for switchover between the UART bus and a CAN bus; sending data to be transmitted to the first chip through the USB; converting the data to be transmitted into UART bus data through the first chip and sending the UART bus data to the second chip through the UART bus; and converting the UART bus data into CAN protocol frames through the second chip and transmitting the CAN protocol frames through the CAN bus. The invention provides a method and device for CAN bus communication, by which CAN bus communication can be realized more easily.

Description

A kind of method of CAN communication and device
Technical field
The present invention relates to field of computer technology, particularly a kind of method that communicates of CAN and device.
Background technology
CAN (ControllerAreaNetwork, controller local area network) serial communication that bus effectively can be supported distributed AC servo system as fieldbus or control in real time, be now widely used in the aspects such as industrial automation, automobile, boats and ships, Medical Devices, industrial equipment.Compared with general communication bus, the data communication of CAN has stronger reliability, real-time and flexibility.
But, in some system, do not support the data communication of CAN.For example, acceptance of the bid kylin has also been widely used in government and military enterprise as domestic operating system, the transmission being realized data under domestic operating system by CAN not only needs to buy the equipment that expensive USB turns CAN with monitoring, but also needs self-developing device drives.Visible by foregoing description, in prior art, for the system not supporting CAN data communication, CAN data communication more complicated to be realized within the system.
Summary of the invention
In view of this, the invention provides method and the device of a kind of CAN communication, can more simply realize CAN communication.
First aspect, the invention provides the method for a kind of CAN communication, comprising:
On the usb bus of main frame, carry is used for the first chip of usb bus and UART general line system, is configured for the second chip that UART bus and CAN are changed, also comprises in described main frame:
S1: data to be transmitted is sent to described first chip by usb bus;
S2: described data to be transmitted is converted to UART bus data by described first chip, sends to described second chip by UART bus by described UART bus data;
S3: described UART bus data is converted to CAN protocol frame by described second chip, is transmitted described CAN protocol frame by described CAN.
Further, before described S1, also comprise:
Identify described first chip, generate described first chip corresponding/dev/ttyUSB0 file, receive the first configuration order, according to described first configuration order, described/dev/ttyUSB0 file is modified, realizes the configuration of the traffic rate to described UART bus, Flow Control mode, data bit, position of rest, check digit.
Further, before described S1, also comprise:
Receiving the second configuration order, according to described second configuration order, opening in CAN for transmitting the CAN passage of data;
In described S3, described described CAN protocol frame to be transmitted by described CAN, comprising:
Described CAN protocol frame is transmitted on the CAN passage opened of CAN.
Further, in described S3, describedly by described second chip, described UART bus data is converted to CAN protocol frame, comprises:
Be a frame by data to be transmitted with 8, add frame identification code, channel recognition code, frame category and form type code, frame ID at frame head place, add the School Affairs to data bit at postamble, generate described CAN protocol frame.
Second aspect, the invention provides the method for a kind of CAN communication, comprising:
On the usb bus of main frame, carry is used for the first chip of usb bus and UART general line system, is configured for the second chip that UART bus and CAN are changed, also comprises in described main frame:
A1: receive the outside CAN protocol frame sent by CAN, and by CAN, described CAN protocol frame is sent to described second chip;
A2: described CAN protocol frame is converted to UART bus data by described second chip, sends to described first chip by UART bus by described UART bus data;
A3: described UART bus data is converted to usb bus data by described first chip, transmits described usb bus data on the usb bus.
Further, before described A1, also comprise:
Identify described first chip, generate described first chip corresponding/dev/ttyUSB0 file, receive the first configuration order, according to described first configuration order, described/dev/ttyUSB0 file is modified, realizes the configuration of the traffic rate to described UART bus, Flow Control mode, data bit, position of rest, check digit.
Further, before described A1, also comprise:
Receiving the second configuration order, according to described second configuration order, opening in CAN for transmitting the CAN passage of data;
Described A1 comprises, and comprising:
By the CAN protocol frame that the described CAN channel reception outside of CAN is sent, and by the CAN passage of CAN, described CAN protocol frame is sent to described second chip.
Further, before described A1, also comprise: the buffering area that UART is set;
Described A1 comprises: the described CAN protocol frame described CAN received adds in the buffering area of described UART, from the buffering area of described UART, obtain described CAN protocol frame, is sent by the CAN protocol frame of acquisition and sends to described second chip by CAN.
Further, in described A2, describedly by described second chip, described CAN protocol frame is converted to UART bus data, comprises:
From described CAN protocol frame, extract data bit, be described UATR bus data by described data bit transition.
The third aspect, the invention provides the device of a kind of CAN communication, comprising:
First dispensing unit, is used for the first chip of usb bus and UART general line system for carry on the usb bus of main frame, be configured for the second chip that UART bus and CAN are changed in described main frame;
First usb bus transmission unit, for sending to described first chip by usb bus by data to be transmitted;
One UART bus transfer unit, for described data to be transmitted being converted to UART bus data by described first chip, sends to described second chip by UART bus by described UART bus data;
First CAN transmission unit, for described UART bus data being converted to CAN protocol frame by described second chip, is transmitted described CAN protocol frame by described CAN.
Fourth aspect, the invention provides the device of a kind of CAN communication, comprising:
Second dispensing unit, is used for the first chip of usb bus and UART general line system for carry on the usb bus of main frame, be configured for the second chip that UART bus and CAN are changed in described main frame;
Second CAN transmission unit, for receiving the outside CAN protocol frame sent by CAN, and sends to described second chip by CAN by described CAN protocol frame;
2nd UART bus transfer unit, for described CAN protocol frame being converted to UART bus data by described second chip, sends to described first chip by UART bus by described UART bus data;
Second usb bus transmission unit, for described UART bus data being converted to usb bus data by described first chip, transmits described usb bus data on the usb bus.
Further, also comprise: setting unit, for arranging the buffering area of UART;
Described second CAN transmission unit, described CAN protocol frame for described CAN being received adds in the buffering area of described UART, from the buffering area of described UART, obtain described CAN protocol frame, the CAN protocol frame of acquisition is sent and sends to described second chip by CAN.
In the method and device of a kind of CAN communication provided by the invention, main frame arranges the first chip and the second chip respectively, by the first chip, data to be transmitted is converted to UART bus data, UART bus data is converted to CAN Frame by the second chip, CAN Frame is transmitted in CAN, realizes the data communication of CAN, in the method that this embodiment provides, without the need to writing complicated driver to CAN, can more simply realize CAN communication.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these accompanying drawings.
Fig. 1 is the flow chart of the method for a kind of CAN communication that one embodiment of the invention provides;
Fig. 2 is the flow chart of the method for the another kind of CAN communication that one embodiment of the invention provides;
Fig. 3 is the flow chart of the method for another CAN communication that one embodiment of the invention provides;
Fig. 4 is the flow chart of the method for another CAN communication that one embodiment of the invention provides;
Fig. 5 is the schematic diagram of the device of a kind of CAN communication that one embodiment of the invention provides;
Fig. 6 is the schematic diagram of the device of the another kind of CAN communication that one embodiment of the invention provides;
Embodiment
For making the object of the embodiment of the present invention, technical scheme and advantage clearly; below in conjunction with the accompanying drawing in the embodiment of the present invention; technical scheme in the embodiment of the present invention is clearly and completely described; obviously; described embodiment is the present invention's part embodiment, instead of whole embodiments, based on the embodiment in the present invention; the every other embodiment that those of ordinary skill in the art obtain under the prerequisite not making creative work, all belongs to the scope of protection of the invention.
As shown in Figure 1, embodiments provide the method for a kind of CAN communication, the method can comprise the following steps:
S0: carry is used for usb bus and UART (UniversalAsynchronousReceiver/Transmitter on the usb bus of main frame, universal asynchronous receiving-transmitting transmitter) the first chip of general line system, in described main frame, be configured for the second chip that UART bus and CAN are changed, also comprise:
S1: data to be transmitted is sent to described first chip by usb bus;
S2: described data to be transmitted is converted to UART bus data by described first chip, sends to described second chip by UART bus by described UART bus data;
S3: described UART bus data is converted to CAN protocol frame by described second chip, is transmitted described CAN protocol frame by described CAN.
In the method for a kind of CAN communication provided in the embodiment of the present invention, main frame arranges the first chip and the second chip respectively, by the first chip, data to be transmitted is converted to UART bus data, UART bus data is converted to CAN Frame by the second chip, CAN Frame is transmitted in CAN, realizes the data communication of CAN, in the method that this embodiment provides, without the need to writing complicated driver to CAN, can more simply realize CAN communication.
For the ease of being configured UART bus, can being /dev/ttyUSB0 by the first chip identification, in a kind of possible implementation, before described S1, also comprising:
Identify described first chip, generate described first chip corresponding/dev/ttyUSB0 file, receive the first configuration order, according to described first configuration order, described/dev/ttyUSB0 file is modified, realizes the configuration of the traffic rate to described UART bus, Flow Control mode, data bit, position of rest, check digit.
In this implementation, realize the configuration to UART bus by operation/dev/ttyUSB0.Wherein, traffic rate supports 300 common ~ 115200bps, and flow control mode can be set to not use current control, use software flow control and use hardware flow control three kinds of modes.First configuration order can be that above-mentioned main frame sends.
There is a lot of passages in CAN, need to carry out transfer of data by these CAN passages, in a kind of possible implementation, before described S1, also comprise:
Receiving the second configuration order, according to described second configuration order, opening in CAN for transmitting the CAN passage of data;
In described S3, described described CAN protocol frame to be transmitted by described CAN, comprising: described CAN protocol frame is transmitted on the CAN passage opened of CAN.
In this implementation, by the second configuration order, can be configured CAN passage, process is opened outside CAN passage, can also realize the operations such as closing passage, initialization, reset, removing buffer memory.Second configuration order can send by above-mentioned main frame.
In a kind of possible implementation, in described S3, describedly by described second chip, described UART bus data is converted to CAN protocol frame, comprises:
Be a frame by data to be transmitted with 8, add frame identification code, channel recognition code, frame category and form type code, frame ID at frame head place, add the School Affairs to data bit at postamble, generate described CAN protocol frame.
Wherein, the form of CAN protocol frame is as shown in table 1.
Table 1
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with drawings and the specific embodiments, the present invention is described in further detail.
In embodiments of the present invention, the system of main frame is acceptance of the bid kylin operating system, and this system does not support CAN, supports usb bus.
As shown in Figure 2, embodiments provide the method for a kind of CAN communication, the method can comprise the following steps:
Step 201: carry is used for the first chip of usb bus and UART general line system on the usb bus of main frame, the second chip that UART bus and CAN are changed is configured in main frame, the second configuration order that Receiving Host is sent, according to described second configuration order, open in CAN for transmitting the CAN passage of data.
Particularly, because the kernel of this system is more than Linux2.6.25 version, be integrated with the driving of cp210x in system, can drive CP2102 chip, the first chip can be: the CP2102 chip of SILICONLABS; Second chip can be: the NUC230LE3AE chip of Nuvoton, also comprise in NUC230LE3AE chip: main control module and TJA1040CAN transceiver, main control module is used for the conversion of UART bus data and CAN Frame, and TJA1040CAN transceiver is used for reception and the transmission of CAN data.
After first chip access host, under system, be identified as/dev/ttyUSB0, it can be used as common serial ports to read and write.
Step 202: data to be transmitted is sent to described first chip by usb bus.
Usb bus supported by main frame, when main frame needs externally to send data, data to be transmitted is sent on usb bus.
Step 203: described data to be transmitted is converted to UART bus data by described first chip, sends to described second chip by UART bus by described UART bus data.
Step 204: described UART bus data is converted to CAN protocol frame by described second chip, transmits described CAN protocol frame on the CAN passage opened of CAN.
Particularly, be a frame by data to be transmitted with 8, add frame identification code, channel recognition code, frame category and form type code, frame ID at frame head place, add the School Affairs to data bit at postamble, generate described CAN protocol frame.
By the method that this embodiment provides, the data that will be sent by main frame are transferred to the first chip by usb bus, convert UART bus data to, by UART bus transfer to the second chip, CAN protocol frame is converted to by the second chip, sent by the CAN protocol frame changed out by CAN, actual effect is by the transfer of data of CAN.
As shown in Figure 3, the method for a kind of CAN communication that the present embodiment provides, comprising:
A0: carry is used for the first chip of usb bus and UART general line system on the usb bus of main frame, is configured for the second chip that UART bus and CAN are changed in described main frame;
A1: receive the outside CAN protocol frame sent by CAN, and by CAN, described CAN protocol frame is sent to described second chip;
A2: described CAN protocol frame is converted to UART bus data by described second chip, sends to described first chip by UART bus by described UART bus data;
A3: described UART bus data is converted to usb bus data by described first chip, transmits described usb bus data on the usb bus.
The method of a kind of CAN communication provided by the embodiment of the present invention, the outside CAN protocol frame sent is received by CAN, CAN protocol frame is converted to UART bus data by the second chip, by the first chip, UART bus data is being converted to usb bus data, transmit these data on the usb bus, achieve the communication of CAN.
When main frame does not support that CAN communicates, the data that outside is sent successfully cannot be received by system, need the usb bus data that the system these data being converted to main frame can identify, the method provided by the present embodiment can realize the successful reception to CAN Frame.
In a kind of possible implementation, before described A1, also comprise:
Identify described first chip, generate described first chip corresponding/dev/ttyUSB0 file, receive the first configuration order, according to described first configuration order, described/dev/ttyUSB0 file is modified, realizes the configuration of the traffic rate to described UART bus, Flow Control mode, data bit, position of rest, check digit.
In a kind of possible implementation, before described A1, also comprising: receive the second configuration order, according to described second configuration order, opening in CAN for transmitting the CAN passage of data;
Described A1 comprises, and comprising: the CAN protocol frame sent by the described CAN channel reception outside of CAN, and by the CAN passage of CAN, described CAN protocol frame is sent to described second chip.
Because the highest support of traffic rate of UART bus under acceptance of the bid kylin operating system is to 115200bps, and CAN flank speed can reach 1M/s, therefore the data that CAN transmission comes possibly cannot be gone out by UART bus transfer completely, and the data of UART bus transfer can be made like this to make a mistake.Solve this problem, CAN can be set when transceiving data, ensure there is certain time interval, to guarantee the correctness that every frame data are received and dispatched between frame and frame.In addition, in a kind of possible implementation, before described A1, also comprise: the buffering area that UART is set;
Described A1 comprises: the described CAN protocol frame described CAN received adds in the buffering area of described UART, from the buffering area of described UART, obtain described CAN protocol frame, is sent by the CAN protocol frame of acquisition and sends to described second chip by CAN.
By the CAN protocol frame buffer that CAN receives by buffering area, from buffering area, obtain data carry out subsequent treatment, avoid the data transmission fault caused because transmission rate is different.
In a kind of possible implementation, in described A2, describedly by described second chip, described CAN protocol frame is converted to UART bus data, comprising: from described CAN protocol frame, extract data bit, is described UATR bus data by described data bit transition.Because the data of carrying in CAN protocol frame are stored in data bit, therefore the data in data bit are extracted and carry out changing.
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with drawings and the specific embodiments, the present invention is described in further detail.
In embodiments of the present invention, the system of main frame is acceptance of the bid kylin operating system, and this system does not support CAN, supports usb bus.
As shown in Figure 4, embodiments provide the method for a kind of CAN communication, the method can comprise the following steps:
Step 401: carry is used for the first chip of usb bus and UART general line system on the usb bus of main frame, is configured for the second chip that UART bus and CAN are changed, arranges the buffering area of UART in described main frame.
Particularly, because the kernel of this system is more than Linux2.6.25 version, be integrated with the driving of cp210x in system, can drive CP2102 chip, the first chip can be: the CP2102 chip of SILICONLABS; Second chip can be: the NUC230LE3AE chip of Nuvoton, also comprise in NUC230LE3AE chip: main control module and TJA1040CAN transceiver, main control module is used for the conversion of UART bus data and CAN Frame, and TJA1040CAN transceiver is used for reception and the transmission of CAN data.
Step 402: receive the outside CAN protocol frame sent by CAN, the described CAN protocol frame described CAN received adds in the buffering area of described UART, from the buffering area of described UART, obtain described CAN protocol frame, the CAN protocol frame of acquisition is sent and sends to described second chip by CAN.
Step 403: extract data bit by described second chip from described CAN protocol frame, is described UATR bus data by described data bit transition, by UART bus, described UART bus data is sent to described first chip.
Step 404: described UART bus data is converted to usb bus data by described first chip, transmits described usb bus data on the usb bus.
Can obtain above-mentioned usb bus data by usb bus, the method provided by this embodiment by main frame, user can by CAN to Host Transfer data, and the data that CAN receives also can obtain with the form of usb bus data by main frame.
See Fig. 5, embodiments provide the device of a kind of CAN communication, comprising:
First dispensing unit 501, is used for the first chip of usb bus and UART general line system for carry on the usb bus of main frame, be configured for the second chip that UART bus and CAN are changed in described main frame;
First usb bus transmission unit 502, for sending to described first chip by usb bus by data to be transmitted;
One UART bus transfer unit 503, for described data to be transmitted being converted to UART bus data by described first chip, sends to described second chip by UART bus by described UART bus data;
First CAN transmission unit 504, for described UART bus data being converted to CAN protocol frame by described second chip, is transmitted described CAN protocol frame by described CAN.
In a kind of possible implementation, this device also comprises: a UART bus configuration unit, for identifying described first chip, generate described first chip corresponding/dev/ttyUSB0 file, receive the first configuration order, according to described first configuration order, described/dev/ttyUSB0 file is modified, realize the configuration of the traffic rate to described UART bus, Flow Control mode, data bit, position of rest, check digit.
In a kind of possible implementation, this device also comprises: the first CAN dispensing unit, for receiving the second configuration order, according to described second configuration order, opens in CAN for transmitting the CAN passage of data.
Described first CAN transmission unit 504, perform described by described CAN protocol frame by the transmission of described CAN time, specifically execution: described CAN protocol frame is transmitted on the CAN passage opened of CAN.
In a kind of possible implementation, described first CAN transmission unit 504, when described UART bus data being converted to CAN protocol frame by described second chip described in performing, concrete execution: be a frame with 8 by data to be transmitted, frame identification code, channel recognition code, frame category and form type code, frame ID is added at frame head place, add the School Affairs to data bit at postamble, generate described CAN protocol frame.
See Fig. 6, embodiments provide the device of a kind of CAN communication, comprising:
Second dispensing unit 601, is used for the first chip of usb bus and UART general line system for carry on the usb bus of main frame, be configured for the second chip that UART bus and CAN are changed in described main frame;
Second CAN transmission unit 602, for receiving the outside CAN protocol frame sent by CAN, and sends to described second chip by CAN by described CAN protocol frame;
2nd UART bus transfer unit 603, for described CAN protocol frame being converted to UART bus data by described second chip, sends to described first chip by UART bus by described UART bus data;
Second usb bus transmission unit 604, for described UART bus data being converted to usb bus data by described first chip, transmits described usb bus data on the usb bus.
In a kind of possible implementation, this device, also comprises:
2nd UART bus configuration unit, for identifying described first chip, generate described first chip corresponding/dev/ttyUSB0 file, receive the first configuration order, according to described first configuration order, described/dev/ttyUSB0 file is modified, realizes the configuration of the traffic rate to described UART bus, Flow Control mode, data bit, position of rest, check digit.
In a kind of possible implementation, this device, also comprises: the second CAN dispensing unit, for receiving the second configuration order, according to described second configuration order, opens in CAN for transmitting the CAN passage of data;
Described second CAN transmission unit 602, for the CAN protocol frame sent by the described CAN channel reception outside of CAN, and sends to described second chip by the CAN passage of CAN by described CAN protocol frame.
In a kind of possible implementation, this device also comprises: setting unit, for arranging the buffering area of UART;
Described second CAN transmission unit 602, described CAN protocol frame for described CAN being received adds in the buffering area of described UART, from the buffering area of described UART, obtain described CAN protocol frame, the CAN protocol frame of acquisition is sent and sends to described second chip by CAN.
In a kind of possible implementation, described 2nd UART bus transfer unit, when described CAN protocol frame being converted to UART bus data by described second chip described in performing, described data bit transition is described UATR bus data by concrete execution: extract data bit from described CAN protocol frame.
The content such as information interaction, implementation between each unit in said apparatus, due to the inventive method embodiment based on same design, particular content can see in the inventive method embodiment describe, repeat no more herein.
Embodiments provide method and the device of the communication of a kind of CAN, there is following beneficial effect:
In the method for a kind of CAN communication 1, provided in the embodiment of the present invention and device, main frame arranges the first chip and the second chip respectively, by the first chip, data to be transmitted is converted to UART bus data, UART bus data is converted to CAN Frame by the second chip, CAN Frame is transmitted in CAN, realize the data communication of CAN, in the method that this embodiment provides and device, without the need to writing complicated driver to CAN, can more simply realize CAN communication.
2, in the method for a kind of CAN communication provided in the embodiment of the present invention and device, main frame arranges the first chip and the second chip respectively, the outside CAN protocol frame sent is received by CAN, CAN protocol frame is converted to UART bus data by the second chip, by the first chip, UART bus data is being converted to usb bus data, transmit these data on the usb bus, achieve the communication of CAN, in the method that this embodiment provides and device, without the need to writing complicated driver to CAN, can more simply realize CAN communication.
In the method for a kind of CAN communication 3, provided in the embodiment of the present invention and device, the buffering area of UART is set, by the CAN protocol frame buffer that CAN receives by this buffering area, from buffering area, obtain CAN protocol frame sends to the second chip to process, and avoids the data transmission fault caused because CAN is different with the transmission rate of UART bus.
It should be noted that, in this article, the relational terms of such as first and second and so on is only used for an entity or operation to separate with another entity or operating space, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, article or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, article or equipment.When not more restrictions, the key element " being comprised " limited by statement, and be not precluded within process, method, article or the equipment comprising described key element and also there is other identical factor.
One of ordinary skill in the art will appreciate that: all or part of step realizing said method embodiment can have been come by the hardware that program command is relevant, aforesaid program can be stored in the storage medium of embodied on computer readable, this program, when performing, performs the step comprising said method embodiment; And aforesaid storage medium comprises: ROM, RAM, magnetic disc or CD etc. various can be program code stored medium in.
Finally it should be noted that: the foregoing is only preferred embodiment of the present invention, only for illustration of technical scheme of the present invention, be not intended to limit protection scope of the present invention.All any amendments done within the spirit and principles in the present invention, equivalent replacement, improvement etc., be all included in protection scope of the present invention.

Claims (10)

1. a method for CAN communication, is characterized in that, comprising:
On the usb bus of main frame, carry is used for the first chip of usb bus and UART general line system, is configured for the second chip that UART bus and CAN are changed, also comprises in described main frame:
S1: data to be transmitted is sent to described first chip by usb bus;
S2: described data to be transmitted is converted to UART bus data by described first chip, sends to described second chip by UART bus by described UART bus data;
S3: described UART bus data is converted to CAN protocol frame by described second chip, is transmitted described CAN protocol frame by described CAN.
2. method according to claim 1, is characterized in that,
Before described S1, also comprise:
Identify described first chip, generate described first chip corresponding/dev/ttyUSB0 file, receive the first configuration order, according to described first configuration order, described/dev/ttyUSB0 file is modified, realizes the configuration of the traffic rate to described UART bus, Flow Control mode, data bit, position of rest, check digit;
And/or, before described S1, also comprise:
Receiving the second configuration order, according to described second configuration order, opening in CAN for transmitting the CAN passage of data;
In described S3, described described CAN protocol frame to be transmitted by described CAN, comprising:
Described CAN protocol frame is transmitted on the CAN passage opened of CAN.
3. method according to claim 1, is characterized in that, in described S3, describedly by described second chip, described UART bus data is converted to CAN protocol frame, comprises:
Be a frame by data to be transmitted with 8, add frame identification code, channel recognition code, frame category and form type code, frame ID at frame head place, add the School Affairs to data bit at postamble, generate described CAN protocol frame.
4. a method for CAN communication, is characterized in that, comprising:
On the usb bus of main frame, carry is used for the first chip of usb bus and UART general line system, is configured for the second chip that UART bus and CAN are changed, also comprises in described main frame:
A1: receive the outside CAN protocol frame sent by CAN, and by CAN, described CAN protocol frame is sent to described second chip;
A2: described CAN protocol frame is converted to UART bus data by described second chip, sends to described first chip by UART bus by described UART bus data;
A3: described UART bus data is converted to usb bus data by described first chip, transmits described usb bus data on the usb bus.
5. method according to claim 4, is characterized in that,
Before described A1, also comprise:
Identify described first chip, generate described first chip corresponding/dev/ttyUSB0 file, receive the first configuration order, according to described first configuration order, described/dev/ttyUSB0 file is modified, realizes the configuration of the traffic rate to described UART bus, Flow Control mode, data bit, position of rest, check digit;
And/or, before described A1, also comprise:
Receiving the second configuration order, according to described second configuration order, opening in CAN for transmitting the CAN passage of data;
Described A1 comprises, and comprising:
By the CAN protocol frame that the described CAN channel reception outside of CAN is sent, and by the CAN passage of CAN, described CAN protocol frame is sent to described second chip.
6. method according to claim 4, is characterized in that,
Before described A1, also comprise: the buffering area that UART is set;
Described A1 comprises: the described CAN protocol frame described CAN received adds in the buffering area of described UART, from the buffering area of described UART, obtain described CAN protocol frame, is sent by the CAN protocol frame of acquisition and sends to described second chip by CAN.
7. method according to claim 4, is characterized in that, in described A2, describedly by described second chip, described CAN protocol frame is converted to UART bus data, comprises:
From described CAN protocol frame, extract data bit, be described UATR bus data by described data bit transition.
8. a device for CAN communication, is characterized in that, comprising:
First dispensing unit, is used for the first chip of usb bus and UART general line system for carry on the usb bus of main frame, be configured for the second chip that UART bus and CAN are changed in described main frame;
First usb bus transmission unit, for sending to described first chip by usb bus by data to be transmitted;
One UART bus transfer unit, for described data to be transmitted being converted to UART bus data by described first chip, sends to described second chip by UART bus by described UART bus data;
First CAN transmission unit, for described UART bus data being converted to CAN protocol frame by described second chip, is transmitted described CAN protocol frame by described CAN.
9. a device for CAN communication, is characterized in that, comprising:
Second dispensing unit, is used for the first chip of usb bus and UART general line system for carry on the usb bus of main frame, be configured for the second chip that UART bus and CAN are changed in described main frame;
Second CAN transmission unit, for receiving the outside CAN protocol frame sent by CAN, and sends to described second chip by CAN by described CAN protocol frame;
2nd UART bus transfer unit, for described CAN protocol frame being converted to UART bus data by described second chip, sends to described first chip by UART bus by described UART bus data;
Second usb bus transmission unit, for described UART bus data being converted to usb bus data by described first chip, transmits described usb bus data on the usb bus.
10. device according to claim 9, is characterized in that, also comprises: setting unit, for arranging the buffering area of UART;
Described second CAN transmission unit, described CAN protocol frame for described CAN being received adds in the buffering area of described UART, from the buffering area of described UART, obtain described CAN protocol frame, the CAN protocol frame of acquisition is sent and sends to described second chip by CAN.
CN201510606609.8A 2015-09-22 2015-09-22 Method and device for CAN bus communication Pending CN105306323A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510606609.8A CN105306323A (en) 2015-09-22 2015-09-22 Method and device for CAN bus communication

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510606609.8A CN105306323A (en) 2015-09-22 2015-09-22 Method and device for CAN bus communication

Publications (1)

Publication Number Publication Date
CN105306323A true CN105306323A (en) 2016-02-03

Family

ID=55203102

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510606609.8A Pending CN105306323A (en) 2015-09-22 2015-09-22 Method and device for CAN bus communication

Country Status (1)

Country Link
CN (1) CN105306323A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106533793A (en) * 2016-12-12 2017-03-22 深圳市瑞凌实业股份有限公司 CAN protocol based communication method and system
CN109725575A (en) * 2018-12-27 2019-05-07 南京熊猫电子股份有限公司 The application system of compatible adaptive various field industrial bus communication
CN111158339A (en) * 2019-12-30 2020-05-15 北京京航计算通讯研究所 CAN bus simulation monitoring system
WO2020103097A1 (en) * 2018-11-22 2020-05-28 北京比特大陆科技有限公司 Data processing device
CN112181882A (en) * 2020-09-23 2021-01-05 深圳市领峰电动智能科技有限公司 Signal conversion method and device, electronic equipment and storage medium
CN112291256A (en) * 2020-11-06 2021-01-29 北京中航通用科技有限公司 UART gateway data transmission method
DE102020121102B3 (en) 2020-08-11 2022-02-03 Infineon Technologies Ag BATTERY MANAGEMENT SYSTEM AND METHOD OF DATA TRANSMISSION IN A BATTERY MANAGEMENT SYSTEM

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201869207U (en) * 2010-10-29 2011-06-15 苏州大学 Converter for data communication
CN202979000U (en) * 2012-11-28 2013-06-05 凯迈(洛阳)电子有限公司 USB interface device for converting UART bus to CAN bus

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201869207U (en) * 2010-10-29 2011-06-15 苏州大学 Converter for data communication
CN202979000U (en) * 2012-11-28 2013-06-05 凯迈(洛阳)电子有限公司 USB interface device for converting UART bus to CAN bus

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106533793A (en) * 2016-12-12 2017-03-22 深圳市瑞凌实业股份有限公司 CAN protocol based communication method and system
CN106533793B (en) * 2016-12-12 2019-08-20 深圳市瑞凌实业股份有限公司 Communication means and system based on CAN protocol
WO2020103097A1 (en) * 2018-11-22 2020-05-28 北京比特大陆科技有限公司 Data processing device
CN109725575A (en) * 2018-12-27 2019-05-07 南京熊猫电子股份有限公司 The application system of compatible adaptive various field industrial bus communication
CN111158339A (en) * 2019-12-30 2020-05-15 北京京航计算通讯研究所 CAN bus simulation monitoring system
CN111158339B (en) * 2019-12-30 2021-05-18 北京京航计算通讯研究所 CAN bus simulation monitoring system
DE102020121102B3 (en) 2020-08-11 2022-02-03 Infineon Technologies Ag BATTERY MANAGEMENT SYSTEM AND METHOD OF DATA TRANSMISSION IN A BATTERY MANAGEMENT SYSTEM
US20220052872A1 (en) * 2020-08-11 2022-02-17 Infineon Technologies Ag Battery management system and method for data transmission in a battery management system
US11956097B2 (en) * 2020-08-11 2024-04-09 Infineon Technologies Ag Battery management system and method for data transmission in a battery management system
CN112181882A (en) * 2020-09-23 2021-01-05 深圳市领峰电动智能科技有限公司 Signal conversion method and device, electronic equipment and storage medium
CN112291256A (en) * 2020-11-06 2021-01-29 北京中航通用科技有限公司 UART gateway data transmission method
CN112291256B (en) * 2020-11-06 2023-12-01 北京中航通用科技有限公司 UART gateway data transmission method

Similar Documents

Publication Publication Date Title
CN105306323A (en) Method and device for CAN bus communication
CN101714129B (en) Display controller driver
CN105208034A (en) SPI bus and CAN bus protocol converting circuit and method
CN105320624B (en) The electronic device controlled using data I/O management
CN102065568B (en) Data descriptor-based medium access control (MAC) software and hardware interaction method and hardware realization device
CN106126465B (en) A kind of data transmission method and device
CN102591812A (en) Method for operating a computer system
CN102054186B (en) Information encoding method and device for electronic tag
CN116506530B (en) Multi-protocol RFID reader-writer with low error rate
CN102884515A (en) Method, devices and system for serial port redirection process
TWI467492B (en) Rfid system with rfid readers and operating method thereof
CN105354166B (en) Robot and the data transmission method being applicable in
CN109992556A (en) A kind of I2C driving method and device
CN109992550A (en) Polymorphic type information processing unit and method based on cpci bus
CN104881694A (en) Data read-write method, terminal and system based on RFID double protocols
CN101488119B (en) Address interpretation method, apparatus and single-board
US7443886B1 (en) Communication protocol system and method
CN108055186A (en) A kind of principal and subordinate processor communication means and device
US20130060830A1 (en) Remote access system, electronic apparatus and method of processing remote access
CN106844273A (en) Access the method and device of DP accessory channels
CN103473197B (en) Gateway device and card of surfing Internet carry out adaptive method and apparatus
CN108196866B (en) Firmware updating method and device
CN105739919A (en) Data access system and method
CN101478455B (en) Handhold portable WorldFIP network data analyzer for locomotive
CN217008201U (en) 1553 board card based on XMC interface

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20160203