Bonjour!

Je voudrais lire des trames de données envoyées par un GPS par protocole XBee. La clé USB XStick reçoit les données suivantes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
CHARS : 15931    SENTENCES = 0    CHECKSUM : 58
Heading : 55    Tilt: -46    Roll:2
CHARS : .....
et ainsi de suite ... J'arrive à les lire en tapant dans le terminal la commande :
Moi j'aimerais pouvoir afficher ces corrdonnées de la même manière, mais avec un programme écrit en C. Voici ce que j'ai fais :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
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
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <sys/fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "serial_port.h"
 
void read_Serial_Port(const char* DEVICE_PORT)
{
	int file;
	struct termios options;
	char message[100];
	unsigned int nCountMax = 60;
	bool b;
 
	file = open(DEVICE_PORT, O_RDONLY | O_NOCTTY | O_NDELAY);
 
	if(file == -1){perror("Unable to open the serial port\n");}
	printf("Serial port open successful\n");
 
	tcgetattr(file, &options); 			
	cfsetispeed(&options, B9600); 					
	cfsetospeed(&options, B9600); 					
	options.c_cflag |= (CLOCAL | CREAD); 			  
	options.c_cflag |= PARENB; 						//No parity					
	options.c_cflag |= PARODD; 						
	options.c_cflag &= ~CSTOPB; 					
	options.c_cflag &= ~CSIZE; 						
	options.c_cflag |= CS8; 						//8 bits					
	options.c_iflag |= (INPCK | ISTRIP); 			
	tcsetattr(file, TCSANOW, &options); 	     
	fcntl(file, F_SETFL, FNDELAY);			
 
	printf("Reading serial port ...\n\n"); 
	b = readMessage(file, message, nCountMax);
	if (b == 0){printf("Error while reading serial port\n");}
	else printf("Serial port read successful\n");
	close(file);
	printf("Serial port closed\n");
};
 
bool readMessage(int file, unsigned int nCountMax)
{
    int i;
    size_t nbytes;
	ssize_t bytes_read;
 
    if (file != -1)
    {
	    i = 0;  
	    char message[100];
	    char data[100];
		while (i<nCountMax && data != ".")
		{
		    if (read(file, data, 1) == -1)
		    {
			    printf("reception error\n");
			    printf("code errno = %d\n", errno);
			    return false;
		    }
		    else
		    {   
				nbytes = sizeof(data);
				bytes_read = read(file, data, nbytes);
			    message[i] = *data;
			    printf("%c", message[i]);
			    i++;
		    }
		}
	    message[i] = 0;
	    return true;
    }
};
Mais ça ne fonctionne pas, il me sors "reception error" correspondant au cas où
Code : Sélectionner tout - Visualiser dans une fenêtre à part
read(file,&data,1) = -1
. Et le code errno est 11, c'est à dire "try again" ...

Pouvez-vous m'aider svp ?

Merci d'avance !