请输入您要查询的百科知识:

 

词条 Can4linux
释义

  1. Usage

  2. References

  3. External links

can4linux is an Open Source CAN Linux-Kernel device driver.

Development started in the mid 1990s for the Philips 82C200 CAN controller stand alone chip on a ISA Board AT-CAN-MINI.

In 1995 the first version was created to use the CAN bus with Linux for laboratory automation as a project of the Linux Lab Project at FU Berlin.

The increasing spread of the CAN field bus technology for automation especially in embedded devices and the growth of Linux in this area leads to a growing importance of device drivers as base for higher layer CAN protocols like CANopen, J1939 and DeviceNet.

Besides the NXP SJA1000 as successor of the first supported CAN controller Philips 82C200 and the Intel 82527, the development for powerful microcontrollers with integrated CAN controllers that are capable to run the Linux Operating system have been intensified since 2005. As examples for this development serve Freescale's ColdFire processors [1] or ARM models by ATMEL[2] and Freescale[3] but also the stand-alone CAN controller MCP2515,[4] connected via SPI Bus.


A list of supported CAN controllers is available on the can4linux project site.[5]

In the latest version there is a virtual CAN mode implemented which allows applications to communicate without CAN hardware but only by using the device

driver software layer. This mode already includes support for the new CAN frame format called CAN FD [6][7] which allows data frame length up to 64 byte.

Usage

Application software opens a CAN device descriptor and gets back a file descriptor. Using this file descriptor standard operating system functions like read() and write() are used to exchange CAN frames with other CAN nodes on a CAN bus.

The following code is an example which puts a CAN frame on the bus and afterwards waits for a CAN frame transmitted by another CAN node. More examples are available on the can4linux project site.[8]

/* simple CAN application example

 *  * used for the Wikipedia article on can4linux */
  1. include
  2. include
  3. include
  1. include

int main(int argc,char **argv)

{
    int fd;    canmsg_t frame;        /* open(),       bit rate comes from parameters at proc/sys/dev/Can */    fd = open("/dev/can0", O_RDWR);
    frame.id      = 100;    frame.length  = 2;    frame.data[0] = 5;    frame.data[1] = 0;    write(fd, &frame, 1); /* ! count is number of frames, not byte */
    read(fd, &frame, 1);  /* ! count is number of frames, not byte */    printf("received CAN Frame Id %ld, DLC=%d\", frame.id, frame.length);    return 0;

}

can4linux can be compiled in a way that allows more than one process to have access to the same CAN controller hardware for reading and writing frames on the CAN bus. Beside the real application other processes like data loggers or other diagnosis processes can access the bus.

References

1. ^Freescale ColdFire
2. ^ATMEL SAM9263
3. ^Freescale i.MX35 Familie{{Dead link|date=November 2018 |bot=InternetArchiveBot |fix-attempted=yes }}
4. ^Stand Alone CAN MCP2515
5. ^[https://gitlab.com/hjoertel/can4linux can4linux project site]
6. ^CAN FD Specification {{Webarchive|url=https://web.archive.org/web/20130822124728/http://www.bosch-semiconductors.de/media/pdf_1/canliteratur/can_fd_spec.pdf# |date=2013-08-22 }} (PDF; 314 kB)
7. ^CAN FD conference paper {{Webarchive|url=https://web.archive.org/web/20121113095040/http://www.can-cia.org/fileadmin/cia/files/icc/13/hartwich.pdf# |date=2012-11-13 }} (PDF; 624 kB)
8. ^Online [https://gitlab.com/hjoertel/can4linux/tree/master/can4linux-examples can4linux-examples]

External links

  • [https://gitlab.com/hjoertel/can4linux can4linux project site]
  • Doxygen generated documentation

6 : CAN bus|Linux software|Device drivers|Linux drivers|Serial buses|Data transmission

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 18:23:09