/*************************************************************************************************************************************/ /* */ /* T E S T D E S F O N C T I O N S C O M P L E X E X E S */ /* D U D I S Q U E V I D E O B E T A - P A L A 9600 B A U D S : */ /* */ /* */ /* Author of '$xtc/disk_vi_P.21$c' : */ /* */ /* Jean-Francois COLONNA (LACTAMME, AAAAMMJJhhmmss). */ /* */ /*************************************************************************************************************************************/ #include <stdio.h> #include <fcntl.h> #include <sys/signal.h> #define SEND(caractere) \ { \ char *pointeur=&bufferOUT[0]; \ bufferOUT[0] = caractere; \ /* Fonction demandee... */ \ write(desc,pointeur,1); \ READ; \ } #define READ \ { \ char *pointeur=&bufferIN[0]; \ read(desc,pointeur,1); \ } #define COMMANDE(chaine) \ { \ int index=0; \ int iterer=0; \ \ while (iterer == 0) \ { \ char caractere=chaine[index]; \ \ if (caractere != 0) \ { \ printf("%c",caractere); \ SEND(caractere); \ index++; \ } \ else \ { \ iterer++; \ } \ } \ \ READ; \ } main() { char commande1[]="VC06145@"; /* Clear ('V'), puis positionnement sur l'image d'adresse '06145' ('C') et "enter" ('@'). */ char commande2[]="VD06245:@00001@"; /* Clear ('V'), puis lecture jusqu'a l'image d'adresse '6245' ('D') et "enter" ('@'). */ int n; int desc,descOUT,descIN; char bufferIN[100],bufferOUT[100]; printf("\n initialisation=%d",system("stty sane < /dev/ttyS0")); /* Le 20090907150153 "/dev/ttyd2" fut remplace par "/dev/ttyS0" (sur '$LACT16'). */ printf("\n programmation =%d",system("stty 9600 -cstopb -parity raw -echo < /dev/ttyS0")); desc = open("/dev/ttyS0",O_RDWR | O_NDELAY); printf("\n desc =%d",desc); READ; printf("\n close =%d",close(desc)); desc = open("/dev/ttyS0",O_RDWR); printf("\n desc =%d",desc); printf("\n"); COMMANDE(commande1); sleep(2); COMMANDE(commande2); printf("\n close =%d",close(desc)); }