Thanks Steve and Paolo

The code that Steve sent me works as expected for RTAI 0.7 as well
as 1.3. So obviously there is some little well hidden (to me anyways) thing 
wrong with my code that is preventing it from working as expected. I will 
let you know what it is when I find it since it
may come up again with others.

Daniel

>From: Steve Papacharalambous <[EMAIL PROTECTED]>
>To: daniel sheltraw <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTED], [EMAIL PROTECTED]
>Subject: Re: [rtl] RTAI rt_task_resume and fifo problem
>Date: Mon, 17 Jul 2000 10:53:39 +0100
>
>Hi Daniel,
>
>I tried your example on my system and the timing works as expected, ie I
>get an LED transition every 1 second.  I am using rtai-1.3 and
>Linux-2.2.14.  I have attached the code for the example that I used,
>hope that it helps,
>
>Best regards,
>
>Steve
>
>
>daniel sheltraw wrote:
> >
> > Steve and others
> >
> > I hope I don't have to take Victors suggestion just yet (but maybe).
> > Here is the pertinent code (obviously a highly edited version). The fifo
> > handler is:
> >
> > int start_fifo_handler(unsigned int)
> > {
> >   rtf_get(START_FIFO, &num_events, sizeof(int));
> >   rt_task_resume(&Task);
> >   return 1;
> > }
> >
> > and the task looks like this:
> >
> > static void task_fun(int task_arg)
> > {
> >   int n;
> >   RTIME time_incr = 1000000000;
> >
> >   rt_task_suspend(&Task); /*The task to be resumed through START_FIFO*/
> >
> >   /* oneshot mode task */
> >   start_time = rt_get_time();
> >   for(n=0; n<num_events; n++){
> >     rt_sleep_until(start_time + nano2count((n+1)*time_incr);
> >     /* Function to produce beeps on speaker on control an LED an
> >      the parallel port would go here*/
> >   }
> >   rt_task_suspend(&Task);
> > }
> >
> > A user-space write to the fifo does start the task and pass the 
>num_events
> > value to the kernel-module but the timing is all wrong.
> > As you can see the task should execute once per second but what I get
> > is once per 2 seconds. If I remove the first rt_task_suspend the timing
> > then works fine (but of course I can't start the task in the manner I 
>wanted
> > to).
> >
> > Thanks for any help,
> > Daniel
> >
> > >From: Steve Papacharalambous <[EMAIL PROTECTED]>
> > >To: daniel sheltraw <[EMAIL PROTECTED]>
> > >CC: [EMAIL PROTECTED]
> > >Subject: Re: [rtl] oneshot mode timing problem
> > >Date: Sun, 16 Jul 2000 08:18:14 +0100
> > >
> > >Hi Daniel,
> > >
> > >Can you send me the pertinent code please,
> > >
> > >Best regards,
> > >
> > >Steve
> > >
> > >
> > >daniel sheltraw wrote:
> > > >
> > > > Hello RT World
> > > >
> > > > I wrote to this mailing list previously with a somewhat less clear
> > >version
> > > > of this question. Please let me know if you need to see the 
>pertinent
> > >code
> > > > to help with this problem.
> > > >
> > > > In case it influences the answer to the following question let it be
> > >known
> > > > that I am using 0.7 RTAI (I know... I will upgrade soon especially 
>if
> > >the
> > > > 0.7 version is the source of my problem).
> > > >
> > > > I am using a fifo which when written to by a user-space program 
>passes a
> > > > single int and resumes a previously
> > > > suspended task (by using a fifo handler). The problem is that if I 
>use
> > > > sleep_until and program certain events to occur at 1 second 
>intervals
> > >when I
> > > > run the code I get 2 second intervals. If I omit the code from
> > >user-space
> > > > and the kernel module that uses the fifo to resume the task the
> > >timinging
> > > > works fine.
> > > >
> > > > So I guess my question is how can I properly resume a previous 
>suspended
> > > > task from within a fifo handler?
> > > >
> > > > Thanks all. Please bail me out again.
> > > > Daniel
> > ________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> >
> > -- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> > ---
> > For more information on Real-Time Linux see:
> > http://www.rtlinux.org/rtlinux/
>
>--
>
>Lineo Industrial Solutions Group
>Visit http://www.lineo.com/
>#include <linux/module.h>
>#include <linux/errno.h>
>#include <linux/sched.h>
>
>#include <asm/system.h>
>#include <asm/smp.h>
>#include <asm/bitops.h>
>#include <asm/io.h>
>
>#include <rtai.h>
>#include <rtai_sched.h>
>#include <rtai_fifos.h>
>
>RT_TASK Task;
>
>#define LPT_PORT 0x378
>
>static int num_events = 0;
>
>int start_fifo_handler(unsigned int arg)
>{
>   rtf_get(4, &num_events, sizeof(int));
>   rt_task_resume(&Task);
>   return 1;
>}
>
>
>static void task_fun(int task_arg)
>{
>   int n;
>   static int output = 0x0;
>   static RTIME start_time;
>   RTIME time_incr = 1000000000;
>
>   rt_task_suspend(&Task); /*The task to be resumed through START_FIFO*/
>
>   /* oneshot mode task */
>   start_time = rt_get_time();
>   for(n=0; n<num_events; n++) {
>     rt_sleep_until(start_time + nano2count((n+1)*time_incr));
>     /* Function to produce beeps on speaker on control an LED an
>      the parallel port would go here*/
>     output ^= 1;
>     outb(output, LPT_PORT);
>   }
>   rt_task_suspend(&Task);
>}
>
>
>// ------------------------------------------------------------------------
>
>int init_module(void)
>{
>       rtf_create(4, 100);
>       rt_task_init(&Task, task_fun, 0, 1000, 2, 0, 0);
>       rtf_create_handler(4, start_fifo_handler);
>       start_rt_timer_ns(1E8);
>         rt_task_resume(&Task);
>       return 0;
>}
>
>
>void cleanup_module(void)
>{
>       rtf_destroy(4);
>       stop_rt_timer();
>       rt_task_delete(&Task);
>}
>
>#include <stdio.h>
>#include <sys/types.h>
>#include <sys/stat.h>
>#include <fcntl.h>
>
>
>int main(int argc, char **argv) {
>
>   int rtf_fd;
>   int out_buf = 0;
>
>   if(argc == 2) {
>     out_buf = atoi(argv[1]);
>   } else {
>     out_buf = 10;
>   }
>
>   printf("%s - output buffer: %d\n", argv[0], out_buf);
>
>   if((rtf_fd = open("/dev/rtf4", O_RDWR)) < 0) {
>     perror("open");
>     exit(1);
>   }
>
>   if(write(rtf_fd, &out_buf, sizeof(out_buf)) < 0) {
>     perror("write");
>     exit(1);
>   }
>
>   close(rtf_fd);
>
>   printf("%s completed okay\n\n", argv[0]);
>
>}

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to