ECE497 Car CANBUS

From eLinux.org
Revision as of 22:16, 13 November 2017 by Daniel.Neelappa (talk | contribs) (Installation Instructions)
Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder


Team members: Daniel Neelappa,

Grading Template

I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!

00 Executive Summary
00 Installation Instructions 
00 User Instructions
00 Highlights
00 Theory of Operation
00 Work Breakdown
00 Future Work
00 Conclusions
00 Demo
00 Late
Comments: I'm looking forward to seeing this.

Score:  10/100

(Inline Comment)

Executive Summary

Intro: This project is designed to integrate the Beaglebone Blue with the network within a car. The Beaglebone Blue has a built-in transmitter and receiver for CAN messages. All vehicles in the U.S. manufactured after 2008 have CAN bus networks, and this provides an excellent opportunity to take advantage of the Beaglebone Blue's hardware. While cars have the same CAN protocol, they differ drastically in the messages that send. Each manufacture has their own message encoding, which makes it difficult to decipher what a message does.

Currently, I have the Beaglebone Blue's transmitter and receiver successfully reading my car's messages. I can even send messages through my Beaglebone Blue to my car. My host computer has successfully compiled can-utils. Can-utils is mentioned more below.

While, my Beaglebone blue can communicate with my car, my car is not currently responding to my requests. This is most likely an issue with not knowing the codes laid out by the manufacturer of my car. This has caused a hold on my progress, yet I mention below on some ideas I have moving forward.

It is unfortunate that each car has its own set of codes for diagnostics and normal functions. The upside is that car manufacturers can protect their end users from harm by obscuring the true functionality of each code. This deters hackers from easily sending viruses through multiple cars using a static attach type. Below, I mention some vulnerabilities with this CAN setup. Overall, once I deduce a few commands in my car, I can add new functionalities such as automatic windshield wipers or a diagnostic logger that resides within my vehicle.

Packaging

My project is still in the design and testing phase. As a result, the packaging isn't ready for a final product quality state.

However, here is my current debug setup:


I have attached a photo that shows my current setup. The beaglebone has a CAN port. In the picture, there is a jumper wire that connects to the CAN port and extends to the breadboard. The breadboard has a 16-pin OBDII wire to connect to my car. Most cars have a male OBDII 16-pin port. The wire connecting to the breadboard is a male to female OBDII 16-pin port. CAN is a 2-wire differential voltage transition protocol. Vehicles are mandated to have a standard OBDII connector. While many pins are left open to the manufacturer to choose their intended purpose, there are a few that are standard. There is a standard CAN pin connection. For my project, I connected to pins: CAR OBDII WIRE

CAR OBDII WIRE BEAGLEBONE
Pin 14 CAN Low Jumper
Pin 6 CAN High Jumper
Pin 5 GND of Beaglebone
Standard OBDII Pin-out
Beaglebone Blue Pin layout
CAN Bus Wiring to my Beaglebone Blue

Installation Instructions

First make sure your system on the bone is updated.

sudo apt-get update

Then we will prepare to load a device overlay onto the board.

sudo apt-get install build-essential git-core device-tree-compiler

Clone the following repository:

git clone https://github.com/beagleboard/bb.org-overlays/
cd ./bb.org-overlays/
./install.sh

You should now restart the system after the install. If you look in the /lib/firmware/ directory, there should be an overlay called "BB-CAN1-00A0.dtbo."

We will need to change a line in the boot DeviceTreeOverlay loader config file in order to load the CAN cape that is built into the beaglebone blue. Place the following line into the "/boot/uEnv.txt" file.

nano /boot/uEnv.txt
cape_enable=bone_capemgr.enable_partno=BB-CAN1

Now reboot the system.

We will load the kernel modules into the kernel:

sudo modprobe can
sudo modprobe can-dev
sudo modprobe can-raw

Now that the modules have been loaded, we will configure an interface for our CAN communications.

sudo ip link set can0 up type can bitrate 500000
sudo ifconfig can0 up

The above commands will set an interface up called "can0" with a bitrate of 500k. I have used 500k as the bitrate since most cars are standardized at this bitrate. If you do not receive messages by your car, then try to change the bitrate to 125k or 250k. It may take some debugging to get the right bitrate for your car.

Try this:

ifconfig

You should see a new interface called "can0." If you do, congratulations. You have successfully configured your CAN interface.

You might want to have your interface loaded upon boot-up. This will auto-start the interface we described above:

write the following into the file "/etc/network/interfaces" using sudo privileges:

allow-hotplug can0
iface can0 can static
bitrate 500000


Testing your communication setup:

One of the major tools that I used in this project was called "can-utils." This is a package that can be downloaded from a git repository.

 git clone https://github.com/linux-can/can-utils.git
cd can-utils/
./autogen.sh
./configure
make

Once the compilation process is over, there is a bunch of tools to use for CAN messaging.

See one of the below sections for more information.

Reference: link

User Instructions

Once everything is installed, how do you use the program? Give details here, so if you have a long user manual, link to it here.

Highlights

Here is where you brag about what your project can do.

Include a YouTube demo.

Theory of Operation

In a high level overview, I am using my beaglebone blue's CAN communicator to talk to my car. The board is running a kernel module that loads on boot time. The OS loads a network profile "can0" as an interface to use in the user mode. Once this is configured, I am ready to read and send CAN messages. I am using a software bundle called "can-utils." This is downloaded and compiled on the bone through the Debian distribution. I use commands like "./candump can0" to list all messages on the can interface or "./cansend" to send a message.

Work Breakdown

For all the tasks below, I (Daniel Neelappa) was working alone. From time to time, I would talk to Dr. Yoder to gain feedback and insight on the project. Most of my knowledge and a large part of this project was directed through research from online sites.

Also list here what doesn't work yet and when you think it will be finished and who is finishing it.

Future Work

Suggest addition things that could be done with this project.

Conclusions

So far, this has been a great project to work on. I would say that the project is still in the research side. Moving forward,



thumb‎ Embedded Linux Class by Mark A. Yoder