Hello,

I'm trying to develop an interrupt-driven acquisition process that will read
data coming across my serial port on my pc.
I'm transmitting bytes from one computer to the other.  My RT Linux serial
driver is working fine, and I can send and receive data from one computer to
the other using a RT Linux thread scheduled to run every second. But when I
try this using interrupts,
problems occur.  The rtl_request_irq( ) and the rtl_hard_enable_irq( )
functions are working when they are called
from the init_module( ), but when I start transmitting data from my other
computer no interrupts are generated from my
acquisition process.  I have rtl_printf( ) statements in my module to
indicate if or when an interrupt is generated, but when I type "dmesg" there
is nothing displayed to indicate that interrupts are being generated.  I
have omitted the rtl_printf( ) statements in
my code below to make it more readable.  Could someone tell me if there is
anything I have left out of my module?  I'm sure there
is something missing from my code, but since I'm new to this interrupt
thing, I'm not sure what it is.  I have included my code 
below.  ( My trigger level is set to 16 in my rt_com.c module )  

Thank you very much,

Bill

pthread_t rttask;
rtl_irqstate_t f;

void thread_code(void *t)
{
   char buf[16];
   int n;

   while(1)
   {

      pthread_suspend_np(pthread_self());
      n=rt_com_read(0,buf,14);
   }

}


unsigned int my_intr_handler(unsigned int irq, struct pt_regs *regs)
{
   pthread_wakeup_np(rttask);
   rtl_hard_enable_irq(4);
   return 0;
}


int init_module(void)
{
   pthread_attr_t attr;
   struct sched_param sched_param;
   int status;
 
   status = rtl_request_irq(4, my_intr_handler);
   rtl_hard_enable_irq(4);

   pthread_attr_init(&attr);
   sched_param.sched_priority=1;
   pthread_attr_setschedparam(&attr,&sched_param);

   if ( !pthread_create(&rttask,&attr,thread_code,(void *)1) )
      rtl_printf("RT thread created successfully.\n");
   else
      rtl_printf("Error creating RT thread.\n");

   /**** Opening and setting up comm port ****/

   rt_com_setup(0,19200,RT_COM_PARITY_NONE,1,8);
   return 0;
}


void cleanup_module(void)
{
   rt_com_setup(0,-1,0,0,0);
   pthread_delete_np(rttask);
   rtl_free_irq(4);
}   
-- [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