Skip to content

A Java wrapper for the CAN4Linux CAN bus driver

License

Notifications You must be signed in to change notification settings

jgeisler0303/libCAN4Linux-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Right now this is a lightly tested bare-bones Java wrapper for the CAN4Linux CAN bus driver. It only supports sending and receiving CAN messages. No baud-rate setting, no other driver config.

The code is heavily cribbed from libsocket-can-java and the pyCan.c example in the CAN4Linux source code.

I wrote the code to be able to use the integrated CAN bus of the Banana Pi in Java, which relies on the can4linux driver; unlike the Raspberry Pi where there is a SocketCAN driver for an attached MCP2515 CAN bus controller chip.

Make sure you have the right version of can4linux.h matching your installed driver in the include directory!

To run the test got to bin.test directory and run: java -cp .:../bin -Djava.library.path=../lib can4linux.CAN4LinuxTest.

  • Make sure you have the CAN baud rate set up matching to your receiving end (e.g. echo 500>/proc/sys/dev/Can/Baud).
  • Run some can bus monitor to see the message being sent by the test program.
  • Then you have 10s to send some message that the test program will then display.
  • If you get a mesage with identifier 0x7FFFFFFF you have an error in the transmission, most likely a baud rate mismatch. I will improve the test to display more detailed error messages later.

In the future I might add more functionality. But for now I will only test it and then move on to using it in my openHAB CANopen binding.

About

A Java wrapper for the CAN4Linux CAN bus driver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published