| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 
 |  
 
#include "stdio.h"
#include "time.h"
#include "stdlib.h"
#include "sys/fcntl.h"
#include "unistd.h"
#include "string.h"
#include "errno.h"     
#include "termios.h"   
#include "sys/types.h"
#include "ilcd.h"
 
extern int fd_ilcd;              // Parametre de la liaison
extern struct termios old_attr;  // Structure d'initialisation
 
/*======================================================================
**  Nom         : Init_Ilcd
**  Description : initialise l'écran tactile 
** ---------------------------------------------------------------------
**  Parametres  : 1[S]
**      1[S]    : code erreur
**======================================================================*/
int Init_Ilcd ()
{
    fd_ilcd = Open_Ilcd( PORT_ILCD );
 
    return  ILCD_OK;
}
 
/*======================================================================
**  Nom         : Open_Ilcd
**  Description : ouvre la liaison avec l'cran tactile 
** ---------------------------------------------------------------------
**  Parametres  : 1[E] 1[S]
**      1[E]    : chemin du peripherique 
**      1[S]    : descripteur de la liaison
**======================================================================*/
int Open_Ilcd (char* port_dev)
{
  struct  termios new_attr;
  int     fd;
 
  fd = open( port_dev, O_RDWR| O_NOCTTY | O_NONBLOCK );
 
  if (fd < 0)
  {
    fprintf( stderr, "Ouverture impossible du port serie : %s\n", strerror(errno) );
    exit( EXIT_FAILURE);
  }
  else
  {
    tcgetattr( fd, &old_attr );
    tcgetattr( fd, &new_attr );
 
    // Modification des paramtres du port serie
    new_attr.c_cflag |= CREAD;      
// Enable receiver
    new_attr.c_cflag |= B115200;    
// Set baud rate
    new_attr.c_cflag |= CS8;        
// 8 data bit
 
    new_attr.c_iflag |= IGNPAR;     
// Ignore framing errors and parity errors. 
 
    new_attr.c_lflag &= ~(ICANON);  
// DISABLE canonical mode. 
 
// Disables the special characters EOF, EOL, EOL2, 
// ERASE, KILL, LNEXT, REPRINT, STATUS, and WERASE, and buffers by lines.
 
    new_attr.c_lflag &= ~(ECHO);    
// DISABLE this: Echo input characters.
    new_attr.c_lflag &= ~(ECHOE);   
// DISABLE this: If ICANON is also set, the ERASE character erases the preceding input 
 
 // character, and WERASE erases the preceding word.
    new_attr.c_lflag &= ~(ISIG);    // DISABLE this: When any of the characters INTR, QUIT, SUSP, 
 
// or DSUSP are received, generate the corresponding signal.
 
    new_attr.c_cc[VMIN]=1;          
// Minimum number of characters for non-canonical read.
    new_attr.c_cc[VTIME]=0;        
 // Timeout in deciseconds for non-canonical read.
 
    tcsetattr( fd, TCSANOW, &new_attr );
  }
  return fd;
} | 
Partager