Re: How to statically set J1939 addresses and names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 11.06.21 um 08:57 schrieb Kurt Van Dijck:
> On Fri, 11 Jun 2021 06:12:32 +0200, Oleksij Rempel wrote:
>> Hi Rémy,
>>
>> On Tue, Jun 08, 2021 at 05:27:45PM +0200, Rémy DZIEMIASZKO wrote:
>>> Hello,
>>>
>>> I need that my applications do not care about J1939 node addresses but
>>> directly bind / connect to socket based on node name only and the
>>> kernel takes care of the conversion to addresses.
>>>
>>> I know this is possible if addresses are dynamically assigned through
>>> the Address Claiming protocol that is implemented in the kernel. The
>>> kernel keeps track of its own address and name as well as the
>>> addresses and names of other ECUs on the network and convert name to
>>> adresse when requested by the applications.
>>>
>>> But I don't want to use the Address Claiming protocol. I want to
>>> statically set all addresses and names.
> 
> It is supported to not use Address Claiming.
> 
>>>
>>> Is there a way to assign J1939 addresses and names to a CAN interface
>>> without using the J1939 address claim protocol?
>>
>> Current version do not have this functionality.
> 
> If you bind() your socket with only sockaddr_can.j1939.sa set to your
> SA, and sockaddr_can.j1939.name to 0, makes your socket use your SA as
> static address.
> 

I'm afraid I asked that question last month.

https://marc.info/?l=linux-can&m=162110222418338&w=2

In Python3.9, it basically sums up to

# making the socket
self._s = socket.socket(socket.AF_CAN, socket.SOCK_DGRAM, socket.CAN_J1939)

#binding the socket to a single defined address which is not 0, 254 or
255 by setting source_address to that value. pgn and source_address are
actually filter values in this context.

self._s.bind((interface, name, pgn, source_address))

#then use sendto and recvfrom.
self._s.sendto(data, (self.interface, self.name, pgn, addr))

data, (interface, name, pgn, addr) = self._s.recvfrom(bufsize)

C / C++ will work the same way.

Kind Regards,
Patrick Menschel



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux