All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] warnings and tangled threads.
@ 2007-02-27 23:25 roland Tollenaar
  2007-02-28  7:55 ` Jan Kiszka
  0 siblings, 1 reply; 9+ messages in thread
From: roland Tollenaar @ 2007-02-27 23:25 UTC (permalink / raw)
  To: xenomai

Hi,

Ok I have CAN functionality of some form running in my tasks.
Initializing seems to be successful and I have written some kind of
wrapper to create a can_write() function of my own which also seems to
be -kind of-  working. I have one question and one problem.

I keep on getting this compile warning

In file included from /mnt/appusb/xenomai/include/rtdm/rtcan.h:250,
                 from cancom.cpp:15:
/mnt/appusb/xenomai/include/rtdm/rtdm.h: In function `ssize_t
rt_dev_sendto(int, const void*, size_t, int, const sockaddr*,
socklen_t)':
/mnt/appusb/xenomai/include/rtdm/rtdm.h:323: warning: missing
initializer for member `msghdr::msg_flags'

Its in rtdm.h so I have not looked closely at it yet but I presume I
must be doing something wrong to be getting it?


The problem I have is that I test my code by running rtcanrecv on
rtcan0 while my application also sends on rtcan0.

What happens is that one of the two real-time tasks does not start up.
If I am lucky the one (task1) calling can_write() starts up and then
the messages come through to rtcanrecv. Great. But if I am less lucky
then task 2 runs happily and task1  does nothing. Nothing is received
on rtcanrecv.

If rtcanrecv is not running then my application has no problems. I can
see that it is writing by reading out /proc/rtcan/rtcan0/info looking
at TxCount.

I call can_write() directly after rt_task_wait_period so i did not
think it necessary to use rt_task_shadow or such like in it.
Can_write is implemented in a separate .cpp file to the one in which
it is called. Can this cause memory faults? Must I use mlockall in
can_write() or something?


Thanks for the time.


Kind regards,

Roland.


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

* Re: [Xenomai-help] warnings and tangled threads.
  2007-02-27 23:25 [Xenomai-help] warnings and tangled threads roland Tollenaar
@ 2007-02-28  7:55 ` Jan Kiszka
  2007-02-28  8:40   ` Jan Kiszka
  2007-02-28 18:00   ` roland Tollenaar
  0 siblings, 2 replies; 9+ messages in thread
From: Jan Kiszka @ 2007-02-28  7:55 UTC (permalink / raw)
  To: roland Tollenaar; +Cc: xenomai

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

roland Tollenaar wrote:
> Hi,
> 
> Ok I have CAN functionality of some form running in my tasks.
> Initializing seems to be successful and I have written some kind of
> wrapper to create a can_write() function of my own which also seems to
> be -kind of-  working. I have one question and one problem.
> 
> I keep on getting this compile warning
> 
> In file included from /mnt/appusb/xenomai/include/rtdm/rtcan.h:250,
>                 from cancom.cpp:15:
> /mnt/appusb/xenomai/include/rtdm/rtdm.h: In function `ssize_t
> rt_dev_sendto(int, const void*, size_t, int, const sockaddr*,
> socklen_t)':
> /mnt/appusb/xenomai/include/rtdm/rtdm.h:323: warning: missing
> initializer for member `msghdr::msg_flags'
> 
> Its in rtdm.h so I have not looked closely at it yet but I presume I
> must be doing something wrong to be getting it?

That seems to be due to non-default -Wmissing-field-initializers, right?
Will have a look if we can quiet gcc.

> 
> The problem I have is that I test my code by running rtcanrecv on
> rtcan0 while my application also sends on rtcan0.
> 
> What happens is that one of the two real-time tasks does not start up.
> If I am lucky the one (task1) calling can_write() starts up and then
> the messages come through to rtcanrecv. Great. But if I am less lucky
> then task 2 runs happily and task1  does nothing. Nothing is received
> on rtcanrecv.
> 
> If rtcanrecv is not running then my application has no problems. I can
> see that it is writing by reading out /proc/rtcan/rtcan0/info looking
> at TxCount.
> 
> I call can_write() directly after rt_task_wait_period so i did not
> think it necessary to use rt_task_shadow or such like in it.

rt_task_shadow() is required if you call blocking services like
rt_task_wait_period from a task AND you didn't create it via some other
native service (rt_task_spawn or rt_task_create/start).

> Can_write is implemented in a separate .cpp file to the one in which
> it is called. Can this cause memory faults? Must I use mlockall in
> can_write() or something?

mlockall is needed once for a _process_, not per thread (or rt_task).

If the problem persists even with clean rt_task setup (rt_task_shadow
etc.), I guess it's best you post your code.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

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

* Re: [Xenomai-help] warnings and tangled threads.
  2007-02-28  7:55 ` Jan Kiszka
@ 2007-02-28  8:40   ` Jan Kiszka
  2007-02-28 13:53     ` Jan Kiszka
  2007-02-28 18:00   ` roland Tollenaar
  1 sibling, 1 reply; 9+ messages in thread
From: Jan Kiszka @ 2007-02-28  8:40 UTC (permalink / raw)
  To: roland Tollenaar; +Cc: xenomai

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

Jan Kiszka wrote:
> roland Tollenaar wrote:
>> Hi,
>>
>> Ok I have CAN functionality of some form running in my tasks.
>> Initializing seems to be successful and I have written some kind of
>> wrapper to create a can_write() function of my own which also seems to
>> be -kind of-  working. I have one question and one problem.
>>
>> I keep on getting this compile warning
>>
>> In file included from /mnt/appusb/xenomai/include/rtdm/rtcan.h:250,
>>                 from cancom.cpp:15:
>> /mnt/appusb/xenomai/include/rtdm/rtdm.h: In function `ssize_t
>> rt_dev_sendto(int, const void*, size_t, int, const sockaddr*,
>> socklen_t)':
>> /mnt/appusb/xenomai/include/rtdm/rtdm.h:323: warning: missing
>> initializer for member `msghdr::msg_flags'
>>
>> Its in rtdm.h so I have not looked closely at it yet but I presume I
>> must be doing something wrong to be getting it?
> 
> That seems to be due to non-default -Wmissing-field-initializers, right?
> Will have a look if we can quiet gcc.
> 

This works for me here (and is a bit more telling as well):

--- include/rtdm/rtdm.h (Revision 2265)
+++ include/rtdm/rtdm.h (Arbeitskopie)
@@ -295,13 +295,22 @@ static inline ssize_t rt_dev_recvfrom(in
                                       struct sockaddr *from,
                                       socklen_t *fromlen)
 {
-    struct iovec    iov = {buf, len};
-    struct msghdr   msg =
-        {from, (from != NULL) ? *fromlen : 0, &iov, 1, NULL, 0};
-    int             ret;
+    struct iovec iov = {
+        .iov_base = buf,
+        .iov_len = len
+    };
+    struct msghdr msg =
+        .msg_name = from,
+        .msg_namelen = from ? *fromlen : 0,
+        .msg_iov = &iov,
+        .msg_iovlen = 1,
+        .msg_control = NULL,
+        .msg_controllen = 0
+    };
+    int ret;
 
     ret = rt_dev_recvmsg(fd, &msg, flags);
-    if ((ret >= 0) && (from != NULL))
+    if (ret >= 0 && from)
         *fromlen = msg.msg_namelen;
     return ret;
 }
@@ -345,9 +354,18 @@ static inline ssize_t rt_dev_sendto(int 
                                     int flags, const struct sockaddr *to,
                                     socklen_t tolen)
 {
-    struct iovec    iov = {(void *)buf, len};
-    struct msghdr   msg =
-        {(struct sockaddr *)to, tolen, &iov, 1, NULL, 0};
+    struct iovec iov = {
+        .iov_base = (void *)buf,
+        .iov_len = len
+    };
+    struct msghdr msg = {
+        .msg_name = (struct sockaddr *)to,
+        .msg_namelen = tolen,
+        .msg_iov = &iov,
+        .msg_iovlen = 1,
+        .msg_control = NULL, 
+        .msg_controllen = 0
+    };
 
     return rt_dev_sendmsg(fd, &msg, flags);
 }


Can you confirm it?

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

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

* Re: [Xenomai-help] warnings and tangled threads.
  2007-02-28  8:40   ` Jan Kiszka
@ 2007-02-28 13:53     ` Jan Kiszka
  2007-03-01 19:51       ` roland Tollenaar
  0 siblings, 1 reply; 9+ messages in thread
From: Jan Kiszka @ 2007-02-28 13:53 UTC (permalink / raw)
  To: roland Tollenaar; +Cc: xenomai

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

Jan Kiszka wrote:
> Jan Kiszka wrote:
>> roland Tollenaar wrote:
>>> Hi,
>>>
>>> Ok I have CAN functionality of some form running in my tasks.
>>> Initializing seems to be successful and I have written some kind of
>>> wrapper to create a can_write() function of my own which also seems to
>>> be -kind of-  working. I have one question and one problem.
>>>
>>> I keep on getting this compile warning
>>>
>>> In file included from /mnt/appusb/xenomai/include/rtdm/rtcan.h:250,
>>>                 from cancom.cpp:15:
>>> /mnt/appusb/xenomai/include/rtdm/rtdm.h: In function `ssize_t
>>> rt_dev_sendto(int, const void*, size_t, int, const sockaddr*,
>>> socklen_t)':
>>> /mnt/appusb/xenomai/include/rtdm/rtdm.h:323: warning: missing
>>> initializer for member `msghdr::msg_flags'
>>>
>>> Its in rtdm.h so I have not looked closely at it yet but I presume I
>>> must be doing something wrong to be getting it?
>> That seems to be due to non-default -Wmissing-field-initializers, right?
>> Will have a look if we can quiet gcc.
>>
> 
> This works for me here (and is a bit more telling as well):
> 
> --- include/rtdm/rtdm.h (Revision 2265)
> +++ include/rtdm/rtdm.h (Arbeitskopie)
> @@ -295,13 +295,22 @@ static inline ssize_t rt_dev_recvfrom(in
>                                        struct sockaddr *from,
>                                        socklen_t *fromlen)
>  {
> -    struct iovec    iov = {buf, len};
> -    struct msghdr   msg =
> -        {from, (from != NULL) ? *fromlen : 0, &iov, 1, NULL, 0};
> -    int             ret;
> +    struct iovec iov = {
> +        .iov_base = buf,
> +        .iov_len = len
> +    };
> +    struct msghdr msg =
                          ^^^
Insert "{", or the kernel build breaks. :(

> +        .msg_name = from,
> +        .msg_namelen = from ? *fromlen : 0,
> +        .msg_iov = &iov,
> +        .msg_iovlen = 1,
> +        .msg_control = NULL,
> +        .msg_controllen = 0
> +    };
> +    int ret;
>  
>      ret = rt_dev_recvmsg(fd, &msg, flags);
> -    if ((ret >= 0) && (from != NULL))
> +    if (ret >= 0 && from)
>          *fromlen = msg.msg_namelen;
>      return ret;
>  }
> @@ -345,9 +354,18 @@ static inline ssize_t rt_dev_sendto(int 
>                                      int flags, const struct sockaddr *to,
>                                      socklen_t tolen)
>  {
> -    struct iovec    iov = {(void *)buf, len};
> -    struct msghdr   msg =
> -        {(struct sockaddr *)to, tolen, &iov, 1, NULL, 0};
> +    struct iovec iov = {
> +        .iov_base = (void *)buf,
> +        .iov_len = len
> +    };
> +    struct msghdr msg = {
> +        .msg_name = (struct sockaddr *)to,
> +        .msg_namelen = tolen,
> +        .msg_iov = &iov,
> +        .msg_iovlen = 1,
> +        .msg_control = NULL, 
> +        .msg_controllen = 0
> +    };
>  
>      return rt_dev_sendmsg(fd, &msg, flags);
>  }
> 
> 
> Can you confirm it?
> 
> Jan
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

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

* Re: [Xenomai-help] warnings and tangled threads.
  2007-02-28  7:55 ` Jan Kiszka
  2007-02-28  8:40   ` Jan Kiszka
@ 2007-02-28 18:00   ` roland Tollenaar
  2007-02-28 20:10     ` Wolfgang Grandegger
  1 sibling, 1 reply; 9+ messages in thread
From: roland Tollenaar @ 2007-02-28 18:00 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai

HI

> That seems to be due to non-default -Wmissing-field-initializers, right?
> Will have a look if we can quiet gcc.
Possible.  I have received your patch. Will apply it (have to figure
out how first) later and give feedback.



> > If rtcanrecv is not running then my application has no problems. I can
> > see that it is writing by reading out /proc/rtcan/rtcan0/info looking
> > at TxCount.
> >
> > I call can_write() directly after rt_task_wait_period so i did not
> > think it necessary to use rt_task_shadow or such like in it.
>
> rt_task_shadow() is required if you call blocking services like
> rt_task_wait_period from a task AND you didn't create it via some other
> native service (rt_task_spawn or rt_task_create/start).
Well then my code should be correct.


> If the problem persists even with clean rt_task setup (rt_task_shadow
> etc.), I guess it's best you post your code.
Without changing my code I cannot repeat the behavior myself. Very
strange. I have tried just about everything but after starting up the
PC this morning there is no way I can repeat the behaviour I describe
above.

So the can_write seems to be working for now. If it happens again I
will post the code.


I have more of a problem with reading. I am doing something wrong. The
program does not return from the call rt_dev_recvfrom. Below is the
simple read function I am presuming that whatever I am doing wrong
will be blatantly obvious to all except me:)

void can_read(const char * device, can_frame_t * frame){

	int  ret;
    	struct ifreq ifr;
	struct sockaddr_can addr;
    	socklen_t addrlen = sizeof(addr);
	struct sockaddr_can recv_addr;

	strncpy(ifr.ifr_name, device, IFNAMSIZ);
	ret = rt_dev_ioctl(can_fd, SIOCGIFINDEX, &ifr);
	if (ret < 0) {
		fprintf(stderr, "rt_dev_ioctl get index: %s\n", strerror(-ret));
		return;
	}

	recv_addr.can_family = AF_CAN;
    	recv_addr.can_ifindex = ifr.ifr_ifindex;
    	ret = rt_dev_bind(can_fd, (struct sockaddr *)&recv_addr,
sizeof(struct sockaddr_can));

	if (ret < 0) {
		fprintf(stderr, "rt_dev_bind: %s\n", strerror(-ret));
		return;
	}
	
printf("going in");
	ret = rt_dev_recvfrom(can_fd, (void *)frame, sizeof(can_frame_t), 0,
(struct sockaddr *)&addr, &addrlen);
printf("coming out");


}//can_read


Regards,

Roland




>
> Jan
>
>
>


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

* Re: [Xenomai-help] warnings and tangled threads.
  2007-02-28 18:00   ` roland Tollenaar
@ 2007-02-28 20:10     ` Wolfgang Grandegger
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfgang Grandegger @ 2007-02-28 20:10 UTC (permalink / raw)
  To: roland Tollenaar; +Cc: xenomai, Jan Kiszka

roland Tollenaar wrote:
> HI
> 
>> That seems to be due to non-default -Wmissing-field-initializers, right?
>> Will have a look if we can quiet gcc.
> Possible.  I have received your patch. Will apply it (have to figure
> out how first) later and give feedback.
> 
> 
> 
>> > If rtcanrecv is not running then my application has no problems. I can
>> > see that it is writing by reading out /proc/rtcan/rtcan0/info looking
>> > at TxCount.
>> >
>> > I call can_write() directly after rt_task_wait_period so i did not
>> > think it necessary to use rt_task_shadow or such like in it.
>>
>> rt_task_shadow() is required if you call blocking services like
>> rt_task_wait_period from a task AND you didn't create it via some other
>> native service (rt_task_spawn or rt_task_create/start).
> Well then my code should be correct.
> 
> 
>> If the problem persists even with clean rt_task setup (rt_task_shadow
>> etc.), I guess it's best you post your code.
> Without changing my code I cannot repeat the behavior myself. Very
> strange. I have tried just about everything but after starting up the
> PC this morning there is no way I can repeat the behaviour I describe
> above.
> 
> So the can_write seems to be working for now. If it happens again I
> will post the code.
> 
> 
> I have more of a problem with reading. I am doing something wrong. The
> program does not return from the call rt_dev_recvfrom. Below is the
> simple read function I am presuming that whatever I am doing wrong
> will be blatantly obvious to all except me:)

At least it is not as in rtcanrecv.c ;-)

> void can_read(const char * device, can_frame_t * frame){
> 
>     int  ret;
>        struct ifreq ifr;
>     struct sockaddr_can addr;
>        socklen_t addrlen = sizeof(addr);
>     struct sockaddr_can recv_addr;
> 
>     strncpy(ifr.ifr_name, device, IFNAMSIZ);
>     ret = rt_dev_ioctl(can_fd, SIOCGIFINDEX, &ifr);
>     if (ret < 0) {
>         fprintf(stderr, "rt_dev_ioctl get index: %s\n", strerror(-ret));
>         return;
>     }
> 
>     recv_addr.can_family = AF_CAN;
>        recv_addr.can_ifindex = ifr.ifr_ifindex;
>        ret = rt_dev_bind(can_fd, (struct sockaddr *)&recv_addr,
> sizeof(struct sockaddr_can));
> 
>     if (ret < 0) {
>         fprintf(stderr, "rt_dev_bind: %s\n", strerror(-ret));
>         return;
>     }

The above code should go to the initialization routine after calling 
rt_dev_socket(). Ohterwise you query and bind the device for every read.

> printf("going in");
>     ret = rt_dev_recvfrom(can_fd, (void *)frame, sizeof(can_frame_t), 0,
> (struct sockaddr *)&addr, &addrlen);
> printf("coming out");

You should check the return code of rt_dev_recvfrom(). And  as you are 
not interested in the destination address, rt_dev_recv() should already 
work.

Nevertheless, the above code should work.

Wolfgang.


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

* Re: [Xenomai-help] warnings and tangled threads.
  2007-02-28 13:53     ` Jan Kiszka
@ 2007-03-01 19:51       ` roland Tollenaar
  2007-03-01 20:27         ` Jan Kiszka
  2007-03-01 20:27         ` Dmitry Adamushko
  0 siblings, 2 replies; 9+ messages in thread
From: roland Tollenaar @ 2007-03-01 19:51 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai

Hi,

My hardware has arrived. Well some of it, the rest should be coming
tomorrow. So will be testing the CAN functionality for real if I
finally get some time to work on this project other than at night. :(

In the mean time I still wanted to squeeze in applying the patch
below. However it fails, says something like

Hunk1 failed at line 295
Hunk2 succeeded.......

1 out of 2 failed.

This is what I did:
Put your patch in a file rtdmpatch in the root of the install (not the
source) directory. Then ran
patch -p0 < rtdmpatch.

What am I doing wrong? Running it in the root of the source directory
won't make a difference will it?


Regards,

Roland.



> > This works for me here (and is a bit more telling as well):
> >
> > --- include/rtdm/rtdm.h (Revision 2265)
> > +++ include/rtdm/rtdm.h (Arbeitskopie)
> > @@ -295,13 +295,22 @@ static inline ssize_t rt_dev_recvfrom(in
> >                                        struct sockaddr *from,
> >                                        socklen_t *fromlen)
> >  {
> > -    struct iovec    iov = {buf, len};
> > -    struct msghdr   msg =
> > -        {from, (from != NULL) ? *fromlen : 0, &iov, 1, NULL, 0};
> > -    int             ret;
> > +    struct iovec iov = {
> > +        .iov_base = buf,
> > +        .iov_len = len
> > +    };
> > +    struct msghdr msg =
>                           ^^^
> Insert "{", or the kernel build breaks. :(
>
> > +        .msg_name = from,
> > +        .msg_namelen = from ? *fromlen : 0,
> > +        .msg_iov = &iov,
> > +        .msg_iovlen = 1,
> > +        .msg_control = NULL,
> > +        .msg_controllen = 0
> > +    };
> > +    int ret;
> >
> >      ret = rt_dev_recvmsg(fd, &msg, flags);
> > -    if ((ret >= 0) && (from != NULL))
> > +    if (ret >= 0 && from)
> >          *fromlen = msg.msg_namelen;
> >      return ret;
> >  }
> > @@ -345,9 +354,18 @@ static inline ssize_t rt_dev_sendto(int
> >                                      int flags, const struct sockaddr *to,
> >                                      socklen_t tolen)
> >  {
> > -    struct iovec    iov = {(void *)buf, len};
> > -    struct msghdr   msg =
> > -        {(struct sockaddr *)to, tolen, &iov, 1, NULL, 0};
> > +    struct iovec iov = {
> > +        .iov_base = (void *)buf,
> > +        .iov_len = len
> > +    };
> > +    struct msghdr msg = {
> > +        .msg_name = (struct sockaddr *)to,
> > +        .msg_namelen = tolen,
> > +        .msg_iov = &iov,
> > +        .msg_iovlen = 1,
> > +        .msg_control = NULL,
> > +        .msg_controllen = 0
> > +    };
> >
> >      return rt_dev_sendmsg(fd, &msg, flags);
> >  }
> >
> >
> > Can you confirm it?
> >
> > Jan
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Xenomai-help mailing list
> > Xenomai-help@domain.hid
> > https://mail.gna.org/listinfo/xenomai-help
>
>
>
>


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

* Re: [Xenomai-help] warnings and tangled threads.
  2007-03-01 19:51       ` roland Tollenaar
@ 2007-03-01 20:27         ` Jan Kiszka
  2007-03-01 20:27         ` Dmitry Adamushko
  1 sibling, 0 replies; 9+ messages in thread
From: Jan Kiszka @ 2007-03-01 20:27 UTC (permalink / raw)
  To: roland Tollenaar; +Cc: xenomai


[-- Attachment #1.1: Type: text/plain, Size: 873 bytes --]

roland Tollenaar wrote:
> Hi,
> 
> My hardware has arrived. Well some of it, the rest should be coming
> tomorrow. So will be testing the CAN functionality for real if I
> finally get some time to work on this project other than at night. :(
> 
> In the mean time I still wanted to squeeze in applying the patch
> below. However it fails, says something like
> 
> Hunk1 failed at line 295
> Hunk2 succeeded.......
> 
> 1 out of 2 failed.
> 
> This is what I did:
> Put your patch in a file rtdmpatch in the root of the install (not the
> source) directory. Then ran
> patch -p0 < rtdmpatch.
> 
> What am I doing wrong? Running it in the root of the source directory
> won't make a difference will it?
> 

Some mail clients tend to mess with inlined patches. I attached it as
file, applicable against v2.3.x (trunk already contain the fix).

Jan

[-- Attachment #1.2: rtdm-warning.patch --]
[-- Type: text/plain, Size: 1749 bytes --]

Index: include/rtdm/rtdm.h
===================================================================
--- include/rtdm/rtdm.h	(Revision 2270)
+++ include/rtdm/rtdm.h	(Arbeitskopie)
@@ -268,13 +268,22 @@ static inline ssize_t rt_dev_recvfrom(in
                                       struct sockaddr *from,
                                       socklen_t *fromlen)
 {
-    struct iovec    iov = {buf, len};
-    struct msghdr   msg =
-        {from, (from != NULL) ? *fromlen : 0, &iov, 1, NULL, 0};
-    int             ret;
+    struct iovec iov = {
+        .iov_base = buf,
+        .iov_len = len
+    };
+    struct msghdr msg = {
+        .msg_name = from,
+        .msg_namelen = from ? *fromlen : 0,
+        .msg_iov = &iov,
+        .msg_iovlen = 1,
+        .msg_control = NULL,
+        .msg_controllen = 0
+    };
+    int ret;
 
     ret = rt_dev_recvmsg(fd, &msg, flags);
-    if ((ret >= 0) && (from != NULL))
+    if (ret >= 0 && from)
         *fromlen = msg.msg_namelen;
     return ret;
 }
@@ -318,9 +327,18 @@ static inline ssize_t rt_dev_sendto(int 
                                     int flags, const struct sockaddr *to,
                                     socklen_t tolen)
 {
-    struct iovec    iov = {(void *)buf, len};
-    struct msghdr   msg =
-        {(struct sockaddr *)to, tolen, &iov, 1, NULL, 0};
+    struct iovec iov = {
+        .iov_base = (void *)buf,
+        .iov_len = len
+    };
+    struct msghdr msg = {
+        .msg_name = (struct sockaddr *)to,
+        .msg_namelen = tolen,
+        .msg_iov = &iov,
+        .msg_iovlen = 1,
+        .msg_control = NULL, 
+        .msg_controllen = 0
+    };
 
     return rt_dev_sendmsg(fd, &msg, flags);
 }

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

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

* Re: [Xenomai-help] warnings and tangled threads.
  2007-03-01 19:51       ` roland Tollenaar
  2007-03-01 20:27         ` Jan Kiszka
@ 2007-03-01 20:27         ` Dmitry Adamushko
  1 sibling, 0 replies; 9+ messages in thread
From: Dmitry Adamushko @ 2007-03-01 20:27 UTC (permalink / raw)
  To: roland Tollenaar; +Cc: Xenomai help

On 01/03/07, roland Tollenaar <rolandtollenaar@domain.hid> wrote:
> Hi,
>
> My hardware has arrived. Well some of it, the rest should be coming
> tomorrow. So will be testing the CAN functionality for real if I
> finally get some time to work on this project other than at night. :(
>
> In the mean time I still wanted to squeeze in applying the patch
> below. However it fails, says something like
>
> Hunk1 failed at line 295
> Hunk2 succeeded.......
>
> 1 out of 2 failed.

This likely indicates that your "target" file (the one to be patched)
and the one Jan used to generate this patch are of different versions
(different revisions). There must have been created a file with .rej
extension - in your case include/rtdm/rtdm.h.rej which contains a part
of the patch that has failed to apply.

Anyway, you can fix it manually. It doesn't require any knowledge of
quantum mechanics, really.

e.g.

> > > --- include/rtdm/rtdm.h (Revision 2265)
> > > +++ include/rtdm/rtdm.h (Arbeitskopie)

the file to be patched is include/rtdm/rtdm.h

> > > @@ -295,13 +295,22 @@ static inline ssize_t rt_dev_recvfrom(in
> > >                                        struct sockaddr *from,
> > >                                        socklen_t *fromlen)
> > >  {

The changes to be applied to rt_dev_recvfrom() (so search for this
function, presumably line 295 but can be different as e.g. patch
failed)

> > > -    struct iovec    iov = {buf, len};
> > > -    struct msghdr   msg =
> > > -        {from, (from != NULL) ? *fromlen : 0, &iov, 1, NULL, 0};
> > > -    int             ret;
> > > +    struct iovec iov = {
> > > +        .iov_base = buf,
> > > +        .iov_len = len
> > > +    };
> > > +    struct msghdr msg = {
> > > ...

In this function look for the line marked with '-' and replace them
with the ones marked with '+'. That's it.


-- 
Best regards,
Dmitry Adamushko


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

end of thread, other threads:[~2007-03-01 20:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-27 23:25 [Xenomai-help] warnings and tangled threads roland Tollenaar
2007-02-28  7:55 ` Jan Kiszka
2007-02-28  8:40   ` Jan Kiszka
2007-02-28 13:53     ` Jan Kiszka
2007-03-01 19:51       ` roland Tollenaar
2007-03-01 20:27         ` Jan Kiszka
2007-03-01 20:27         ` Dmitry Adamushko
2007-02-28 18:00   ` roland Tollenaar
2007-02-28 20:10     ` 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.