Thread (6 messages) 6 messages, 4 authors, 2021-06-14

Re: How to statically set J1939 addresses and names

From: Kurt Van Dijck <hidden>
Date: 2021-06-14 09:10:46

On Mon, 14 Jun 2021 10:32:34 +0200, Rémy DZIEMIASZKO wrote:
Le ven. 11 juin 2021 à 08:57, Kurt Van Dijck
[off-list ref] a écrit :
quoted
On Fri, 11 Jun 2021 06:12:32 +0200, Oleksij Rempel wrote:
quoted
Hi Rémy,

On Tue, Jun 08, 2021 at 05:27:45PM +0200, Rémy DZIEMIASZKO wrote:
quoted
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.
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help