Ligne 78 : |
Ligne 78 : |
| == Contrôle avancé du port série == | | == Contrôle avancé du port série == |
| | | |
− | The wiringSerial library is intended to provide simplified control – suitable for most applications, however if you need advanced control – e.g. parity control, modem control lines (via a USB adapter, there are none on the Pi’s on-board UART!) and so on, then you need to do some of this the “old fashioned” way.
| + | La librairie wiringSerial à pour but de simplifier le contrôle du port série – ce qui est approprié pour la plupart des applications. |
| | | |
− | For example – To set the serial line into 7 bit mode plus even parity, you need to do this…
| + | Vous pourriez cependant avoir besoin d'un contrôle avancé – ex: contrôle de parité, contrôle de ligne modem (via un adaptateur USB, car il n'y en a pas sur l'UART du Pi!) et ainsi de suite. Si c'est le cas, vous aurez besoin de le faire à l'ancienne (ou à "la sauce Linux" si vous préférez). |
| | | |
− | In your program:
| + | Par exemple – si vous voulez placez la ligne série en mode 7 bits plus parité paire, vous aurez besoin de ceci... |
| + | |
| + | Dans votre programme: |
| | | |
| <nowiki>#include <termios.h></nowiki> | | <nowiki>#include <termios.h></nowiki> |
| | | |
− | and in a function:
| + | Et des appels de fonctions: |
| | | |
| | | |
| <nowiki>struct termios options ; | | <nowiki>struct termios options ; |
− | tcgetattr (fd, &options) ; // Read current options | + | tcgetattr (fd, &options) ; // Lire les options actuelles |
− | options.c_cflag &= ~CSIZE ; // Mask out size | + | options.c_cflag &= ~CSIZE ; // Masquer la "taille" ("''size''" en anglais) |
− | options.c_cflag |= CS7 ; // Or in 7-bits | + | options.c_cflag |= CS7 ; // Faire un "ou" pour le 7-bits |
− | options.c_cflag |= PARENB ; // Enable Parity - even by default | + | options.c_cflag |= PARENB ; // Activer la Parité - paire (even) par défaut |
− | tcsetattr (fd, &options) ; // Set new options </nowiki> | + | tcsetattr (fd, &options) ; // Activer les nouvelles options </nowiki> |
| | | |
| The ‘fd’ variable above is the file descriptor that serialOpen() returns. | | The ‘fd’ variable above is the file descriptor that serialOpen() returns. |