Coucou, donc voici le code, actuellement il fonctionne sans aucunes pertes de données ^^ cool.
Mais c'est loin d'être fini.
@Cocothebo : merci et si tu as d'autres suggestions no prob 
Gcom.cpp
#include <iostream> //Permet d'utiliser In et Out du moniteur série
#include "rs232.h" //Librairie de communication RS232
using namespace std;
int cport_nr(0); // 0 = ttyS0 ls /dev/tty*
struct S_SERVO
{
char ms_membre ; //1 octet/bytes (8 bits) : 0 / 255
char ms_servo ; //1 octet/bytes (8 bits) : 0 / 255
unsigned short int ms_acceleration ;//2 octet/bytes (16 bits) : 0 / 65 535
//short int ms_vitesse ; //2 octet/bytes (16 bits) : -32 768 / +32 767
//short int ms_cible ; //2 octet/bytes (16 bits) : -32 768 / +32 767
};
struct S_ARDUINO
{
short int roll; //2 octet/bytes (16 bits) : -32 768 / +32 767
short int pitch; //2 octet/bytes (16 bits) : -32 768 / +32 767
short int yaw; //2 octet/bytes (16 bits) : -32 768 / +32 767
unsigned short int boussole;//2 octet/bytes (16 bits) : 0 / 65 535
};
union U_DATA
{
S_SERVO s_servo;
S_ARDUINO s_arduino;
unsigned char cast_servo[sizeof (s_servo)];
unsigned char cast_arduino[sizeof (s_arduino)];
}u_servo, u_arduino, u_buf;
//class permettant la création d'objet (servo)
class C_SERVO
{
public :
C_SERVO(char, char, unsigned short int);
~C_SERVO();
U_DATA *cu_servo; //pointeur sur un type U_DATA, on utilise la même case mémoire
void affiche() const;
};
C_SERVO::C_SERVO (char mbr, char servo, unsigned short int acceleration)
{
cu_servo = &u_servo;
cu_servo->s_servo.ms_membre = mbr;
cu_servo->s_servo.ms_servo = servo;
cu_servo->s_servo.ms_acceleration = acceleration;
//l'objet est crée, on peut l'envoyer
cout << "Création objet : \n";
RS232_SendBuf(cport_nr, cu_servo->cast_servo, sizeof (u_buf.cast_servo));
cout << "----- \n";
}
C_SERVO::~C_SERVO()
{
cout << "Objet détruit... \n";
cout << "----- \n";
}
void C_SERVO::affiche () const
{
cout << "&cu_servo->s_servo : \t\t" << &cu_servo->s_servo << "\n";
cout << "cu_servo->s_servo.ms_membre : \t\t" << cu_servo->s_servo.ms_membre << "\n";
cout << "cu_servo->s_servo.ms_servo : \t\t" << cu_servo->s_servo.ms_servo << "\n";
cout << "cu_servo->s_servo.ms_acceleration : \t" << cu_servo->s_servo.ms_acceleration << "\n";
//cout << "ms_vitesse : \t\t" << ms_vitesse << "\n";
//cout << "ms_cible : \t\t" << ms_cible << "\n";
cout << "----- \n";
}
void fctDelete (C_SERVO *);
int main ()
{
short int i = 0;
//int cport_nr(0); // 0 = ttyS0 ls /dev/tty*
int bdrate(115200); // Baud
char mode []={'8','N','1',0}; // 8 data bits, no parity, 1 stop bit
//Si toutes les conditions recquises sont bonnes, on test le port de communication
if (RS232_OpenComport(cport_nr, bdrate, mode))
{
cout <<"Ne peut pas ouvrir le port com. \n";
return 0;
}
cout << "----- \n";
cout << "Raspberry connecté : \n";
cout << "----- \n";
//pour le test j'ai été un peu barbare, :)
//on crée un objet, on argumente, on test en affichant les données grâce à la fonction "affiche"
//on attend 100 ms et on efface l'objet avec la fonction "fctDelete"
while(1)
{
C_SERVO *teteY;
teteY = new C_SERVO (65, 85, 110); //65 = A ; 85 = U
teteY->affiche();
usleep(100000); //usleep est en ms - 1 - 100000 pause pour 100 milliSeconds
fctDelete (teteY);
C_SERVO *teteZ;
teteZ = new C_SERVO (66, 86, 120); //66 = B ; 86 = V
teteZ->affiche();
usleep(100000); //usleep est en ms - 1 - 100000 pause pour 100 milliSeconds
fctDelete (teteZ);
C_SERVO *brasDY;
brasDY = new C_SERVO (67, 87, 130); //67 = C ; 87 = W
brasDY->affiche();
usleep(100000); //usleep est en ms - 1 - 100000 pause pour 100 milliSeconds
fctDelete (brasDY);
C_SERVO *brasDX;
brasDX = new C_SERVO (68, 88, 140); //68 = D ; 88 = X
brasDX->affiche();
usleep(100000); //usleep est en ms - 1 - 100000 pause pour 100 milliSeconds
fctDelete (brasDX);
C_SERVO *brasDZ;
brasDZ = new C_SERVO (69, 89, 150); //69 = E ; 89 = Y
brasDZ->affiche();
usleep(100000); //usleep est en ms - 1 - 100000 pause pour 100 milliSeconds
fctDelete (brasDZ);
//Récupére un tableau de données de la pi dans le buffer envoyé d'Arduino
//Via la RS232
int n = RS232_PollComport(cport_nr, u_arduino.cast_arduino, sizeof (u_buf.cast_arduino));
cout << "----- \n";
cout << "Taille sizeof u_buf.cast_arduino : " << sizeof (u_buf.cast_arduino) << " octets/bytes. \n";
if (n > 0)
{
u_arduino.cast_arduino[n] = 0;
cout <<"Pi reçoit d'Arduino : "<< n <<" bytes. \n";
}
//On regarde ce qu'Arduino nous envoie
cout << "Pi reçoit u_arduino.s_arduino.roll :\t\t " << u_arduino.s_arduino.roll <<" \n";
cout << "Pi reçoit u_arduino.s_arduino.pitch :\t\t " << u_arduino.s_arduino.pitch <<" \n";
cout << "Pi reçoit u_arduino.s_arduino.yaw :\t\t " << u_arduino.s_arduino.yaw <<" \n";
cout << "Pi reçoit u_arduino.s_arduino.boussole :\t " << u_arduino.s_arduino.boussole <<" \n";
usleep(100000); //usleep est en ms - 1 - 100000 pause pour 100 milliSeconds
}
return 0;
}
void fctDelete (C_SERVO * del)
{
cout << "Appel fctDelete !! \n";
delete del;
}
Arduino :
//incomingByte initialisée pour tester l'entrée de données
int incomingByte = 0;
//Structure pour l'émission de données vers la PI
struct S_PI
{
int roll; //2 octet/bytes (16 bits) : -32 768 / +32 767
int pitch; //2 octet/bytes (16 bits) : -32 768 / +32 767
int yaw; //2 octet/bytes (16 bits) : -32 768 / +32 767
unsigned int boussole; //2 octet/bytes (8 bits) : 0 / 65 535
};
//Structure pour la récepetion des données des servomoteurs
struct S_SERVO
{
byte membre ; //1 octet/bytes (8 bits) : 0 / 255
byte servo ; //1 octet/bytes (8 bits) : 0 / 255
unsigned int acceleration ; //2 octet/bytes (8 bits) : 0 / 65 535
//int vitesse ; //2 octet/bytes (16 bits) : -32 768 / +32 767
//int cible ; //2 octet/bytes (16 bits) : -32 768 / +32 767
};
//Union pour envoyer nos types struct dans un tableau unsigned char
union U_DATA
{
S_PI s_pi;
S_SERVO s_servo;
//L'envoie et la réception sont dans des tableaux
//(sizeof) permet de récupérer la taille en byte de nos structures
unsigned char cast_servo[sizeof s_servo];
unsigned char cast_pi[sizeof s_pi];
}u_servo, u_pi, u_buf;
byte j = 0;
void setup(){
Serial.begin (115200);
Serial1.begin(115200); //ici j'utilise un convertisseur de niveau logique, que l'on peut trouver sur la boutique
//Initisalisation de la structure s_pi
u_pi.s_pi.roll = 180;
u_pi.s_pi.pitch = 90;
u_pi.s_pi.yaw = 45;
u_pi.s_pi.boussole = 360;
}
void loop() {
arduinoSend();
if (Serial1.available() >= sizeof u_buf.cast_servo) //= u_buf.cast_servo)
{
incomingByte = Serial1.readBytes (u_servo.cast_servo, sizeof u_buf.cast_servo);
piReceive();
}
}
//fonction pour l'envoi de données
void arduinoSend(){
unsigned int waitingTime = 100; // 0.100 secondes
unsigned long refTime = 0;
//Envoie un tableau de données u_pi.cast_pi au format unsigned char dans le buffer à la pi
Serial1.write (u_pi.cast_pi, sizeof u_buf.cast_pi);
Serial.print ("u_pi.s_pi.roll :\t ");
Serial.println (u_pi.s_pi.roll);
Serial.print ("u_pi.s_pi.pitch :\t ");
Serial.println (u_pi.s_pi.pitch);
Serial.print ("u_pi.s_pi.yaw :\t\t ");
Serial.println (u_pi.s_pi.yaw);
Serial.print ("u_pi.s_pi.boussole :\t ");
Serial.println (u_pi.s_pi.boussole);
Serial.print ("u_buf.cast_pi : ");
Serial.println (sizeof (u_buf.cast_pi));
Serial.println("Données envoyées toutes les 100 ms :");
refTime = millis();
// début de l'attente :
while((millis()-refTime)<waitingTime){
//Attends
}
}
//fonction affichant la réception de données
void piReceive (){
Serial.println ("----------");
Serial.println ("u_servo.s_servo : ");
Serial.println (u_servo.s_servo.membre);
Serial.println (u_servo.s_servo.servo);
Serial.println (u_servo.s_servo.acceleration);
//Serial.println (u_servo.s_servo.vitesse);
//Serial.println (u_servo.s_servo.cible);
Serial.println ("-----");
Serial.print ("u_buf.cast_servo : ");
Serial.println (sizeof (u_buf.cast_servo));
Serial.print ("Compteur j : ");
Serial.println (j);
j++;
Serial.println ("-----");
}
Même si ce n'est pas parfais je le reconnais, mais je progresse et c'est super sympa je trouve ^^
Faut améliorer tous ça 
Merci