Usage
The application first sets up its access to the CAN interface by initialising a socket (much like in TCP/IP communications), then binding that socket to an interface (or all interfaces, if the application so desires). Once bound, the socket can then be used like a UDP socket via read
, write
, etc...
Python added support for SocketCan in version 3.3.
There is also a virtual can driver for testing purposes which can be loaded and created in Linux with the commands below.
$ modprobe can $ modprobe can_raw $ modprobe can_bcm $ modprobe vcan $ sudo ip link add dev vcan0 type vcan $ sudo ip link set up vcan0 $ ip link show vcan0 3: vcan0:The following code snippet is a working example of the SocketCAN API, that sends a packet using the raw interface. It is based on the notes documented in the Linux Kernel.
#includeThe packet can be analyzed on the vcan0 interface using the candump utility which is part of the SocketCAN can-utils package.
can-utils $ ./candump vcan0 vcan0 123 11 22Read more about this topic: Socket CAN
Famous quotes containing the word usage:
“...Often the accurate answer to a usage question begins, It depends. And what it depends on most often is where you are, who you are, who your listeners or readers are, and what your purpose in speaking or writing is.”
—Kenneth G. Wilson (b. 1923)
“Pythagoras, Locke, Socratesbut pages
Might be filled up, as vainly as before,
With the sad usage of all sorts of sages,
Who in his life-time, each was deemed a bore!
The loftiest minds outrun their tardy ages.”
—George Gordon Noel Byron (17881824)
“Girls who put out are tramps. Girls who dont are ladies. This is, however, a rather archaic usage of the word. Should one of you boys happen upon a girl who doesnt put out, do not jump to the conclusion that you have found a lady. What you have probably found is a lesbian.”
—Fran Lebowitz (b. 1951)