All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Menschel <menschel.p@posteo.de>
To: linux-can <linux-can@vger.kernel.org>
Subject: Re: correct length of bcm message
Date: Sun, 7 Feb 2021 07:33:31 +0100	[thread overview]
Message-ID: <f0b2d6de-9254-be02-abd6-0373834b574b@posteo.de> (raw)
In-Reply-To: <7f9ffbe7-8926-3874-9261-03e26f711b8d@hartkopp.net>

>> Interesting to know, apparently native alignment is 8 on X86_64 linux
>> and 4 on armhf linux. That's why it worked on X86_64.
>>
>> Regarding python ctypes module, setting _pack_=8 has no remedy effect on
>> armhf platform, so I'll move to struct module.

Hi,

tying some loose ends here.
My final solution to force alignment after bcm_msg_head to the next 8
byte boundary in python3 is to use an alignment hack of struct module.
https://docs.python.org/3/library/struct.html#struct-examples

struct.pack("IIIllllII0q",opcode,flags,count,ival1_sec,ival1_usec,ival2_sec,ival2_usec,can_id,nframes)

The "0q" is a zero length long long which causes padding up to the next
8 byte boundary.

This works for ARMHF (40 bytes) and X86_64 (72 bytes).

Regards,
Patrick

  reply	other threads:[~2021-02-07  6:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 15:38 correct length of bcm message Patrick Menschel
2021-02-04 17:47 ` Patrick Menschel
2021-02-04 20:14   ` Oliver Hartkopp
2021-02-05  8:27     ` Patrick Menschel
2021-02-05  9:01       ` Oliver Hartkopp
2021-02-07  6:33         ` Patrick Menschel [this message]
2021-02-07 18:23           ` Oliver Hartkopp

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=f0b2d6de-9254-be02-abd6-0373834b574b@posteo.de \
    --to=menschel.p@posteo.de \
    --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.