* How to statically set J1939 addresses and names @ 2021-06-08 15:27 Rémy DZIEMIASZKO 2021-06-11 4:12 ` Oleksij Rempel 0 siblings, 1 reply; 6+ messages in thread From: Rémy DZIEMIASZKO @ 2021-06-08 15:27 UTC (permalink / raw) To: linux-can 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. Is there a way to assign J1939 addresses and names to a CAN interface without using the J1939 address claim protocol? I found in old j1939 kernel documentation something like ip addr add dev canX j1939 0xXX ip addr add dev canX j1939 name 0xXX See https://www.spinics.net/lists/netdev/msg162350.html But in the latest j1939 kernel documentation I do not find any reference to these commands. Thanks for your help -- Rémy Dziemiaszko Tech Manager Smile Embedded & Connected Systems ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to statically set J1939 addresses and names 2021-06-08 15:27 How to statically set J1939 addresses and names Rémy DZIEMIASZKO @ 2021-06-11 4:12 ` Oleksij Rempel 2021-06-11 6:57 ` Kurt Van Dijck 0 siblings, 1 reply; 6+ messages in thread From: Oleksij Rempel @ 2021-06-11 4:12 UTC (permalink / raw) To: Rémy DZIEMIASZKO; +Cc: linux-can 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. > > 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. > I found in old j1939 kernel documentation something like > ip addr add dev canX j1939 0xXX > ip addr add dev canX j1939 name 0xXX > See https://www.spinics.net/lists/netdev/msg162350.html > > But in the latest j1939 kernel documentation I do not find any > reference to these commands. Yes, it was pre mainline version. For mainlining we reduced UAPI to the minimum to simplify reviewing, mainlining and testing process. IF you need this option, you are welcome to send patches :) Or you can contact us or other company to implement it. Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to statically set J1939 addresses and names 2021-06-11 4:12 ` Oleksij Rempel @ 2021-06-11 6:57 ` Kurt Van Dijck 2021-06-12 10:02 ` Patrick Menschel 2021-06-14 8:32 ` Rémy DZIEMIASZKO 0 siblings, 2 replies; 6+ messages in thread From: Kurt Van Dijck @ 2021-06-11 6:57 UTC (permalink / raw) To: Rémy DZIEMIASZKO; +Cc: Oleksij Rempel, linux-can 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 found in old j1939 kernel documentation something like > > ip addr add dev canX j1939 0xXX > > ip addr add dev canX j1939 name 0xXX > > See https://www.spinics.net/lists/netdev/msg162350.html > > > > But in the latest j1939 kernel documentation I do not find any > > reference to these commands. > > Yes, it was pre mainline version. For mainlining we reduced UAPI to the > minimum to simplify reviewing, mainlining and testing process. > The strict addressing was rejected because it felt much heavier than what most CAN users were used to. Moving to the current ad-hoc implementation allowed to drop quite some kernel code too. > IF you need this option, you are welcome to send patches :) > Or you can contact us or other company to implement it. > > Regards, > Oleksij > -- > Pengutronix e.K. | | > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to statically set J1939 addresses and names 2021-06-11 6:57 ` Kurt Van Dijck @ 2021-06-12 10:02 ` Patrick Menschel 2021-06-14 8:32 ` Rémy DZIEMIASZKO 1 sibling, 0 replies; 6+ messages in thread From: Patrick Menschel @ 2021-06-12 10:02 UTC (permalink / raw) To: Rémy DZIEMIASZKO; +Cc: linux-can 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to statically set J1939 addresses and names 2021-06-11 6:57 ` Kurt Van Dijck 2021-06-12 10:02 ` Patrick Menschel @ 2021-06-14 8:32 ` Rémy DZIEMIASZKO 2021-06-14 9:10 ` Kurt Van Dijck 1 sibling, 1 reply; 6+ messages in thread From: Rémy DZIEMIASZKO @ 2021-06-14 8:32 UTC (permalink / raw) To: Rémy DZIEMIASZKO, Oleksij Rempel, linux-can Le ven. 11 juin 2021 à 08:57, Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be> a écrit : > > 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 found in old j1939 kernel documentation something like > > > ip addr add dev canX j1939 0xXX > > > ip addr add dev canX j1939 name 0xXX > > > See https://www.spinics.net/lists/netdev/msg162350.html > > > > > > But in the latest j1939 kernel documentation I do not find any > > > reference to these commands. > > > > Yes, it was pre mainline version. For mainlining we reduced UAPI to the > > minimum to simplify reviewing, mainlining and testing process. > > > > The strict addressing was rejected because it felt much heavier than > what most CAN users were used to. Moving to the current ad-hoc > implementation allowed to drop quite some kernel code too. > Hi Kurt, When I develop my application I don't know it's source address. I only know its name. In the future my application shall be integrated in different projects/vehicules. For each project, the source_address may be different but the name will never change. I don't want to adapt the source code of the application for each project so I don't want to bind/connect to source_addresses but to names. That's why it would be nice if the platform / the kernel does the translation name --> source_address. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to statically set J1939 addresses and names 2021-06-14 8:32 ` Rémy DZIEMIASZKO @ 2021-06-14 9:10 ` Kurt Van Dijck 0 siblings, 0 replies; 6+ messages in thread From: Kurt Van Dijck @ 2021-06-14 9:10 UTC (permalink / raw) To: Rémy DZIEMIASZKO; +Cc: Oleksij Rempel, linux-can On Mon, 14 Jun 2021 10:32:34 +0200, Rémy DZIEMIASZKO wrote: > Le ven. 11 juin 2021 à 08:57, Kurt Van Dijck > <dev.kurt@vandijck-laurijssen.be> a écrit : > > > > 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. > > > > > Hi Kurt, > > When I develop my application I don't know it's source address. I only > know its name. > In the future my application shall be integrated in different > projects/vehicules. > For each project, the source_address may be different but the name > will never change. Ok, I have a little misunderstood your question before. The way I interpret your setup now is going a bit off the j1939 spec. You use the NAME only, but don't want to use address claiming? that are opposite requrements. You want to re-use the same NAME on different projects/vehicules. Part of the NAME is the ECU serial number. You may keep the manufacturer and function attributes equal, but the NAME is (supposed to be) unique across the universe. And due to that, you can't know the complete NAME at compile time. Please note that the kernel will only translate NAME to SA for dynamic addresses, i.e. where address claiming took place. Please also not that the kernel does not care if another application dealt with the actual address claiming. So, can-utils contains a program, j1939acd, that can do the job for you. > I don't want to adapt the source code of the application for each > project so I don't want to bind/connect to source_addresses but to > names. I understand. That is a true goal. > That's why it would be nice if the platform / the kernel does the > translation name --> source_address. The way I now see your problem, you have 2 ways to proceed, which are pretty equal in development and deploy work. Both options avoid Address claiming code in your application, and avoid hardcoded static addresses. 1. You absolutely want no Address claiming on the CAN bus. You must use static addressing then. You make the effective SA used on the bus a parameter of your application, and use this static addressing mode. 2. You 'tolerate' Address claiming on the CAN bus, but only with a single predictable address. You can use j1939acd from can-utils to do the address claiming work. Your application still needs the final NAME as a parameter of your final application, who will use it to bind using dynamic addressing. To j1939acd, you only proved the single address as option. All dynamic addressing rules apply in case of address conflicts etc, but I suppose you manage somehow to not have any address collisions. A 3rd option with less deployment work could be a variation of 2., with hardcoded fixed NAME. You would still need to call j1939acd. Since hardcoded fixed NAME is out of the j1939 spec, it's a bit on your own risk. Kind regards, Kurt ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-14 9:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-06-08 15:27 How to statically set J1939 addresses and names Rémy DZIEMIASZKO 2021-06-11 4:12 ` Oleksij Rempel 2021-06-11 6:57 ` Kurt Van Dijck 2021-06-12 10:02 ` Patrick Menschel 2021-06-14 8:32 ` Rémy DZIEMIASZKO 2021-06-14 9:10 ` Kurt Van Dijck
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.