Contact: netseal at users.sourceforge.net 
Development
The Linux CAN Sniffer


  Menu:

  » Home

  » svn checkout

 

 

 



Diagramm of the architectureInstances of classes


Architecture


General

The Application is build around the MainWindow. MainWindow nows all, is listening everywhere.
It holds up to 16 GraphicWindow and ObserverDialog instances. Basic control messiges are exchanged. It holds also an instance of ReadThread. The device is configured through Readthred via SIGNAL setDev() and its arguments. ReadThread owns after succsessful setDev() an instance of CANDevice.

The Views

All big list views invoke a StringlistModel derived from QAbstractListModel. It is responsiible for the quick storage of the data for the view. This Model is expanded with useful funktions for those Display actions. One can add other ideas.

The GraphicWindow is really simple class. But it invokes powerful implementations from the Qwt library.
In a listclass besides the GraphicWindow stores infomation about  the Signals on the Screen. There are also CANSignal objects in. It has got a SLOT for receiving newMessage() SIGNALs.

The ObserverDialog goes the same way in his own matter.

Documentation

I know the documentation is reare in this project. I started to add doxygen comment which can be extracted via doxygen to pdf or html.

Signal extraction via Rules

The class ProcessDatabase is loading class for all the rules out of an xml Database. It creates a CANSignalCollection on the heap and fills it with the information of the database. This information is packaged into CANSignal class. This class is responcible for the calculation of one Signal (a value send over the CAN). This is a spicific Signal assigned to one CAN ID. This CANSignalCollection is returned to the MainWindow who is now the owner. The pointer to this object are Blown with the wind into nearly ever other class who wants to know about.
Below is the format of the database:


    <ID Id="22">
        <Item0>
            <interpret EventItem="true" Constrain="0xf0" ConstrainMask="10000000"  Multiplier="1.0" Name="SomeName"
                Datamask="00000000" Unit="none">
            </interpret>
        </Item0>
        <Item1>
            <interpret EventItem="true" Constrain="0xf2" ConstrainMask="10000000"  Multiplier="1.0" Name="SomeName" Offset="0"
                Datamask="01200000" Unit="Ver.">
            </interpret>
        </Item1>
        <Item2>
            <interpret EventItem="true" Constrain="0x80" ConstrainMask="01000000"  Multiplier="1.0" Name="SomeName"
                Datamask="00000000" Unit="none">
            </interpret>
        </Item2>
        <Item3>
            <interpret EventItem="true" Constrain="0xf4" ConstrainMask="10000000"  Multiplier="1.0" Name="SomeName"
Offset="0"
                Datamask="01000000" Unit="none">
            </interpret>
        </Item3>
    </ID>

If EventItem=true a signal is only availeble on a compare match with some triggerdata (Constrain). If in Constrain a single bit only is set,the underlying data is only and masked with the Constrain Value. This raises the event and the Signal is available in ths CAN-Messages.
The both Masks ConstrainMask and Datamask describe how the data belongs together is put together. A "12300000" means shift the first of the eight databytes into the first eight bits of the raw-value. shift the second of the eight databytes into the second eight bits of the raw-value. And so on.
Then this raw value is multiplied by Multiplier then the Offset  is subtracted from the value. The value is a double at the moment.
Other types of values could be implemented via get funktions.
This class can also be used to implement a interface to the CANdB format.
The eventitems are interesting on Signals on the CAN like a reset, a data package send all days.
The other are continuiesly captured measurement values or command values for a controller - actuator pair.

Interface to the drivers

There is a simple so-interface for interacting with the driver. One has to implemnt the class CANDevice for specific hardware.
The interface class to the devices has got to implement a few funktions.  Reads, writes to the CAN Bus, configuration , filter setting is standardized over this interface. This class is compiled as shared library. It has to be placed in the subdirectory lib with some qualifieing name.  This library is loaded if the user asks for. For linux there is a sample project for the QT-Creator. The binary lib has to be copied to the lib directory.
On Windows there will be something similar producing dll's.

Building from the Sources

The sourcs were built and thested with QT 4.5.1. There is no exception handling on different versions on the library.
It was built on Gentoo with gcc 4.3.2 .

I needed to add  -lqwt -lpcan to the included libs. But maybe you need to add something like -lwqt-qt4.

General

First you need to install the Drivers for your CAN-Hardware. Currently there is only support for the PEAK-System interfaces. The USB-Interface is the only tested one but the others should work out of the box. If you have not got a CAN Interface, you can try the Program too, since it allows you to use all the functionality by loading sniffed information from a file. A little file is included. A little Database that shows the defition of Items too. The Software is the very first release and might steel your Beer. So pay attention!

Driverinstallation

Your linux kernel needs support for your CAN hardware and additinally support
for the SocketCAN network interface. Follow the instruction on the SocketCAN
wiki site: http://en.wikipedia.org/wiki/SocketCAN. Additinally see After in-
stallation, plug in your hardware and load the drivers:
See the howto.pdf on the main page.

Getting the Source


The project is in a svn respository on Sourceforge.net.
You need a svn client to check it out. Look inside of your distribution Package Manager for this client.
With the following Code, you can check it out onto a local directory on your Computer:

 svn co https://qcanobserver.svn.sourceforge.net/svnroot/qcanobserver qcanobserver


If you want to commit some changes, contact me on my sourceforge account.


If you haven't, you should install the QT4 libraries. Also you need the Qwt libs. Best you try to install them from you Distro's package manager.
I found the QT-Creator useful. It is a lightwight IDE for GUI development.
Open the .pro file inside of The Creator and add a Form-Class called Observer. It should be a dialog.
Here one should be able to add specific ID's. Display the States of the Items inside the Message that you got out of the Database.
Follow your own ideas!
You can build the Programm also without the Qt Creator. Try make at the shell.

Basic usage

In the menu select a device first. Then select a database. In the menu select ``new'' -> Graphic. Add some Items to the Graphic window then. Start sniffing!

Without a CAN-Interface

In the menu select a database first. In the menu select ``new'' -> Graphic. Add some Items to the Graphic window then. Load a sniffed file!



© 2007 - ... yourdomain.com  

Design downloaded from Free Templates - your source for free web templates