All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Menschel <menschel.p@posteo.de>
To: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Cc: linux-can <linux-can@vger.kernel.org>
Subject: Re: J1939 Questions on Intended usage
Date: Sat, 15 May 2021 14:01:53 +0000	[thread overview]
Message-ID: <38c85980-a569-b714-2643-9623b3dbc973@posteo.de> (raw)
In-Reply-To: <20210515122611.GC2387@x1.vandijck-laurijssen.be>

Am 15.05.21 um 14:26 schrieb Kurt Van Dijck:
> On Fri, 14 May 2021 12:04:47 +0000, Patrick Menschel wrote:
>> Do I need to open one socket per PGN I'm sending?
>> e.g.
>>
>> s1 = socket.socket(socket.AF_CAN, socket.SOCK_DGRAM, socket.CAN_J1939)
>> s1.bind(interface_name, MY_NAME, PGN_OF_TSC1, MY_SA)
>> s1.write(bytes(8))
>>
>> s2 = socket.socket(socket.AF_CAN, socket.SOCK_DGRAM, socket.CAN_J1939)
>> s2.bind(interface_name, MY_NAME, PGN_OF_EBC1, MY_SA)
>> s2.write(bytes(8))
> 
> No, you don't _need_ to. You can.
> 
> If you need quite some different PGN's, it may be more interesting to:
> s = socket.socket(socket.AF_CAN, socket.SOCK_DGRAM, socket.CAN_J1939)
> s.bind(interface_name, MY_NAME, ANY_PGN, MY_SA)
> s.sendto(bytes(8), DST_1, PGN_1)
> s.sendto(bytes(8), DST_2, PGN_2)
> ...
> 
> I'm not a python expert, I just assume something like that is possible.

Yes, the method exists

sendto()
https://docs.python.org/3/library/socket.html#socket.socket.sendto
https://github.com/python/cpython/blob/main/Modules/socketmodule.c#L4279

but apparently sockaddr_can is not yet expanded to individual parameters
as it was done with the

bind()
https://github.com/python/cpython/blob/main/Modules/socketmodule.c#L2207

Then I'll start by passing in the sockaddr_can struct as a first test
and make a PR to that repo in the long run.

>> What about the cyclic transmitted PGNs? Do I drop those into
>> BroadcastManager somehow?
> 
> The broadcast manager is seperate from j1939, so it's apart.

Now that would have been the cherry on the cake  ;-)
99% of J1939 are information sharing, cyclic messages of PDU2 format.
Handing the timing over to the BCM would have been super convenient.

Thanks again and Best Regards,
Patrick

  reply	other threads:[~2021-05-15 14:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 12:04 J1939 Questions on Intended usage Patrick Menschel
2021-05-15 12:26 ` Kurt Van Dijck
2021-05-15 14:01   ` Patrick Menschel [this message]
2021-05-15 18:10     ` Patrick Menschel
2021-05-15 18:41       ` Marc Kleine-Budde
2021-05-15 18:42       ` Kurt Van Dijck
2021-05-15 19:00         ` Patrick Menschel
2021-05-15 19:07           ` Kurt Van Dijck
2021-05-15 19:17           ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=38c85980-a569-b714-2643-9623b3dbc973@posteo.de \
    --to=menschel.p@posteo.de \
    --cc=dev.kurt@vandijck-laurijssen.be \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.