Forum > Networking and Web Programming

CAN-BUS SocketCAN

(1/32) > >>

rampinia:
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?

Thanks

marcov:
Yes, the sockets unit are just wrappers. Best is if somebody finds the constants, tests it, and then submits a patch.

rampinia:
Yes

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.

RM:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---class procedure TSysBus.OpenSocket;var  s:Tsocket;  sa:TSockAddr;begin     s:=fpsocket(29, SOCK_RAW, 1);     sa.sa_family:=29;     sa.sa_data[0]:=???;     fpbind(s,@sa,SizeOf(sa));     FpClose(s);end; 
Can somebody give me an example, how i have to go on?
Thanks

jcdammeyer:
Anyone been able to create the equivalent of a simple the socketCAN utilities  candump using Lazarus

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---debian@ebb:~$ sudo /sbin/ip link set can1 up type can bitrate 250000debian@ebb:~$ candump can1  can1  721   [1]  05  can1  1A1   [8]  20 00 FF 0F A8 FD A8 FD 
No one answered RM and rampinia didn't post any other solutions.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TSocketForm.Button1Click(Sender: TObject);var    i : integer;begin  // open socket  socket_result := fpsocket(PF_CAN, SOCK_RAW, CAN_RAW);  if (socket_result < 0) then begin        // perror("socket");    Edit1.text := 'Error #' + IntToStr(socket_result) + ' creating socket';  end  else begin    SAddr.sin_family := PF_CAN;    if fpconnect(socket_result, @SAddr, 0) = -1 then begin      Edit1.text := 'Socket can''t connect: ' + strerror(socketerror);    end;  end;end; 
The error is 'Operation not supported on Endpoint'

The C language candump doesn't use fpconnect() and the 'connect()' is deprecated and doesn't work either.  So although this is the document for fpconnect it uses deprecated functions rather than fpconnect().

https://www.freepascal.org/docs-html/current/rtl/sockets/fpconnect.html

Plus it's more targeted at internet protocol sockets.

Ideas?

Navigation

[0] Message Index

[#] Next page

Go to full version