--- rpl/src/instructions_o1.c 2012/01/17 14:44:08 1.44 +++ rpl/src/instructions_o1.c 2012/02/23 13:05:08 1.45 @@ -942,6 +942,9 @@ instruction_open(struct_processus *s_eta struct_objet *s_objet_argument; struct_objet *s_objet_resultat; + struct_objet *s_parametres_tty; + + struct termios tc; uint32_t adresse_ipv4; @@ -1019,6 +1022,9 @@ instruction_open(struct_processus *s_eta printf(" { \"filetype\" \"access\" \"format\" { \"name\" " "\"file name\" } \"protection\" } OPEN\n"); + printf(" { \"filetype\" \"access\" \"format\" { \"name\" " + "\"file name\" } \n" + " { \"stty\" { \"stty parameters\" ... } } } OPEN\n"); printf(" { \"sockettype\" { \"name\" \"local name\" } } OPEN\n"); printf(" { \"sockettype\" \"socketdomain\" \"protection\" } OPEN\n"); printf(" \"/semaphore\" OPEN\n"); @@ -1031,6 +1037,14 @@ instruction_open(struct_processus *s_eta printf(" Socket protocol : IPV4/IPV6/UNIX\n"); printf(" Format : FORMATTED/UNFORMATTED/FLOW\n"); printf(" Protection : READONLY/WRITEONLY/READWRITE\n\n"); + printf(" Stty parameters : can be prefixed by 'NO'\n"); + printf(" IGNBRK, BRKINT, IGNPAR, PARMRK, INPCK, ISTRIP\n"); + printf(" INLCR, IGNCR, ICRNL, IXON, IXANY, IXOFF,\n"); + printf(" IMAXBEL, OPOST, ONLCR, OCRNL, ONOCR, ONLRET,\n"); + printf(" OFILL, HUPCL, CLOCAL, CRTSCTS, ISIG, ICANON,\n"); + printf(" ECHO, ECHOE, ECHOK, ECHONL, NOFLSH, TOSTOP,\n"); + printf(" IEXTEN, VEOF, VEOL, VERASE, VINTR, VKILL,\n"); + printf(" VQUIT, VSTART, VSTOP, VSUSP\n"); printf(" Address : { \"ADDRESS\" [ 127 0 0 1 ] }\n"); printf(" { \"HOST\" \"hostname\" }\n"); @@ -1061,6 +1075,8 @@ instruction_open(struct_processus *s_eta printf(" { \"STREAM\" \"READWRITE\" } OPEN\n"); printf(" { \"FOREIGN\" \"DATAGRAM\" } OPEN\n"); printf(" { \"LOCAL\" { \"NAME\" \"socket.sock\" } } OPEN\n"); + printf(" { \"/dev/ttyS1\" { \"STTY\" { \"9600,8,N,1\" " + "\"NO ICANON\" \"IGNBRK\" } }\n"); return; } @@ -1121,6 +1137,7 @@ instruction_open(struct_processus *s_eta timeout_emission = 0; timeout_reception = 0; drapeau = -1; + s_parametres_tty = NULL; for(i = 0; i < 12; options[i++] = 'N'); @@ -1973,15 +1990,14 @@ instruction_open(struct_processus *s_eta (*(*l_element_courant_sous_objet) .donnee).objet; - for(i = 0; i < strlen(protocole_socket); i++) - { - if ((protocole_socket[i] >= 'a') && - (protocole_socket[i] <= 'z')) - { - protocole_socket[i] -= 'a' - 'A'; - } - } - + for(i = 0; i < strlen(protocole_socket); i++) + { + if ((protocole_socket[i] >= 'a') && + (protocole_socket[i] <= 'z')) + { + protocole_socket[i] -= 'a' - 'A'; + } + } } else { @@ -2250,6 +2266,30 @@ instruction_open(struct_processus *s_eta } } } + else if (strcmp(argument_majuscule, "STTY") == 0) + { + if ((*(*l_element_courant_sous_objet) + .donnee).type == LST) + { + if (type_arguments == ' ') + { + type_arguments = 'F'; + } + else if (type_arguments == 'S') + { + liberation(s_etat_processus, + s_objet_argument); + free(argument_majuscule); + + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return; + } + + s_parametres_tty = + (*l_element_courant_sous_objet).donnee; + } + } else { liberation(s_etat_processus, s_objet_argument); @@ -3480,6 +3520,21 @@ instruction_open(struct_processus *s_eta return; } + if (s_parametres_tty != NULL) + { + // Affectation des paramètres du port série. + + if (tcgetattr(fileno(descripteur), &tc) != 0) + { + liberation(s_etat_processus, s_objet_argument); + liberation(s_etat_processus, s_objet_resultat); + + (*s_etat_processus).erreur_systeme = + d_ex_erreur_fichier; + return; + } + } + strcpy((*((struct_fichier *) (*s_objet_resultat).objet)).nom, nom); liberation(s_etat_processus, s_objet_argument);