* [Xenomai-help] CAN rt_dev_recvfrom
@ 2007-02-28 20:08 roland Tollenaar
2007-02-28 20:59 ` Wolfgang Grandegger
0 siblings, 1 reply; 6+ messages in thread
From: roland Tollenaar @ 2007-02-28 20:08 UTC (permalink / raw)
To: xenomai
Hi,
Ok the issue I posted earlier regarding the read function. It seems
that it IS recieving can messages and displaying them correctly. Only
its behaviour is not as I expected. I thought the function
rt_dev_recvfrom
would simply perform a read one frame from a buffer (which in my
experience holds a number of can messages) then exit.
By the look of things I will have to implement the aforementioned
buffer myself. I.e
run rt_dev_recvfrom in a separate thread other than my periodic task
and store an x number of messages in BUFFER that I recieve there. The
can_read() function which I implement in the periodic task must then
simply read the messages from BUFFER.
Can this be confirmed or is rt_dev_recvfrom() behaving incorrectly in my case?
Kind regards,
Roland.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-help] CAN rt_dev_recvfrom
2007-02-28 20:08 [Xenomai-help] CAN rt_dev_recvfrom roland Tollenaar
@ 2007-02-28 20:59 ` Wolfgang Grandegger
2007-03-01 11:22 ` Roland Tollenaar
0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Grandegger @ 2007-02-28 20:59 UTC (permalink / raw)
To: roland Tollenaar; +Cc: xenomai
roland Tollenaar wrote:
> Hi,
>
> Ok the issue I posted earlier regarding the read function. It seems
> that it IS recieving can messages and displaying them correctly. Only
> its behaviour is not as I expected. I thought the function
>
> rt_dev_recvfrom
>
> would simply perform a read one frame from a buffer (which in my
> experience holds a number of can messages) then exit.
>
> By the look of things I will have to implement the aforementioned
> buffer myself. I.e
>
> run rt_dev_recvfrom in a separate thread other than my periodic task
> and store an x number of messages in BUFFER that I recieve there. The
> can_read() function which I implement in the periodic task must then
> simply read the messages from BUFFER.
>
> Can this be confirmed or is rt_dev_recvfrom() behaving incorrectly in my
> case?
rt_dev_recvfrom() reads message frames (one at a time) from an internal
socket buffer (there is actually a kernel configuration option to
configure the size). If no messages are available, it will block by
default, but it can also be used in non-blocking mode by using the flag
MSG_DONTWAIT. It seems, that your application is trying to read messages
periodically in polling mode. Either you do reading and buffering in
your own thread as you suggested above or you use rt_dev_recvfrom() in
non-blocking mode.
Wolfgang.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-help] CAN rt_dev_recvfrom
2007-02-28 20:59 ` Wolfgang Grandegger
@ 2007-03-01 11:22 ` Roland Tollenaar
2007-03-01 11:32 ` Wolfgang Grandegger
0 siblings, 1 reply; 6+ messages in thread
From: Roland Tollenaar @ 2007-03-01 11:22 UTC (permalink / raw)
To: Wolfgang Grandegger, Xenomai-help
Hi Wolfgang,
>> Can this be confirmed or is rt_dev_recvfrom() behaving incorrectly in
>> my case?
>
> rt_dev_recvfrom() reads message frames (one at a time) from an internal
> socket buffer (there is actually a kernel configuration option to
> configure the size). If no messages are available, it will block by
> default, but it can also be used in non-blocking mode by using the flag
> MSG_DONTWAIT. It seems, that your application is trying to read messages
> periodically in polling mode. Either you do reading and buffering in
> your own thread as you suggested above or you use rt_dev_recvfrom() in
> non-blocking mode.
Thanks for this. I have not tried it yet but I was looking for that flag
in the hope that something like this would exist. I thought I had seen
something like it but when I tried to locate it yesterday I failed.
Don;t worry it is there, I just checked. Sorry.
Where can I find the buffer size option in the kernel config menu? What
is the default size?
Thanks again.
Roland
>
> Wolfgang.
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-help] CAN rt_dev_recvfrom
2007-03-01 11:22 ` Roland Tollenaar
@ 2007-03-01 11:32 ` Wolfgang Grandegger
2007-03-01 12:10 ` Roland Tollenaar
0 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Grandegger @ 2007-03-01 11:32 UTC (permalink / raw)
To: rolandtollenaar; +Cc: Xenomai-help
Roland Tollenaar wrote:
> Hi Wolfgang,
>
>>> Can this be confirmed or is rt_dev_recvfrom() behaving incorrectly in
>>> my case?
>>
>> rt_dev_recvfrom() reads message frames (one at a time) from an
>> internal socket buffer (there is actually a kernel configuration
>> option to configure the size). If no messages are available, it will
>> block by default, but it can also be used in non-blocking mode by
>> using the flag MSG_DONTWAIT. It seems, that your application is trying
>> to read messages periodically in polling mode. Either you do reading
>> and buffering in your own thread as you suggested above or you use
>> rt_dev_recvfrom() in non-blocking mode.
>
> Thanks for this. I have not tried it yet but I was looking for that flag
> in the hope that something like this would exist. I thought I had seen
> something like it but when I tried to locate it yesterday I failed.
> Don;t worry it is there, I just checked. Sorry.
>
> Where can I find the buffer size option in the kernel config menu? What
> is the default size?
On the first menu of the RT-Socket-CAN configuration options:
config XENO_DRIVERS_CAN_RXBUF_SIZE
depends on XENO_DRIVERS_CAN
int "Size of receive ring buffers (must be 2^N)"
default 1024
Note that the messages are stored in "packed" format.
Wolfgang.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-help] CAN rt_dev_recvfrom
2007-03-01 11:32 ` Wolfgang Grandegger
@ 2007-03-01 12:10 ` Roland Tollenaar
2007-03-01 12:25 ` Wolfgang Grandegger
0 siblings, 1 reply; 6+ messages in thread
From: Roland Tollenaar @ 2007-03-01 12:10 UTC (permalink / raw)
To: Wolfgang Grandegger, Xenomai-help
Hi,
>> Where can I find the buffer size option in the kernel config menu?
>> What is the default size?
>
> On the first menu of the RT-Socket-CAN configuration options:
>
> config XENO_DRIVERS_CAN_RXBUF_SIZE
> depends on XENO_DRIVERS_CAN
> int "Size of receive ring buffers (must be 2^N)"
> default 1024
>
> Note that the messages are stored in "packed" format.
Does this mean that the buffer will store 1024 can_frame's ?
If yes (or even if no) when rt_dev_recv is called, does it place the
last recieved message (youngest message) or the oldest (behave like a
FIFO) into *Buf?
Roland
>
> Wolfgang.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Xenomai-help] CAN rt_dev_recvfrom
2007-03-01 12:10 ` Roland Tollenaar
@ 2007-03-01 12:25 ` Wolfgang Grandegger
0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Grandegger @ 2007-03-01 12:25 UTC (permalink / raw)
To: rolandtollenaar; +Cc: Xenomai-help
Roland Tollenaar wrote:
> Hi,
>
>>> Where can I find the buffer size option in the kernel config menu?
>>> What is the default size?
>>
>> On the first menu of the RT-Socket-CAN configuration options:
>>
>> config XENO_DRIVERS_CAN_RXBUF_SIZE
>> depends on XENO_DRIVERS_CAN
>> int "Size of receive ring buffers (must be 2^N)"
>> default 1024
>>
>> Note that the messages are stored in "packed" format.
>
> Does this mean that the buffer will store 1024 can_frame's ?
The size is usually in bytes. And as the messages are packed, the FIFO
can hold from 1024/5 to 1024/13 messages (without time-stamp).
> If yes (or even if no) when rt_dev_recv is called, does it place the
> last recieved message (youngest message) or the oldest (behave like a
> FIFO) into *Buf?
It is a FIFO.
Wolfgang.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-01 12:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-28 20:08 [Xenomai-help] CAN rt_dev_recvfrom roland Tollenaar
2007-02-28 20:59 ` Wolfgang Grandegger
2007-03-01 11:22 ` Roland Tollenaar
2007-03-01 11:32 ` Wolfgang Grandegger
2007-03-01 12:10 ` Roland Tollenaar
2007-03-01 12:25 ` 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.