0

I am trying to figure out how to use a SocketCAN connection in Java.

As stated in the SocketCAN doc, SocketCAN is designed very similar to TCP and UDP Sockets. It also provides a network interface for each connected CAN bus. These are also listed for example by ifconfig:

can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

But the can0 interface is not listed by NetworkInterface.networkInterfaces() in Java for example. I guess, because it's not a TCP/UDP interface with an IP. CAN is a different network, without addresses.

I would like give it a try by using the Unix Domain Socket support in Java. But I couldn't find out the file path of the CAN interface to build a UnixDomainSocketAddress.

I know there are tools that route the SocketCAN to a network connection, like socketcand. And also I found libs that make SocketCAN usage possible via JNI or JNA. But I would like to give it a try without extra JNI/JNA implementations and extra tools.

4
  • Have you found any more information on this? I'm going to be trying something similar soon. Commented Jun 25, 2023 at 16:56
  • No, sorry I didn't find an answer yet. But not an high priority for me. So didn't invest more time yet. Commented Jul 4, 2023 at 6:53
  • Still no luck? I need to do the same thing and have been doing a LOT of searching... Commented Jan 1, 2024 at 20:26
  • No, sorry. I did not investigate anymore. Commented Apr 30 at 14:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.