• [^] # Re: Module noyau ?

    Posté par . En réponse au message IRQ en C. Évalué à 2.

    Déjà, fais un petit test en user-land avec select(), comme conseillé
    au-dessus.

    Un squelette écrit à la va-vite (désolé pas testé):

    fd_set rfds;
    int fd[4], max_fd = -1;

    fd[0] = open("/dev/ttyS0",O_RDWR,0600);
    fd[1] = open("/dev/ttyS1",O_RDWR,0600);
    fd[2] = open("/dev/ttyS2",O_RDWR,0600);
    fd[3] = open("/dev/ttyS3",O_RDWR,0600);

    for(i=0;i<4;i++)
    if (fd[i] > max_fd)
    max_fd = fd[i];

    while(1) {
    FD_ZERO(&rfds);
    for(i=0;i<4;i++) FD_SET(fd[i],&rfds);
    select(max_fd+1,&rfds,NULL,NULL,NULL);

    for(i=0;i<4;i++)
    {
    if (FD_ISSET(fd[i],&rfds)) {
    printf("qqch recu sur ttyS%d\n",i);
    }
    }
    }

    Un "man select()" t'expliquera comment marchent FD_SET, FD_CLR,
    etc.