hello
i use rtl3.0
i would like to use the real time signal in my module
i don't have problem with sigaction to install a signal, but when i try
to use sigqueue  i have this message:

intr_sick_arriere.o: unresolved symbol sigqueue
is it possible to use this function in rtmodule?
is there a function similar to getpid() to obtain the id of a module?
i have joined my code

thank you for your help




/************************ acquisition donnees sick sur com4 par interruption 
*************************/

#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <rtl_sync.h>
#include <rtl_core.h>
#include <rtl.h>
#include <asm/io.h>
#include <time.h>
#include <pthread.h>
#include <rtl_fifo.h>

#include "def_moxa.h"


#define adresse_base_com4 COM4

WORD dll_com4 = adresse_base_com4 + DLL;
WORD dlm_com4 = adresse_base_com4 + DLM;
WORD ier_com4 = adresse_base_com4 + IER;
WORD lcr_com4 = adresse_base_com4 + LCR;        
unsigned char test_com4[6];
unsigned char donnee_com4[732];
hrtime_t debut_com4;
int i_com4=0, j_com4=0;
int passage_com4=0;





void gestionnaire_signal_temps_reel (int numero, siginfo_t * info, void * inutile)
{
        rtl_printf("\n signal recu par le gestionnaire");
}






unsigned int handler_com4(void)
{ //WORD adresse_base_com4=COM4;
  unsigned char temp;
  unsigned int nouveau_debut=1;
  int test_rtf;
  int ro[361];
  hrtime_t temps_com4, tampon_temps_com4;
  double temps;


  outb(0x00,ier_com4);

//  do{
   temp = inb(adresse_base_com4);
  i_com4++;
//  rtl_printf("\n handler com4");
  if(i_com4==732)
  {     i_com4=0;
        tampon_temps_com4=clock_gethrtime(CLOCK_REALTIME);
        temps_com4=tampon_temps_com4-debut_com4;
        temps=(double)(temps_com4/1000000);

        rtl_printf("\n\n   arriere %ld passage %d",(long int)temps,passage_com4);
        envoie_signal_temps_reel(1,3);
        passage_com4++;
        if(passage_com4>10000)
                passage_com4=0;
        for (i_com4=0; i_com4<=720; i_com4+=2)
        {       ro[i_com4/2] = (donnee_com4[8+i_com4])+(256*(donnee_com4[9+i_com4]));
//              rtl_printf(" %d ",ro[i_com4/2]);
        }       
        i_com4=0;
  }
  test_com4[0]=test_com4[1];
  test_com4[1]=test_com4[2];
  test_com4[2]=test_com4[3];
  test_com4[3]=test_com4[4];
  test_com4[4]=test_com4[5];
  test_com4[5]=temp;

  if(test_com4[0]==0x02 && test_com4[1]==0x80 && test_com4[2]== 0xD6 && 
test_com4[3]==0x02
     && test_com4[4]==0xB0 && test_com4[5]==0x69 )
  {     for(j_com4=0; j_com4<6; j_com4++)
                donnee_com4[j_com4]=test_com4[j_com4];
        i_com4=j_com4;
        debut_com4=clock_gethrtime(CLOCK_REALTIME);     
                //rtl_printf(" %x ",test_com4[j_com4]);         
  }     
        
  donnee_com4[i_com4]=temp;     
        
        
// }while( ((inb((COM4)+5))&0x01)!=1);  

  outb(0x01,ier_com4);
  rtl_hard_enable_irq(7);


  return 0;
}


int init_module(void)
{

        int  Erreur = 0;
        BYTE i,tampon;
        rtl_irqstate_t f_com4;
        int test_irq=0;
        struct sigaction action;
        
        
        
        /* Nettoyage du port */
        for (i=0;i<=6;i++)
                inb(adresse_base_com4);
                
        outb(0x00,ier_com4);                    /* disable l'IT reception */
                /* Initialisation de la vitesse de communication */
        outb(0x80,lcr_com4);  /* LCR.7 = 1 */
        outb((B500ka & 255),dll_com4);  /* partie basse */
        outb(( B500ka>> 8),dlm_com4);   /* partie haute */
                /* Initialisation de la largeur du caractere, du bit de stop
        et de la parite */
        outb((  BIT_8 | (0 << 2) | (P_AUCUNE << 3) ),lcr_com4 );
        
        outb(0x02,adresse_base_com4 +2);        // Raz FIFO
        outb(0x01,adresse_base_com4 +2);        // val. FIFO mode DMA
//         outb(inb(adresse_base_com4 + MCR) | 0x08, adresse_base_com4 + MCR);
        outb(0x01,ier_com4);                    /* enable l'IT reception */
        inb(adresse_base_com4);   /* On vide RXD */
        inb(adresse_base_com4);

        


        rtl_no_interrupts(f_com4);


        rtl_request_irq(7,handler_com4);
        rtl_printf("\n test test_request_irq %d",test_irq);

        rtl_hard_enable_irq(7);
      //  rtl_printf("\n test hard_enable %d",test_irq);

        rtl_restore_interrupts(f_com4);
  //      rtl_printf("\n test restore %d",test_irq);

        rtl_printf("\n valeur de sigrtmin %d ",SIGRTMIN);
        rtl_printf("\n valeur de sigrtmax %d ",SIGRTMAX);       
        rtl_printf ("Installation gestionnaires de signaux\n");
        action . sa_sigaction = gestionnaire_signal_temps_reel;
        sigemptyset (& action . sa_mask);
        action . sa_flags = SA_SIGINFO;
        if ( sigaction (SIGRTMIN + 1, & action, NULL) < 0)
                rtl_printf("\n erreur installation sigaction");
        return 0;
}


void
envoie_signal_temps_reel (int numero, int valeur)
{
union sigval valeur_sig;

rtl_printf ( "Envoi signal SIRTMIN+%d, valeur %d\n",numero, valeur);
valeur_sig . sival_int = valeur;
if (sigqueue (getpid(), numero + SIGRTMIN, valeur_sig) < 0)
{
        rtl_printf("\n erreur sigqueue");
}

}


void cleanup_module(void)
{
  rtl_free_irq(7);
}

Reply via email to