All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] size of the struct can_frame
@ 2006-12-04 11:34 Frits de Klark
  2006-12-04 11:56 ` Wolfgang Grandegger
  0 siblings, 1 reply; 2+ messages in thread
From: Frits de Klark @ 2006-12-04 11:34 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

Hello everyone,

I noticed that the sizeof() function reports that the struct can_frame has a
size of 16 bytes. I know that this is because of memory aligning done by the
GNU compiler.
But now I wonder if there are actually 16 bytes transferred over the CAN
bus. I guess not, since it has such a strict and well-defined format, but
I'd like to have this confirmed by someone, please.
The size of 16 bytes though, is also passed to the rt_dev_recv() and
rt_dev_send() functions, so this is where I get confused: Are the correct
bytes extracted from this 16 byte block at a later stage (the CAN driver)?

I'm asking this to make sure that if, for example, I'd like to store all the
received frames in a binary file, I don't need to store all 16 bytes, just
the 13 (right?) that are in use.

I hope I made myself clear.

Thanks in advance and best regards!

Frits

[-- Attachment #2: Type: text/html, Size: 924 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Xenomai-help] size of the struct can_frame
  2006-12-04 11:34 [Xenomai-help] size of the struct can_frame Frits de Klark
@ 2006-12-04 11:56 ` Wolfgang Grandegger
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Grandegger @ 2006-12-04 11:56 UTC (permalink / raw)
  To: Frits de Klark; +Cc: xenomai

Frits de Klark wrote:
> Hello everyone,
> 
> I noticed that the sizeof() function reports that the struct can_frame 
> has a size of 16 bytes. I know that this is because of memory aligning 
> done by the GNU compiler.

This is just a structure to pass message data from and to the CAN driver.

> But now I wonder if there are actually 16 bytes transferred over the CAN 
> bus. I guess not, since it has such a strict and well-defined format, 
> but I'd like to have this confirmed by someone, please.

The format of the data actually transferred over the bus is defined in 
the CAN bus standard. And the driver just programs the appropriate 
registers of the CAN controller.

> The size of 16 bytes though, is also passed to the rt_dev_recv() and 
> rt_dev_send() functions, so this is where I get confused: Are the 
> correct bytes extracted from this 16 byte block at a later stage (the 
> CAN driver)?

Yes, of course. And the internal ringer buffers for received messages 
also use a "packed" format.

> I'm asking this to make sure that if, for example, I'd like to store all 
> the received frames in a binary file, I don't need to store all 16 
> bytes, just the 13 (right?) that are in use.

You need to store (5 + can_dlc) bytes.

> 
> I hope I made myself clear.
> 
> Thanks in advance and best regards!

Wolfgang.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-12-04 11:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-04 11:34 [Xenomai-help] size of the struct can_frame Frits de Klark
2006-12-04 11:56 ` Wolfgang Grandegger

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.