#include /* Standard input/output definitions */ #include /* String function definitions */ #include /* UNIX standard function definitions */ #include /* File control definitions */ #include /* Error number definitions */ #include /* POSIX terminal control definitions */ // Lecture port série typedef int serialPort; serialPort SerialLib_open(const char * portPath); int main(int argc, char **argv) { serialPort p = SerialLib_open("/dev/ttyAMA0"); char buffer[1]; printf("ouverture reussi\n"); while(1){ printf("lecture d'un caractere\n"); read(p, buffer ,1); printf("Message recu: %s \n",buffer); } return 0; } /** * Ouverture du port * * */ serialPort SerialLib_open(const char * serialPortPath) { int fd; fd = open(serialPortPath, O_RDWR | O_NOCTTY); if (fd == -1) { printf("Could not open the serial port : %s - ", serialPortPath); }else { fcntl(fd, F_SETFL, 0); } return (serialPort)fd; }