Author Topic: CAN-BUS SockectCAN  (Read 1704 times)


  • Newbie
  • Posts: 2
« on: January 28, 2018, 10:20:35 am »
Hello to all

does anyone did programming socket in the class PF_CAN for accessing CAN-BUS in Linux?
On the wiki side I have seen there are not current constant declaration for such network protocoll.

If the pfsocket and others call are just wrapper for standard BSD socket call I think it is enaugh to declare the constant just porting from the standard linux header.

Any info?



  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7927
Re: CAN-BUS SockectCAN
« Reply #1 on: January 28, 2018, 10:43:14 am »
Yes, the sockets unit are just wrappers. Best is if somebody finds the constants, tests it, and then submits a patch.


  • Newbie
  • Posts: 2
Re: CAN-BUS SockectCAN
« Reply #2 on: January 28, 2018, 06:30:27 pm »

got PF_CAN = 29 and CAN_RAW = 1 from sys/if.h

already run some tests with PF_CAN = 29 and CAN_RAW = 1 and it works.

I'm working a minimal porting from C header.


  • Newbie
  • Posts: 1
Re: CAN-BUS SockectCAN
« Reply #3 on: March 11, 2019, 08:50:21 am »
Hello at all, i am new here...

I try to establish a CAN connection on the raspberry pi (stretch), using free pascal.
I successfully created a raw socket with PF_CAN=29 and CAN_RAW=1.
And now i have to bind the socket to the hardware address, but i don't know how?

Code: Pascal  [Select]
  1. class procedure TSysBus.OpenSocket;
  2. var
  3.   s:Tsocket;
  4.   sa:TSockAddr;
  5. begin
  6.      s:=fpsocket(29, SOCK_RAW, 1);
  7.      sa.sa_family:=29;
  8.      sa.sa_data[0]:=???;
  9.      fpbind(s,@sa,SizeOf(sa));
  10.      FpClose(s);
  11. end;

Can somebody give me an example, how i have to go on?