All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] message pipe stream test application
@ 2018-08-17 13:26 Pintu Kumar
  2018-08-20 13:48 ` Pintu Kumar
  0 siblings, 1 reply; 13+ messages in thread
From: Pintu Kumar @ 2018-08-17 13:26 UTC (permalink / raw)
  To: Xenomai@xenomai.org

Hi,

I wanted to understand how rt_pipe_stream works and how it can be useful.
I wanted to create a demo application using it.
But currently I could not figure out how to make use of it.

I saw a sample pipe application under: lib/alchemy/testsuite/pipe-1.c.
Based on this I am trying to create a new application that uses rt_pipe_stream.
The rt_pipe_stream is working fine, but I wanted to test the scenario
based on its description.

My understanding is that:
Regular thread keeps write one by one char to rtipc, and the real-time
task reads one char at a time. Then real-time task call rt_pipe_stream
which keeps storing the char.
Finally, when regular thread calls "read" then all the data from
stream will be read by the regular thread at once.

Hope my understanding is correct.
I want to prepare a sample application for the same.

If any reference for rt_pipe_stream is available please let me know.


Thanks,
Pintu


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

* Re: [Xenomai] message pipe stream test application
  2018-08-17 13:26 [Xenomai] message pipe stream test application Pintu Kumar
@ 2018-08-20 13:48 ` Pintu Kumar
  2018-08-20 16:40   ` Greg Gallagher
  0 siblings, 1 reply; 13+ messages in thread
From: Pintu Kumar @ 2018-08-20 13:48 UTC (permalink / raw)
  To: Xenomai@xenomai.org

Dear Greg,

If you have any idea can you please explain how rt_pipe_stream works
with an example.
I need to prepare a demo, to demonstrate the usefulness of rt_pipe_stream API.


Thanks,
Pintu
On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com> wrote:
>
> Hi,
>
> I wanted to understand how rt_pipe_stream works and how it can be useful.
> I wanted to create a demo application using it.
> But currently I could not figure out how to make use of it.
>
> I saw a sample pipe application under: lib/alchemy/testsuite/pipe-1.c.
> Based on this I am trying to create a new application that uses rt_pipe_stream.
> The rt_pipe_stream is working fine, but I wanted to test the scenario
> based on its description.
>
> My understanding is that:
> Regular thread keeps write one by one char to rtipc, and the real-time
> task reads one char at a time. Then real-time task call rt_pipe_stream
> which keeps storing the char.
> Finally, when regular thread calls "read" then all the data from
> stream will be read by the regular thread at once.
>
> Hope my understanding is correct.
> I want to prepare a sample application for the same.
>
> If any reference for rt_pipe_stream is available please let me know.
>
>
> Thanks,
> Pintu


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

* Re: [Xenomai] message pipe stream test application
  2018-08-20 13:48 ` Pintu Kumar
@ 2018-08-20 16:40   ` Greg Gallagher
  2018-08-20 18:02     ` Pintu Kumar
  0 siblings, 1 reply; 13+ messages in thread
From: Greg Gallagher @ 2018-08-20 16:40 UTC (permalink / raw)
  To: Pintu Kumar; +Cc: Xenomai@xenomai.org

On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> Dear Greg,
>
> If you have any idea can you please explain how rt_pipe_stream works
> with an example.
> I need to prepare a demo, to demonstrate the usefulness of rt_pipe_stream API.
>
>
> Thanks,
> Pintu
> On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com> wrote:
>>
>> Hi,
>>
>> I wanted to understand how rt_pipe_stream works and how it can be useful.
>> I wanted to create a demo application using it.
>> But currently I could not figure out how to make use of it.
>>
>> I saw a sample pipe application under: lib/alchemy/testsuite/pipe-1.c.
>> Based on this I am trying to create a new application that uses rt_pipe_stream.
>> The rt_pipe_stream is working fine, but I wanted to test the scenario
>> based on its description.
>>
>> My understanding is that:
>> Regular thread keeps write one by one char to rtipc, and the real-time
>> task reads one char at a time. Then real-time task call rt_pipe_stream
>> which keeps storing the char.
>> Finally, when regular thread calls "read" then all the data from
>> stream will be read by the regular thread at once.
>>
>> Hope my understanding is correct.
>> I want to prepare a sample application for the same.
>>
>> If any reference for rt_pipe_stream is available please let me know.
>>
>>
>> Thanks,
>> Pintu
>
> _______________________________________________
> Xenomai mailing list
> Xenomai@xenomai.org
> https://xenomai.org/mailman/listinfo/xenomai

HI,
  Do you want an explaination how they worked in cobalt or an
exaplaination of how to use them?

Thanks

Greg


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

* Re: [Xenomai] message pipe stream test application
  2018-08-20 16:40   ` Greg Gallagher
@ 2018-08-20 18:02     ` Pintu Kumar
  2018-08-20 18:42       ` Greg Gallagher
  0 siblings, 1 reply; 13+ messages in thread
From: Pintu Kumar @ 2018-08-20 18:02 UTC (permalink / raw)
  To: Greg Gallagher; +Cc: Xenomai@xenomai.org

May be both.
Specially I want to know how to use may use of rt_pipe_steam with a use
case example.

On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com> wrote:

> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> > Dear Greg,
> >
> > If you have any idea can you please explain how rt_pipe_stream works
> > with an example.
> > I need to prepare a demo, to demonstrate the usefulness of
> rt_pipe_stream API.
> >
> >
> > Thanks,
> > Pintu
> > On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
> wrote:
> >>
> >> Hi,
> >>
> >> I wanted to understand how rt_pipe_stream works and how it can be
> useful.
> >> I wanted to create a demo application using it.
> >> But currently I could not figure out how to make use of it.
> >>
> >> I saw a sample pipe application under: lib/alchemy/testsuite/pipe-1.c.
> >> Based on this I am trying to create a new application that uses
> rt_pipe_stream.
> >> The rt_pipe_stream is working fine, but I wanted to test the scenario
> >> based on its description.
> >>
> >> My understanding is that:
> >> Regular thread keeps write one by one char to rtipc, and the real-time
> >> task reads one char at a time. Then real-time task call rt_pipe_stream
> >> which keeps storing the char.
> >> Finally, when regular thread calls "read" then all the data from
> >> stream will be read by the regular thread at once.
> >>
> >> Hope my understanding is correct.
> >> I want to prepare a sample application for the same.
> >>
> >> If any reference for rt_pipe_stream is available please let me know.
> >>
> >>
> >> Thanks,
> >> Pintu
> >
> > _______________________________________________
> > Xenomai mailing list
> > Xenomai@xenomai.org
> > https://xenomai.org/mailman/listinfo/xenomai
>
> HI,
>   Do you want an explaination how they worked in cobalt or an
> exaplaination of how to use them?
>
> Thanks
>
> Greg
>

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

* Re: [Xenomai] message pipe stream test application
  2018-08-20 18:02     ` Pintu Kumar
@ 2018-08-20 18:42       ` Greg Gallagher
  2018-08-21  8:08         ` Philippe Gerum
  2018-08-21  8:09         ` Pintu Kumar
  0 siblings, 2 replies; 13+ messages in thread
From: Greg Gallagher @ 2018-08-20 18:42 UTC (permalink / raw)
  To: Pintu Kumar; +Cc: Xenomai@xenomai.org

On Mon, Aug 20, 2018 at 2:02 PM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> May be both.
> Specially I want to know how to use may use of rt_pipe_steam with a use case
> example.
>
>
> On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com> wrote:
>>
>> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
>> > Dear Greg,
>> >
>> > If you have any idea can you please explain how rt_pipe_stream works
>> > with an example.
>> > I need to prepare a demo, to demonstrate the usefulness of
>> > rt_pipe_stream API.
>> >
>> >
>> > Thanks,
>> > Pintu
>> > On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
>> > wrote:
>> >>
>> >> Hi,
>> >>
>> >> I wanted to understand how rt_pipe_stream works and how it can be
>> >> useful.
>> >> I wanted to create a demo application using it.
>> >> But currently I could not figure out how to make use of it.
>> >>
>> >> I saw a sample pipe application under: lib/alchemy/testsuite/pipe-1.c.
>> >> Based on this I am trying to create a new application that uses
>> >> rt_pipe_stream.
>> >> The rt_pipe_stream is working fine, but I wanted to test the scenario
>> >> based on its description.
>> >>
>> >> My understanding is that:
>> >> Regular thread keeps write one by one char to rtipc, and the real-time
>> >> task reads one char at a time. Then real-time task call rt_pipe_stream
>> >> which keeps storing the char.
>> >> Finally, when regular thread calls "read" then all the data from
>> >> stream will be read by the regular thread at once.
>> >>
>> >> Hope my understanding is correct.
>> >> I want to prepare a sample application for the same.
>> >>
>> >> If any reference for rt_pipe_stream is available please let me know.
>> >>
>> >>
>> >> Thanks,
>> >> Pintu
>> >
>> > _______________________________________________
>> > Xenomai mailing list
>> > Xenomai@xenomai.org
>> > https://xenomai.org/mailman/listinfo/xenomai
>>
>> HI,
>>   Do you want an explaination how they worked in cobalt or an
>> exaplaination of how to use them?
>>
>> Thanks
>>
>> Greg

Start here:

https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__pipe.html#ga29521cc898afa0069963964955167aa5

I'll see what I can for an example.

-Greg


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

* Re: [Xenomai] message pipe stream test application
  2018-08-20 18:42       ` Greg Gallagher
@ 2018-08-21  8:08         ` Philippe Gerum
  2018-08-21  8:09         ` Pintu Kumar
  1 sibling, 0 replies; 13+ messages in thread
From: Philippe Gerum @ 2018-08-21  8:08 UTC (permalink / raw)
  To: Greg Gallagher, Pintu Kumar; +Cc: Xenomai@xenomai.org


Hi Greg,

On 08/20/2018 08:42 PM, Greg Gallagher wrote:
> On Mon, Aug 20, 2018 at 2:02 PM, Pintu Kumar <pintu.ping@gmail.com> wrote:
>> May be both.
>> Specially I want to know how to use may use of rt_pipe_steam with a use case
>> example.
>>
>>
>> On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com> wrote:
>>>
>>> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
>>>> Dear Greg,
>>>>
>>>> If you have any idea can you please explain how rt_pipe_stream works
>>>> with an example.
>>>> I need to prepare a demo, to demonstrate the usefulness of
>>>> rt_pipe_stream API.
>>>>
>>>>
>>>> Thanks,
>>>> Pintu
>>>> On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I wanted to understand how rt_pipe_stream works and how it can be
>>>>> useful.
>>>>> I wanted to create a demo application using it.
>>>>> But currently I could not figure out how to make use of it.
>>>>>
>>>>> I saw a sample pipe application under: lib/alchemy/testsuite/pipe-1.c.
>>>>> Based on this I am trying to create a new application that uses
>>>>> rt_pipe_stream.
>>>>> The rt_pipe_stream is working fine, but I wanted to test the scenario
>>>>> based on its description.
>>>>>
>>>>> My understanding is that:
>>>>> Regular thread keeps write one by one char to rtipc, and the real-time
>>>>> task reads one char at a time. Then real-time task call rt_pipe_stream
>>>>> which keeps storing the char.
>>>>> Finally, when regular thread calls "read" then all the data from
>>>>> stream will be read by the regular thread at once.
>>>>>
>>>>> Hope my understanding is correct.
>>>>> I want to prepare a sample application for the same.
>>>>>
>>>>> If any reference for rt_pipe_stream is available please let me know.
>>>>>
>>>>>
>>>>> Thanks,
>>>>> Pintu
>>>>
>>>> _______________________________________________
>>>> Xenomai mailing list
>>>> Xenomai@xenomai.org
>>>> https://xenomai.org/mailman/listinfo/xenomai
>>>
>>> HI,
>>>   Do you want an explaination how they worked in cobalt or an
>>> exaplaination of how to use them?
>>>
>>> Thanks
>>>
>>> Greg
> 
> Start here:
> 
> https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__pipe.html#ga29521cc898afa0069963964955167aa5
> 
> I'll see what I can for an example.
> 

demo/posix/cobalt/xddp-stream.c implements such an example with the
POSIX API, based on RTDM's socket-based XDDP protocol. rt_pipe_stream()
is basically a wrapper around a XDDP socket, just like the rest of the
legacy RT_PIPE API.

-- 
Philippe.


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

* Re: [Xenomai] message pipe stream test application
  2018-08-20 18:42       ` Greg Gallagher
  2018-08-21  8:08         ` Philippe Gerum
@ 2018-08-21  8:09         ` Pintu Kumar
  2018-08-21 15:06           ` Pintu Kumar
  1 sibling, 1 reply; 13+ messages in thread
From: Pintu Kumar @ 2018-08-21  8:09 UTC (permalink / raw)
  To: Greg Gallagher; +Cc: Xenomai@xenomai.org

Dear Greg,

For your information, I already implemented sample application using
message pipe read/write API over RTIPC.
For the reference I saw lib/alchemy/testsuite/pipe-1.c

But now I wanted to use rt_pipe_stream and understand how it work.
Mainly what is the real difference between rt_pipe_write and
rt_pipe_stream, and how to implement such difference.
According to my experiment, both behaves almost the same for me.

I have read the description about rt_pipe_stream in the documentation.
I tried to implement the similar logic, but behavior is not same for me.

My understanding is that:
Regular thread keeps writing one by one char to rtipc, and the real-time
task reads one char at a time. Then real-time task call rt_pipe_stream
which keeps storing all the characters until read is called.

Finally, when regular thread calls "read" then all the data from
stream will be read by the regular thread at once.

I implemented it in similar way, but in the end regular thread could
read only one char (first char) in the end.


Thanks,
Pintu
On Tue, Aug 21, 2018 at 12:12 AM Greg Gallagher <greg@embeddedgreg.com> wrote:
>
> On Mon, Aug 20, 2018 at 2:02 PM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> > May be both.
> > Specially I want to know how to use may use of rt_pipe_steam with a use case
> > example.
> >
> >
> > On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com> wrote:
> >>
> >> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> >> > Dear Greg,
> >> >
> >> > If you have any idea can you please explain how rt_pipe_stream works
> >> > with an example.
> >> > I need to prepare a demo, to demonstrate the usefulness of
> >> > rt_pipe_stream API.
> >> >
> >> >
> >> > Thanks,
> >> > Pintu
> >> > On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
> >> > wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> I wanted to understand how rt_pipe_stream works and how it can be
> >> >> useful.
> >> >> I wanted to create a demo application using it.
> >> >> But currently I could not figure out how to make use of it.
> >> >>
> >> >> I saw a sample pipe application under: lib/alchemy/testsuite/pipe-1.c.
> >> >> Based on this I am trying to create a new application that uses
> >> >> rt_pipe_stream.
> >> >> The rt_pipe_stream is working fine, but I wanted to test the scenario
> >> >> based on its description.
> >> >>
> >> >> My understanding is that:
> >> >> Regular thread keeps write one by one char to rtipc, and the real-time
> >> >> task reads one char at a time. Then real-time task call rt_pipe_stream
> >> >> which keeps storing the char.
> >> >> Finally, when regular thread calls "read" then all the data from
> >> >> stream will be read by the regular thread at once.
> >> >>
> >> >> Hope my understanding is correct.
> >> >> I want to prepare a sample application for the same.
> >> >>
> >> >> If any reference for rt_pipe_stream is available please let me know.
> >> >>
> >> >>
> >> >> Thanks,
> >> >> Pintu
> >> >
> >> > _______________________________________________
> >> > Xenomai mailing list
> >> > Xenomai@xenomai.org
> >> > https://xenomai.org/mailman/listinfo/xenomai
> >>
> >> HI,
> >>   Do you want an explaination how they worked in cobalt or an
> >> exaplaination of how to use them?
> >>
> >> Thanks
> >>
> >> Greg
>
> Start here:
>
> https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__pipe.html#ga29521cc898afa0069963964955167aa5
>
> I'll see what I can for an example.
>
> -Greg


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

* Re: [Xenomai] message pipe stream test application
  2018-08-21  8:09         ` Pintu Kumar
@ 2018-08-21 15:06           ` Pintu Kumar
  2018-08-21 16:01             ` Greg Gallagher
  0 siblings, 1 reply; 13+ messages in thread
From: Pintu Kumar @ 2018-08-21 15:06 UTC (permalink / raw)
  To: Greg Gallagher; +Cc: Xenomai@xenomai.org

Hi,

This is the technique I am using:

struct pipe_message {
        char value[32];
};

volatile int terminate = 0;

realtime_task()
{
     ret = rt_pipe_bind(&mpipe, "pipe", TM_INFINITE);
     while (!terminate) {
          ret = rt_pipe_read(&mpipe, &msg, sizeof(msg), TM_INFINITE);
          printf("%s: rt_pipe_read: value: %c\n", __func__, msg.value[i]);
          ret = rt_pipe_stream(&mpipe, &msg, sizeof(msg));
          i++;
     }
     rt_pipe_unbind(&mpipe);
     pthread_cancel(t_reg);
}

regular_thread(void *arg)
{
     char string[] = "realtime";
     sprintf(device, "/dev/rtp%d", minor);
     fd = open(device, O_RDWR);
     for (read char by char from a string) {
            msg.value[i] = ch;
            ret = write(fd, &msg, sizeof(msg));
            usleep(SLEEP_INTERVAL * MILLI_SECOND);
            i++;
     }
     terminate = 1;
     ret = read(fd, &msg, sizeof(msg));
     printf("%s: read: value: %s\n", __func__, msg.value);
}

With this I want to read all the rt_pipe_stream message at once in regular
thread.
Is this the correct way to implement stream ?
Or, please suggest how to modify this code to make stream work, which
behavior should be different from normal rt_pipe_write.

Currently, with this implement, only the first byte is getting printed
after the read, in regular thread.
I want the the whole stream of characters should be printed at once.


Thanks,
Pintu

On Tue, Aug 21, 2018 at 1:39 PM Pintu Kumar <pintu.ping@gmail.com> wrote:

> Dear Greg,
>
> For your information, I already implemented sample application using
> message pipe read/write API over RTIPC.
> For the reference I saw lib/alchemy/testsuite/pipe-1.c
>
> But now I wanted to use rt_pipe_stream and understand how it work.
> Mainly what is the real difference between rt_pipe_write and
> rt_pipe_stream, and how to implement such difference.
> According to my experiment, both behaves almost the same for me.
>
> I have read the description about rt_pipe_stream in the documentation.
> I tried to implement the similar logic, but behavior is not same for me.
>
> My understanding is that:
> Regular thread keeps writing one by one char to rtipc, and the real-time
> task reads one char at a time. Then real-time task call rt_pipe_stream
> which keeps storing all the characters until read is called.
>
> Finally, when regular thread calls "read" then all the data from
> stream will be read by the regular thread at once.
>
> I implemented it in similar way, but in the end regular thread could
> read only one char (first char) in the end.
>
>
> Thanks,
> Pintu
> On Tue, Aug 21, 2018 at 12:12 AM Greg Gallagher <greg@embeddedgreg.com>
> wrote:
> >
> > On Mon, Aug 20, 2018 at 2:02 PM, Pintu Kumar <pintu.ping@gmail.com>
> wrote:
> > > May be both.
> > > Specially I want to know how to use may use of rt_pipe_steam with a
> use case
> > > example.
> > >
> > >
> > > On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com>
> wrote:
> > >>
> > >> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com>
> wrote:
> > >> > Dear Greg,
> > >> >
> > >> > If you have any idea can you please explain how rt_pipe_stream works
> > >> > with an example.
> > >> > I need to prepare a demo, to demonstrate the usefulness of
> > >> > rt_pipe_stream API.
> > >> >
> > >> >
> > >> > Thanks,
> > >> > Pintu
> > >> > On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
> > >> > wrote:
> > >> >>
> > >> >> Hi,
> > >> >>
> > >> >> I wanted to understand how rt_pipe_stream works and how it can be
> > >> >> useful.
> > >> >> I wanted to create a demo application using it.
> > >> >> But currently I could not figure out how to make use of it.
> > >> >>
> > >> >> I saw a sample pipe application under:
> lib/alchemy/testsuite/pipe-1.c.
> > >> >> Based on this I am trying to create a new application that uses
> > >> >> rt_pipe_stream.
> > >> >> The rt_pipe_stream is working fine, but I wanted to test the
> scenario
> > >> >> based on its description.
> > >> >>
> > >> >> My understanding is that:
> > >> >> Regular thread keeps write one by one char to rtipc, and the
> real-time
> > >> >> task reads one char at a time. Then real-time task call
> rt_pipe_stream
> > >> >> which keeps storing the char.
> > >> >> Finally, when regular thread calls "read" then all the data from
> > >> >> stream will be read by the regular thread at once.
> > >> >>
> > >> >> Hope my understanding is correct.
> > >> >> I want to prepare a sample application for the same.
> > >> >>
> > >> >> If any reference for rt_pipe_stream is available please let me
> know.
> > >> >>
> > >> >>
> > >> >> Thanks,
> > >> >> Pintu
> > >> >
> > >> > _______________________________________________
> > >> > Xenomai mailing list
> > >> > Xenomai@xenomai.org
> > >> > https://xenomai.org/mailman/listinfo/xenomai
> > >>
> > >> HI,
> > >>   Do you want an explaination how they worked in cobalt or an
> > >> exaplaination of how to use them?
> > >>
> > >> Thanks
> > >>
> > >> Greg
> >
> > Start here:
> >
> >
> https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__pipe.html#ga29521cc898afa0069963964955167aa5
> >
> > I'll see what I can for an example.
> >
> > -Greg
>

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

* Re: [Xenomai] message pipe stream test application
  2018-08-21 15:06           ` Pintu Kumar
@ 2018-08-21 16:01             ` Greg Gallagher
  2018-08-21 17:47               ` Pintu Kumar
  0 siblings, 1 reply; 13+ messages in thread
From: Greg Gallagher @ 2018-08-21 16:01 UTC (permalink / raw)
  To: Pintu Kumar; +Cc: Xenomai@xenomai.org

HI,
  I"m not sure if I understand how you are using stream.   Stream
stores data in an internal buffer until the reciever wakes up and
reads the data.  Your telling read just to read one message, usually I
loop through the messages until read blocks again.  Are you trying to
read all the messages you sent to the pipe using stream in a single
read?
-Greg

On Tue, Aug 21, 2018 at 11:06 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> Hi,
>
> This is the technique I am using:
>
> struct pipe_message {
>         char value[32];
> };
>
> volatile int terminate = 0;
>
> realtime_task()
> {
>      ret = rt_pipe_bind(&mpipe, "pipe", TM_INFINITE);
>      while (!terminate) {
>           ret = rt_pipe_read(&mpipe, &msg, sizeof(msg), TM_INFINITE);
>           printf("%s: rt_pipe_read: value: %c\n", __func__, msg.value[i]);
>           ret = rt_pipe_stream(&mpipe, &msg, sizeof(msg));
>           i++;
>      }
>      rt_pipe_unbind(&mpipe);
>      pthread_cancel(t_reg);
> }
>
> regular_thread(void *arg)
> {
>      char string[] = "realtime";
>      sprintf(device, "/dev/rtp%d", minor);
>      fd = open(device, O_RDWR);
>      for (read char by char from a string) {
>             msg.value[i] = ch;
>             ret = write(fd, &msg, sizeof(msg));
>             usleep(SLEEP_INTERVAL * MILLI_SECOND);
>             i++;
>      }
>      terminate = 1;
>      ret = read(fd, &msg, sizeof(msg));
>      printf("%s: read: value: %s\n", __func__, msg.value);
> }
>
> With this I want to read all the rt_pipe_stream message at once in regular
> thread.
> Is this the correct way to implement stream ?
> Or, please suggest how to modify this code to make stream work, which
> behavior should be different from normal rt_pipe_write.
>
> Currently, with this implement, only the first byte is getting printed after
> the read, in regular thread.
> I want the the whole stream of characters should be printed at once.
>
>
> Thanks,
> Pintu
>
> On Tue, Aug 21, 2018 at 1:39 PM Pintu Kumar <pintu.ping@gmail.com> wrote:
>>
>> Dear Greg,
>>
>> For your information, I already implemented sample application using
>> message pipe read/write API over RTIPC.
>> For the reference I saw lib/alchemy/testsuite/pipe-1.c
>>
>> But now I wanted to use rt_pipe_stream and understand how it work.
>> Mainly what is the real difference between rt_pipe_write and
>> rt_pipe_stream, and how to implement such difference.
>> According to my experiment, both behaves almost the same for me.
>>
>> I have read the description about rt_pipe_stream in the documentation.
>> I tried to implement the similar logic, but behavior is not same for me.
>>
>> My understanding is that:
>> Regular thread keeps writing one by one char to rtipc, and the real-time
>> task reads one char at a time. Then real-time task call rt_pipe_stream
>> which keeps storing all the characters until read is called.
>>
>> Finally, when regular thread calls "read" then all the data from
>> stream will be read by the regular thread at once.
>>
>> I implemented it in similar way, but in the end regular thread could
>> read only one char (first char) in the end.
>>
>>
>> Thanks,
>> Pintu
>> On Tue, Aug 21, 2018 at 12:12 AM Greg Gallagher <greg@embeddedgreg.com>
>> wrote:
>> >
>> > On Mon, Aug 20, 2018 at 2:02 PM, Pintu Kumar <pintu.ping@gmail.com>
>> > wrote:
>> > > May be both.
>> > > Specially I want to know how to use may use of rt_pipe_steam with a
>> > > use case
>> > > example.
>> > >
>> > >
>> > > On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com>
>> > > wrote:
>> > >>
>> > >> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com>
>> > >> wrote:
>> > >> > Dear Greg,
>> > >> >
>> > >> > If you have any idea can you please explain how rt_pipe_stream
>> > >> > works
>> > >> > with an example.
>> > >> > I need to prepare a demo, to demonstrate the usefulness of
>> > >> > rt_pipe_stream API.
>> > >> >
>> > >> >
>> > >> > Thanks,
>> > >> > Pintu
>> > >> > On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
>> > >> > wrote:
>> > >> >>
>> > >> >> Hi,
>> > >> >>
>> > >> >> I wanted to understand how rt_pipe_stream works and how it can be
>> > >> >> useful.
>> > >> >> I wanted to create a demo application using it.
>> > >> >> But currently I could not figure out how to make use of it.
>> > >> >>
>> > >> >> I saw a sample pipe application under:
>> > >> >> lib/alchemy/testsuite/pipe-1.c.
>> > >> >> Based on this I am trying to create a new application that uses
>> > >> >> rt_pipe_stream.
>> > >> >> The rt_pipe_stream is working fine, but I wanted to test the
>> > >> >> scenario
>> > >> >> based on its description.
>> > >> >>
>> > >> >> My understanding is that:
>> > >> >> Regular thread keeps write one by one char to rtipc, and the
>> > >> >> real-time
>> > >> >> task reads one char at a time. Then real-time task call
>> > >> >> rt_pipe_stream
>> > >> >> which keeps storing the char.
>> > >> >> Finally, when regular thread calls "read" then all the data from
>> > >> >> stream will be read by the regular thread at once.
>> > >> >>
>> > >> >> Hope my understanding is correct.
>> > >> >> I want to prepare a sample application for the same.
>> > >> >>
>> > >> >> If any reference for rt_pipe_stream is available please let me
>> > >> >> know.
>> > >> >>
>> > >> >>
>> > >> >> Thanks,
>> > >> >> Pintu
>> > >> >
>> > >> > _______________________________________________
>> > >> > Xenomai mailing list
>> > >> > Xenomai@xenomai.org
>> > >> > https://xenomai.org/mailman/listinfo/xenomai
>> > >>
>> > >> HI,
>> > >>   Do you want an explaination how they worked in cobalt or an
>> > >> exaplaination of how to use them?
>> > >>
>> > >> Thanks
>> > >>
>> > >> Greg
>> >
>> > Start here:
>> >
>> >
>> > https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__pipe.html#ga29521cc898afa0069963964955167aa5
>> >
>> > I'll see what I can for an example.
>> >
>> > -Greg


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

* Re: [Xenomai] message pipe stream test application
  2018-08-21 16:01             ` Greg Gallagher
@ 2018-08-21 17:47               ` Pintu Kumar
  2018-08-21 18:15                 ` Greg Gallagher
  2018-08-22  5:19                 ` Greg Gallagher
  0 siblings, 2 replies; 13+ messages in thread
From: Pintu Kumar @ 2018-08-21 17:47 UTC (permalink / raw)
  To: Greg Gallagher; +Cc: Xenomai@xenomai.org

On Tue, Aug 21, 2018 at 9:32 PM Greg Gallagher <greg@embeddedgreg.com> wrote:
>
> HI,
>   I"m not sure if I understand how you are using stream.   Stream
> stores data in an internal buffer until the reciever wakes up and
> reads the data.

Yes I read this in the API description.
But how this is different from normal write.
I found the same behavior.

> Your telling read just to read one message, usually I
> loop through the messages until read blocks again.
Yes this way it works, but then what is the difference here with
normal read, if we keep reading the message at the same time.

> Are you trying to
> read all the messages you sent to the pipe using stream in a single
> read?
Yes, exactly.
I though that is the purpose of streaming a messages.

I just want to create a scenario in which rt_pipe_stream works but
rt_pipe_write cannot.
Hope to demonstrate this?

> -Greg
>
> On Tue, Aug 21, 2018 at 11:06 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> > Hi,
> >
> > This is the technique I am using:
> >
> > struct pipe_message {
> >         char value[32];
> > };
> >
> > volatile int terminate = 0;
> >
> > realtime_task()
> > {
> >      ret = rt_pipe_bind(&mpipe, "pipe", TM_INFINITE);
> >      while (!terminate) {
> >           ret = rt_pipe_read(&mpipe, &msg, sizeof(msg), TM_INFINITE);
> >           printf("%s: rt_pipe_read: value: %c\n", __func__, msg.value[i]);
> >           ret = rt_pipe_stream(&mpipe, &msg, sizeof(msg));
> >           i++;
> >      }
> >      rt_pipe_unbind(&mpipe);
> >      pthread_cancel(t_reg);
> > }
> >
> > regular_thread(void *arg)
> > {
> >      char string[] = "realtime";
> >      sprintf(device, "/dev/rtp%d", minor);
> >      fd = open(device, O_RDWR);
> >      for (read char by char from a string) {
> >             msg.value[i] = ch;
> >             ret = write(fd, &msg, sizeof(msg));
> >             usleep(SLEEP_INTERVAL * MILLI_SECOND);
> >             i++;
> >      }
> >      terminate = 1;
> >      ret = read(fd, &msg, sizeof(msg));
> >      printf("%s: read: value: %s\n", __func__, msg.value);
> > }
> >
> > With this I want to read all the rt_pipe_stream message at once in regular
> > thread.
> > Is this the correct way to implement stream ?
> > Or, please suggest how to modify this code to make stream work, which
> > behavior should be different from normal rt_pipe_write.
> >
> > Currently, with this implement, only the first byte is getting printed after
> > the read, in regular thread.
> > I want the the whole stream of characters should be printed at once.
> >
> >
> > Thanks,
> > Pintu
> >
> > On Tue, Aug 21, 2018 at 1:39 PM Pintu Kumar <pintu.ping@gmail.com> wrote:
> >>
> >> Dear Greg,
> >>
> >> For your information, I already implemented sample application using
> >> message pipe read/write API over RTIPC.
> >> For the reference I saw lib/alchemy/testsuite/pipe-1.c
> >>
> >> But now I wanted to use rt_pipe_stream and understand how it work.
> >> Mainly what is the real difference between rt_pipe_write and
> >> rt_pipe_stream, and how to implement such difference.
> >> According to my experiment, both behaves almost the same for me.
> >>
> >> I have read the description about rt_pipe_stream in the documentation.
> >> I tried to implement the similar logic, but behavior is not same for me.
> >>
> >> My understanding is that:
> >> Regular thread keeps writing one by one char to rtipc, and the real-time
> >> task reads one char at a time. Then real-time task call rt_pipe_stream
> >> which keeps storing all the characters until read is called.
> >>
> >> Finally, when regular thread calls "read" then all the data from
> >> stream will be read by the regular thread at once.
> >>
> >> I implemented it in similar way, but in the end regular thread could
> >> read only one char (first char) in the end.
> >>
> >>
> >> Thanks,
> >> Pintu
> >> On Tue, Aug 21, 2018 at 12:12 AM Greg Gallagher <greg@embeddedgreg.com>
> >> wrote:
> >> >
> >> > On Mon, Aug 20, 2018 at 2:02 PM, Pintu Kumar <pintu.ping@gmail.com>
> >> > wrote:
> >> > > May be both.
> >> > > Specially I want to know how to use may use of rt_pipe_steam with a
> >> > > use case
> >> > > example.
> >> > >
> >> > >
> >> > > On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com>
> >> > > wrote:
> >> > >>
> >> > >> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com>
> >> > >> wrote:
> >> > >> > Dear Greg,
> >> > >> >
> >> > >> > If you have any idea can you please explain how rt_pipe_stream
> >> > >> > works
> >> > >> > with an example.
> >> > >> > I need to prepare a demo, to demonstrate the usefulness of
> >> > >> > rt_pipe_stream API.
> >> > >> >
> >> > >> >
> >> > >> > Thanks,
> >> > >> > Pintu
> >> > >> > On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
> >> > >> > wrote:
> >> > >> >>
> >> > >> >> Hi,
> >> > >> >>
> >> > >> >> I wanted to understand how rt_pipe_stream works and how it can be
> >> > >> >> useful.
> >> > >> >> I wanted to create a demo application using it.
> >> > >> >> But currently I could not figure out how to make use of it.
> >> > >> >>
> >> > >> >> I saw a sample pipe application under:
> >> > >> >> lib/alchemy/testsuite/pipe-1.c.
> >> > >> >> Based on this I am trying to create a new application that uses
> >> > >> >> rt_pipe_stream.
> >> > >> >> The rt_pipe_stream is working fine, but I wanted to test the
> >> > >> >> scenario
> >> > >> >> based on its description.
> >> > >> >>
> >> > >> >> My understanding is that:
> >> > >> >> Regular thread keeps write one by one char to rtipc, and the
> >> > >> >> real-time
> >> > >> >> task reads one char at a time. Then real-time task call
> >> > >> >> rt_pipe_stream
> >> > >> >> which keeps storing the char.
> >> > >> >> Finally, when regular thread calls "read" then all the data from
> >> > >> >> stream will be read by the regular thread at once.
> >> > >> >>
> >> > >> >> Hope my understanding is correct.
> >> > >> >> I want to prepare a sample application for the same.
> >> > >> >>
> >> > >> >> If any reference for rt_pipe_stream is available please let me
> >> > >> >> know.
> >> > >> >>
> >> > >> >>
> >> > >> >> Thanks,
> >> > >> >> Pintu
> >> > >> >
> >> > >> > _______________________________________________
> >> > >> > Xenomai mailing list
> >> > >> > Xenomai@xenomai.org
> >> > >> > https://xenomai.org/mailman/listinfo/xenomai
> >> > >>
> >> > >> HI,
> >> > >>   Do you want an explaination how they worked in cobalt or an
> >> > >> exaplaination of how to use them?
> >> > >>
> >> > >> Thanks
> >> > >>
> >> > >> Greg
> >> >
> >> > Start here:
> >> >
> >> >
> >> > https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__pipe.html#ga29521cc898afa0069963964955167aa5
> >> >
> >> > I'll see what I can for an example.
> >> >
> >> > -Greg


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

* Re: [Xenomai] message pipe stream test application
  2018-08-21 17:47               ` Pintu Kumar
@ 2018-08-21 18:15                 ` Greg Gallagher
  2018-08-22  5:19                 ` Greg Gallagher
  1 sibling, 0 replies; 13+ messages in thread
From: Greg Gallagher @ 2018-08-21 18:15 UTC (permalink / raw)
  To: Pintu Kumar; +Cc: Xenomai@xenomai.org

On Tue, Aug 21, 2018 at 1:47 PM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> On Tue, Aug 21, 2018 at 9:32 PM Greg Gallagher <greg@embeddedgreg.com> wrote:
>>
>> HI,
>>   I"m not sure if I understand how you are using stream.   Stream
>> stores data in an internal buffer until the reciever wakes up and
>> reads the data.
>
> Yes I read this in the API description.
> But how this is different from normal write.
> I found the same behavior.
>
>> Your telling read just to read one message, usually I
>> loop through the messages until read blocks again.
> Yes this way it works, but then what is the difference here with
> normal read, if we keep reading the message at the same time.
>
>> Are you trying to
>> read all the messages you sent to the pipe using stream in a single
>> read?
> Yes, exactly.
> I though that is the purpose of streaming a messages.
>
> I just want to create a scenario in which rt_pipe_stream works but
> rt_pipe_write cannot.
> Hope to demonstrate this?
>
>> -Greg
>>
>> On Tue, Aug 21, 2018 at 11:06 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
>> > Hi,
>> >
>> > This is the technique I am using:
>> >
>> > struct pipe_message {
>> >         char value[32];
>> > };
>> >
>> > volatile int terminate = 0;
>> >
>> > realtime_task()
>> > {
>> >      ret = rt_pipe_bind(&mpipe, "pipe", TM_INFINITE);
>> >      while (!terminate) {
>> >           ret = rt_pipe_read(&mpipe, &msg, sizeof(msg), TM_INFINITE);
>> >           printf("%s: rt_pipe_read: value: %c\n", __func__, msg.value[i]);
>> >           ret = rt_pipe_stream(&mpipe, &msg, sizeof(msg));
>> >           i++;
>> >      }
>> >      rt_pipe_unbind(&mpipe);
>> >      pthread_cancel(t_reg);
>> > }
>> >
>> > regular_thread(void *arg)
>> > {
>> >      char string[] = "realtime";
>> >      sprintf(device, "/dev/rtp%d", minor);
>> >      fd = open(device, O_RDWR);
>> >      for (read char by char from a string) {
>> >             msg.value[i] = ch;
>> >             ret = write(fd, &msg, sizeof(msg));
>> >             usleep(SLEEP_INTERVAL * MILLI_SECOND);
>> >             i++;
>> >      }
>> >      terminate = 1;
>> >      ret = read(fd, &msg, sizeof(msg));
>> >      printf("%s: read: value: %s\n", __func__, msg.value);
>> > }
>> >
>> > With this I want to read all the rt_pipe_stream message at once in regular
>> > thread.
>> > Is this the correct way to implement stream ?
>> > Or, please suggest how to modify this code to make stream work, which
>> > behavior should be different from normal rt_pipe_write.
>> >
>> > Currently, with this implement, only the first byte is getting printed after
>> > the read, in regular thread.
>> > I want the the whole stream of characters should be printed at once.
>> >
>> >
>> > Thanks,
>> > Pintu
>> >
>> > On Tue, Aug 21, 2018 at 1:39 PM Pintu Kumar <pintu.ping@gmail.com> wrote:
>> >>
>> >> Dear Greg,
>> >>
>> >> For your information, I already implemented sample application using
>> >> message pipe read/write API over RTIPC.
>> >> For the reference I saw lib/alchemy/testsuite/pipe-1.c
>> >>
>> >> But now I wanted to use rt_pipe_stream and understand how it work.
>> >> Mainly what is the real difference between rt_pipe_write and
>> >> rt_pipe_stream, and how to implement such difference.
>> >> According to my experiment, both behaves almost the same for me.
>> >>
>> >> I have read the description about rt_pipe_stream in the documentation.
>> >> I tried to implement the similar logic, but behavior is not same for me.
>> >>
>> >> My understanding is that:
>> >> Regular thread keeps writing one by one char to rtipc, and the real-time
>> >> task reads one char at a time. Then real-time task call rt_pipe_stream
>> >> which keeps storing all the characters until read is called.
>> >>
>> >> Finally, when regular thread calls "read" then all the data from
>> >> stream will be read by the regular thread at once.
>> >>
>> >> I implemented it in similar way, but in the end regular thread could
>> >> read only one char (first char) in the end.
>> >>
>> >>
>> >> Thanks,
>> >> Pintu
>> >> On Tue, Aug 21, 2018 at 12:12 AM Greg Gallagher <greg@embeddedgreg.com>
>> >> wrote:
>> >> >
>> >> > On Mon, Aug 20, 2018 at 2:02 PM, Pintu Kumar <pintu.ping@gmail.com>
>> >> > wrote:
>> >> > > May be both.
>> >> > > Specially I want to know how to use may use of rt_pipe_steam with a
>> >> > > use case
>> >> > > example.
>> >> > >
>> >> > >
>> >> > > On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com>
>> >> > > wrote:
>> >> > >>
>> >> > >> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com>
>> >> > >> wrote:
>> >> > >> > Dear Greg,
>> >> > >> >
>> >> > >> > If you have any idea can you please explain how rt_pipe_stream
>> >> > >> > works
>> >> > >> > with an example.
>> >> > >> > I need to prepare a demo, to demonstrate the usefulness of
>> >> > >> > rt_pipe_stream API.
>> >> > >> >
>> >> > >> >
>> >> > >> > Thanks,
>> >> > >> > Pintu
>> >> > >> > On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
>> >> > >> > wrote:
>> >> > >> >>
>> >> > >> >> Hi,
>> >> > >> >>
>> >> > >> >> I wanted to understand how rt_pipe_stream works and how it can be
>> >> > >> >> useful.
>> >> > >> >> I wanted to create a demo application using it.
>> >> > >> >> But currently I could not figure out how to make use of it.
>> >> > >> >>
>> >> > >> >> I saw a sample pipe application under:
>> >> > >> >> lib/alchemy/testsuite/pipe-1.c.
>> >> > >> >> Based on this I am trying to create a new application that uses
>> >> > >> >> rt_pipe_stream.
>> >> > >> >> The rt_pipe_stream is working fine, but I wanted to test the
>> >> > >> >> scenario
>> >> > >> >> based on its description.
>> >> > >> >>
>> >> > >> >> My understanding is that:
>> >> > >> >> Regular thread keeps write one by one char to rtipc, and the
>> >> > >> >> real-time
>> >> > >> >> task reads one char at a time. Then real-time task call
>> >> > >> >> rt_pipe_stream
>> >> > >> >> which keeps storing the char.
>> >> > >> >> Finally, when regular thread calls "read" then all the data from
>> >> > >> >> stream will be read by the regular thread at once.
>> >> > >> >>
>> >> > >> >> Hope my understanding is correct.
>> >> > >> >> I want to prepare a sample application for the same.
>> >> > >> >>
>> >> > >> >> If any reference for rt_pipe_stream is available please let me
>> >> > >> >> know.
>> >> > >> >>
>> >> > >> >>
>> >> > >> >> Thanks,
>> >> > >> >> Pintu
>> >> > >> >
>> >> > >> > _______________________________________________
>> >> > >> > Xenomai mailing list
>> >> > >> > Xenomai@xenomai.org
>> >> > >> > https://xenomai.org/mailman/listinfo/xenomai
>> >> > >>
>> >> > >> HI,
>> >> > >>   Do you want an explaination how they worked in cobalt or an
>> >> > >> exaplaination of how to use them?
>> >> > >>
>> >> > >> Thanks
>> >> > >>
>> >> > >> Greg
>> >> >
>> >> > Start here:
>> >> >
>> >> >
>> >> > https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__pipe.html#ga29521cc898afa0069963964955167aa5
>> >> >
>> >> > I'll see what I can for an example.
>> >> >
>> >> > -Greg

>From what I've seen it looks like you have this backwards.  Stream is
meant to send bytes from the rt side to the non-rt side, it makes the
pipe byte oriented. The non-rt side can still read the whole message
from the buffer. I'll work out a quick example later tonight.

-Greg


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

* Re: [Xenomai] message pipe stream test application
  2018-08-21 17:47               ` Pintu Kumar
  2018-08-21 18:15                 ` Greg Gallagher
@ 2018-08-22  5:19                 ` Greg Gallagher
  2018-08-22  8:37                   ` Pintu Kumar
  1 sibling, 1 reply; 13+ messages in thread
From: Greg Gallagher @ 2018-08-22  5:19 UTC (permalink / raw)
  To: Pintu Kumar; +Cc: Xenomai@xenomai.org

On Tue, Aug 21, 2018 at 1:47 PM, Pintu Kumar <pintu.ping@gmail.com> wrote:
> On Tue, Aug 21, 2018 at 9:32 PM Greg Gallagher <greg@embeddedgreg.com> wrote:
>>
>> HI,
>>   I"m not sure if I understand how you are using stream.   Stream
>> stores data in an internal buffer until the reciever wakes up and
>> reads the data.
>
> Yes I read this in the API description.
> But how this is different from normal write.
> I found the same behavior.
>
>> Your telling read just to read one message, usually I
>> loop through the messages until read blocks again.
> Yes this way it works, but then what is the difference here with
> normal read, if we keep reading the message at the same time.
>
>> Are you trying to
>> read all the messages you sent to the pipe using stream in a single
>> read?
> Yes, exactly.
> I though that is the purpose of streaming a messages.
>
> I just want to create a scenario in which rt_pipe_stream works but
> rt_pipe_write cannot.
> Hope to demonstrate this?
>
>> -Greg
>>
>> On Tue, Aug 21, 2018 at 11:06 AM, Pintu Kumar <pintu.ping@gmail.com> wrote:
>> > Hi,
>> >
>> > This is the technique I am using:
>> >
>> > struct pipe_message {
>> >         char value[32];
>> > };
>> >
>> > volatile int terminate = 0;
>> >
>> > realtime_task()
>> > {
>> >      ret = rt_pipe_bind(&mpipe, "pipe", TM_INFINITE);
>> >      while (!terminate) {
>> >           ret = rt_pipe_read(&mpipe, &msg, sizeof(msg), TM_INFINITE);
>> >           printf("%s: rt_pipe_read: value: %c\n", __func__, msg.value[i]);
>> >           ret = rt_pipe_stream(&mpipe, &msg, sizeof(msg));
>> >           i++;
>> >      }
>> >      rt_pipe_unbind(&mpipe);
>> >      pthread_cancel(t_reg);
>> > }
>> >
>> > regular_thread(void *arg)
>> > {
>> >      char string[] = "realtime";
>> >      sprintf(device, "/dev/rtp%d", minor);
>> >      fd = open(device, O_RDWR);
>> >      for (read char by char from a string) {
>> >             msg.value[i] = ch;
>> >             ret = write(fd, &msg, sizeof(msg));
>> >             usleep(SLEEP_INTERVAL * MILLI_SECOND);
>> >             i++;
>> >      }
>> >      terminate = 1;
>> >      ret = read(fd, &msg, sizeof(msg));
>> >      printf("%s: read: value: %s\n", __func__, msg.value);
>> > }
>> >
>> > With this I want to read all the rt_pipe_stream message at once in regular
>> > thread.
>> > Is this the correct way to implement stream ?
>> > Or, please suggest how to modify this code to make stream work, which
>> > behavior should be different from normal rt_pipe_write.
>> >
>> > Currently, with this implement, only the first byte is getting printed after
>> > the read, in regular thread.
>> > I want the the whole stream of characters should be printed at once.
>> >
>> >
>> > Thanks,
>> > Pintu
>> >
>> > On Tue, Aug 21, 2018 at 1:39 PM Pintu Kumar <pintu.ping@gmail.com> wrote:
>> >>
>> >> Dear Greg,
>> >>
>> >> For your information, I already implemented sample application using
>> >> message pipe read/write API over RTIPC.
>> >> For the reference I saw lib/alchemy/testsuite/pipe-1.c
>> >>
>> >> But now I wanted to use rt_pipe_stream and understand how it work.
>> >> Mainly what is the real difference between rt_pipe_write and
>> >> rt_pipe_stream, and how to implement such difference.
>> >> According to my experiment, both behaves almost the same for me.
>> >>
>> >> I have read the description about rt_pipe_stream in the documentation.
>> >> I tried to implement the similar logic, but behavior is not same for me.
>> >>
>> >> My understanding is that:
>> >> Regular thread keeps writing one by one char to rtipc, and the real-time
>> >> task reads one char at a time. Then real-time task call rt_pipe_stream
>> >> which keeps storing all the characters until read is called.
>> >>
>> >> Finally, when regular thread calls "read" then all the data from
>> >> stream will be read by the regular thread at once.
>> >>
>> >> I implemented it in similar way, but in the end regular thread could
>> >> read only one char (first char) in the end.
>> >>
>> >>
>> >> Thanks,
>> >> Pintu
>> >> On Tue, Aug 21, 2018 at 12:12 AM Greg Gallagher <greg@embeddedgreg.com>
>> >> wrote:
>> >> >
>> >> > On Mon, Aug 20, 2018 at 2:02 PM, Pintu Kumar <pintu.ping@gmail.com>
>> >> > wrote:
>> >> > > May be both.
>> >> > > Specially I want to know how to use may use of rt_pipe_steam with a
>> >> > > use case
>> >> > > example.
>> >> > >
>> >> > >
>> >> > > On Mon, 20 Aug 2018, 10:10 pm Greg Gallagher, <greg@embeddedgreg.com>
>> >> > > wrote:
>> >> > >>
>> >> > >> On Mon, Aug 20, 2018 at 9:48 AM, Pintu Kumar <pintu.ping@gmail.com>
>> >> > >> wrote:
>> >> > >> > Dear Greg,
>> >> > >> >
>> >> > >> > If you have any idea can you please explain how rt_pipe_stream
>> >> > >> > works
>> >> > >> > with an example.
>> >> > >> > I need to prepare a demo, to demonstrate the usefulness of
>> >> > >> > rt_pipe_stream API.
>> >> > >> >
>> >> > >> >
>> >> > >> > Thanks,
>> >> > >> > Pintu
>> >> > >> > On Fri, Aug 17, 2018 at 6:56 PM Pintu Kumar <pintu.ping@gmail.com>
>> >> > >> > wrote:
>> >> > >> >>
>> >> > >> >> Hi,
>> >> > >> >>
>> >> > >> >> I wanted to understand how rt_pipe_stream works and how it can be
>> >> > >> >> useful.
>> >> > >> >> I wanted to create a demo application using it.
>> >> > >> >> But currently I could not figure out how to make use of it.
>> >> > >> >>
>> >> > >> >> I saw a sample pipe application under:
>> >> > >> >> lib/alchemy/testsuite/pipe-1.c.
>> >> > >> >> Based on this I am trying to create a new application that uses
>> >> > >> >> rt_pipe_stream.
>> >> > >> >> The rt_pipe_stream is working fine, but I wanted to test the
>> >> > >> >> scenario
>> >> > >> >> based on its description.
>> >> > >> >>
>> >> > >> >> My understanding is that:
>> >> > >> >> Regular thread keeps write one by one char to rtipc, and the
>> >> > >> >> real-time
>> >> > >> >> task reads one char at a time. Then real-time task call
>> >> > >> >> rt_pipe_stream
>> >> > >> >> which keeps storing the char.
>> >> > >> >> Finally, when regular thread calls "read" then all the data from
>> >> > >> >> stream will be read by the regular thread at once.
>> >> > >> >>
>> >> > >> >> Hope my understanding is correct.
>> >> > >> >> I want to prepare a sample application for the same.
>> >> > >> >>
>> >> > >> >> If any reference for rt_pipe_stream is available please let me
>> >> > >> >> know.
>> >> > >> >>
>> >> > >> >>
>> >> > >> >> Thanks,
>> >> > >> >> Pintu
>> >> > >> >
>> >> > >> > _______________________________________________
>> >> > >> > Xenomai mailing list
>> >> > >> > Xenomai@xenomai.org
>> >> > >> > https://xenomai.org/mailman/listinfo/xenomai
>> >> > >>
>> >> > >> HI,
>> >> > >>   Do you want an explaination how they worked in cobalt or an
>> >> > >> exaplaination of how to use them?
>> >> > >>
>> >> > >> Thanks
>> >> > >>
>> >> > >> Greg
>> >> >
>> >> > Start here:
>> >> >
>> >> >
>> >> > https://xenomai.org/documentation/xenomai-3/html/xeno3prm/group__alchemy__pipe.html#ga29521cc898afa0069963964955167aa5
>> >> >
>> >> > I'll see what I can for an example.
>> >> >
>> >> > -Greg

For your example, you are sending a message in rt_pipe_stream not a
stream of bytes.  You'll need to change what you are sending in the
rt_pipe_stream call.  I have a rough example working, I should have
time to post it hopefully in the next few days.

-Greg


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

* Re: [Xenomai] message pipe stream test application
  2018-08-22  5:19                 ` Greg Gallagher
@ 2018-08-22  8:37                   ` Pintu Kumar
  0 siblings, 0 replies; 13+ messages in thread
From: Pintu Kumar @ 2018-08-22  8:37 UTC (permalink / raw)
  To: Greg Gallagher; +Cc: Xenomai@xenomai.org

On Wed, Aug 22, 2018 at 10:49 AM Greg Gallagher <greg@embeddedgreg.com> wrote:
>
>
> For your example, you are sending a message in rt_pipe_stream not a
> stream of bytes.  You'll need to change what you are sending in the
> rt_pipe_stream call.  I have a rough example working, I should have
> time to post it hopefully in the next few days.
>

Dear Greg, Thank you so much for the clue.
Yes, I could able to make it working, by changing the following:
ret = rt_pipe_stream(&mpipe, msg.value + i, 1);

Thus, each char is being streamed in the loop.
After both the loop terminates, I could read the whole stream messages
using single read command.

If you feel this could be one important demo. I can plan to contribute.
Similarly I developed 4 different patterns.

Thanks,
Pintu



> -Greg


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

end of thread, other threads:[~2018-08-22  8:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-17 13:26 [Xenomai] message pipe stream test application Pintu Kumar
2018-08-20 13:48 ` Pintu Kumar
2018-08-20 16:40   ` Greg Gallagher
2018-08-20 18:02     ` Pintu Kumar
2018-08-20 18:42       ` Greg Gallagher
2018-08-21  8:08         ` Philippe Gerum
2018-08-21  8:09         ` Pintu Kumar
2018-08-21 15:06           ` Pintu Kumar
2018-08-21 16:01             ` Greg Gallagher
2018-08-21 17:47               ` Pintu Kumar
2018-08-21 18:15                 ` Greg Gallagher
2018-08-22  5:19                 ` Greg Gallagher
2018-08-22  8:37                   ` Pintu Kumar

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.