Coder Social home page Coder Social logo

famez / j1939-framework Goto Github PK

View Code? Open in Web Editor NEW
153.0 11.0 53.0 1.65 MB

Framework to work with J1939 Frames used in CAN bus in bus, car and trucks industries

License: MIT License

C++ 80.68% C 10.65% CMake 3.14% HTML 4.25% JavaScript 0.78% Shell 0.50%
j1939 can-bus cplusplus-11 angularjs bus linux-distribution websockets javascript html c

j1939-framework's Introduction

Travis Build Status

J1939-Framework

Framework to work with J1939 protocol.

J1939 protocol is a standard used in different systems compliant with CAN 2.0B specification.

The framework has been developed in C++ in a Linux distribution and compiled using the GNU toolchain. No dependencies are required for the compilation of any of the projects except from SocketCan compiled in the Linux Kernel.

What can you do with J1939-Framework

  • Save can frames from the Can Bus into recordings in TRC format with BinUtils/TRCDumper.
  • Play can frames from recordings in TRC format into the Can Bus with BinUtils/TRCPlayer.
  • Convert TRC files into pcap files readable by wireshark with BinUtils/TRCToCap.
  • Dissect pcap files with wireshark and the J1939 plugin dissector (wireshark/dissector).
  • Sniff frames from the Can Bus compliant with J1939 protocol with BinUtils/j1939Sniffer.
  • Decode raw J1939 data to human readable data with BinUtils/j1939Decoder.
  • Craft your own J1939 frames and send them to the Can Bus with BinUtils/j1939Sender. The functionality can be extended with the help of bash scripts located in Scripts (some examples are listed).
  • Visualize what is going on in the Can Bus with GUI_WEB. You will be able to craft, send and visualize the frames that are flowing in the Bus as well as visualizing graphics of their content (SPNs).
  • Discover J1939 devices with BinUtils/j1939AddressMapper.
  • Simulation of the Address Claim Process with BinUtils/j1939AddrClaim.

And of course, develop!!:

  • In CAN/ folder we can find a library in C++ (libCAN.so) with methods to generate and sniff can frames with support for PeakCan and SocketCan.
  • In J1939/ folder we can find a library in C++ (libJ1939.so) to easily manipulate J1939 frames and work with the J1939 protocol. Some features are: Support of BAM protocol. A factory class in charge of generating the J1939 frames. A database loaded by the factory located in Database/frames.json with a list of the most used Application Layer frames (including the FMS protocol). Coding/Decoding DM1 (Diagnosis), FMS1 (TTS), Request and Address Claim frames. Coding/Decoding of SPNs (String, status and numeric).

Installing and compiling

Installation:

Ubuntu 18.10 or higher

sudo apt-get install libgtest-dev protobuf-compiler libprotobuf-dev libncurses-dev libwebsockets cmake
cd /usr/src/gtest
sudo env "PATH=$PATH" cmake CMakeLists.txt
sudo make
sudo cp *.a /usr/lib
git clone https://github.com/open-source-parsers/jsoncpp.git

 
cd jsoncpp
git checkout 863aa36165acfdbaf22447f4934f5adc327692a0
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON 
sudo make install
cd ~
git clone https://github.com/famez/J1939-Framework.git
cd J1939-Framework
cmake . 
cmake --build .
sudo make install

Usage with SocketCan:

To make SocketCan available in your system, you should execute the following commands:

sudo apt-get install can-utils

To enable the drivers if they not enabled by default:

sudo modprobe can
sudo modprobe vcan

To generate a virtual interface for test purposes.

sudo ip link add name vcan0 type vcan

To test over vcan0.

./Scripts/gear_level.sh vcan0 | j1939Sender --silent --file Scripts/define_frames.j1939
candump vcan0

TRCPlayer

alt text

Wireshark dissector

alt text

J1939GUI

alt text

alt text

j1939-framework's People

Contributors

famez avatar guilyx avatar martonmiklos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

j1939-framework's Issues

CMake command "protobuf_generate_cpp" : GUI_WEB

Not able to build GUI_WEB.
OS: Ubuntu~20.04

CMake Error at CMakeLists.txt:9 (protobuf_generate_cpp):
  Unknown CMake command "protobuf_generate_cpp".


-- Configuring incomplete, errors occurred!
See also "/home/zbr1kor/J1939-Framework/GUI_WEB/backend/build/CMakeFiles/CMakeOutput.log".
make: *** [Makefile:256: cmake_check_build_system] Error 1

Where comes the frame.json file ?

How to convert J1939DA.xls to the specific database.json format expected here ?
There are converters out there but none for the format used here.

Could it be used from Python ?

Very interesting lib you have here...
Any chance it could be called from a python program to replace python-can ?
Am just trying to figure out a way to read all frames from a 1mbps bus without loosing 4/5 of all messages.

Thanks !

Make CMake targets more modular to reduce required dependencies

As a user of this library, I want to just use a few parts of the library for things like J1939/Transport, but I am required to have a bunch of other dependencies to compile such as libgtest-dev protobuf-compiler libprotobuf-dev libncurses-dev libwebsockets jsoncpp

For example, if I just want transport, I should be able to build transport, with minimal requirements.

cmake -S . -B build && cmake --build build --target transport

Wireshark Dissector issue

Has anyone had luck getting the Wireshark dissector to work? I am able to build it, but I noticed that it appears to conflict with the existing standard Wireshark J1939 dissector which takes precedence when you analyze a packet. Thanks in advance for any help or pointers to information you can give me on this.

cmake --build . error

How to resolve this error

cmake --build .
[ 2%] Built target Common
[ 23%] Built target Can
[ 53%] Built target J1939
[ 55%] Linking CXX executable j1939Decoder
/usr/bin/ld: ../../J1939/libJ1939.so.1.0.0: undefined reference to Json::Value::operator=(Json::Value&&)' /usr/bin/ld: ../../J1939/libJ1939.so.1.0.0: undefined reference to Json::Value::Value(unsigned long)'
collect2: error: ld returned 1 exit status
make[2]: *** [BinUtils/j1939Decoder/CMakeFiles/j1939Decoder.dir/build.make:86: BinUtils/j1939Decoder/j1939Decoder] Error 1
make[1]: *** [CMakeFiles/Makefile2:488: BinUtils/j1939Decoder/CMakeFiles/j1939Decoder.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

RTS CTS Protocol

Thanks for giving the wonderful project. I'm learning the j1939 protocol stack and find the project lack of RTS/CTS transfer protocol. Does it support it?

segmentation fault when CanSniffer::sniff() exits

I created a thread that calls CanSniffer::sniff().
I can see my ontimeout() callback being called by the sniffer. When I call CanSniffer::finish() from another thread, I get a segmentation fault at the caller of CanSniffer::sniff().
My code is compiled using CMake, on Yocto, linking with LibCan.so and LibJ1939.so

Any clues?
Thanks

Cannot sniff CAN frames using libCan

Is there a proper example code for how to receive and send j1939 CAN frames in C++ ? The sample C++ code that exists in CAN folder does not work, giving me errors like these:

undefined reference to `Can::CanEasy::initialize(unsigned int, void ()(Can::CanFrame const&, Utils::TimeStamp const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, void), bool (*)())'

undefined reference to Can::CanEasy::mSniffer' undefined reference to Can::CanEasy::mSniffer'
undefined reference to `Can::CanSniffer::sniff(unsigned int) const'

Multipacket CAN utilities

Add basic multipacket BAM and CM send and receive utilities with no assumptions about SPNs.
Will submit a PR shortly.

Compile the project not success

@famez hi, thank you for your grate project
i want to compile the project ,but i stop in the problem of json.can you help me?

../../J1939/libJ1939.so.1.0.0: undefined reference to Json::Value::operator=(Json::Value&&)' ../../J1939/libJ1939.so.1.0.0: undefined reference to Json::Value::Value(unsigned long)'
collect2: error: ld returned 1 exit status
BinUtils/j1939Decoder/CMakeFiles/j1939Decoder.dir/build.make:96: recipe for target 'BinUtils/j1939Decoder/j1939Decoder' failed

thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.