Leonardo Pappagallo wrote:
> hi,
> I have tried to use the Timeout handling for the function
> recvfrom_rt(...) in my code.
> But, when I start the program the function is always blocked, and my
> program doesn't stop. I'm working in user space.
> 
> my code is the next:
> 
> [...
> // set  time_out
>  TimeOut=500000000;           //500ms
>  ioctl_rt(udpSocket,RTNET_RTIOC_TIMEOUT,&TimeOut);
> 
>  // inizializzo il task real-time, tutti i metodi usati devono essere RT
>  task_rt = rt_task_init(4907,1,0,0);          //Id_Task, priorità, ...
>  if (task_rt==NULL)  // controllo che il task sia stato creato
>  {
>       close_rt(udpSocket);    //chiudo il socket
>       printf("task non creato\n");
>       exit(1);
>  }
> 
>  i=0;                 //i conta i segmenti
>  t_sum=0;
>  while (i<Npkt)  //aspetto l'invio di 10 segmenti 1200000
>  {    
>    *((long*)(&(Buffer[1])))=i;
>    rt_make_hard_real_time();
>    t_start=rt_get_time();
>    a=sendto_rt(udpSocket, Buffer, BufferLen,flags,
> (sockaddr*)&slaveAdrs,(socklen_t) sizeof(sockaddr));
>    // ricevo il segmento e lo reinvio al mittente
>    for (i_slave=0; i_slave<SLAVE;)      // I have 2 Slave
>    {
>       BufferLenRx=recvfrom_rt(udpSocket, BufferRx, sizeof(BufferRx),flags,
> (sockaddr*)&slaveRx,&lenRx );
>       if (BufferLenRx==ETIMEDOUT)
>       {//Time Out
>               rt_make_soft_real_time();
>               rt_task_delete(task_rt);
>               close_rt(udpSocket);            
>               printf("TimeOut %d\n",BufferLenRx);
>               exit(1);
>       }
>       //il confronto è tra due unsigned long
>       for(j_slave=0; j_slave<SLAVE; j_slave++)
>       {// controllo chi mi ha risposto
>               if (slaveRx.sin_addr.s_addr==slaveIP[j_slave])
>               {
>                       if (i==(*((long*)(&(BufferRx[1])))))
>                       {
>                               i_slave++;
>                               continue;
>                       }
>                       else
>                       {
>                               //errore uscita
>                               rt_make_soft_real_time();
>                               rt_task_delete(task_rt);
>                               close_rt(udpSocket);                            
>                               printf("dati errati\n");
>                               exit(1);
>                       }
>               }
>       }       
>    }
>    t_stop=rt_get_time();
>    rt_make_soft_real_time();
>    t_sum+=((long)count2nano(t_stop-t_start)/1000);
>    i++;
>  }
> 
> ...]
> 
> do you have any idea?

Typically a sign that the timer has not been started (start_rt_timer) or
stopped accidentally (if you are running RTmac/TDMA+RTcfg, the rtcfg
module will start the timer). Can't remember right now if RTAI provides
information about the current timer state via /proc/rtai as Xenomai does.

Jan

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to