Do you need the newline termination? Some of the bytes in the data struct may be equal to the newline characters used for termination and this may cause problems. Try this approach:
void sendMessage(byte* msg, byte cc)
{
for (byte i = 0; i < cc; i++) Serial.write(msg[i]);
Serial.flush();
}
bool receiveMessage(byte* msg, byte cc)
{
byte i = 0;
while (Serial.available() && (i < cc)) msg[i++] = Serial.read();
return (i == cc);
}
type_msgRS485 theMessage;
sendMessage(&theMessage, sizeof(theMessage));
if (receiveMessage(&theMessage, sizeof(theMessage))
{
//Yay!
}
as you know there is only one serial port on nano and I said that I was observing the results. I am observing via softserial @ 9600bauds agains serial @115200.
I tried to downsize 115200 to 57600 : I now see about 10 bytes coming.
So I guess that the missing bytes comes from occupied processor
So I upgrade to 57600 both SoftSerial and Serial :
Seems no problem anymore
I can't change hardware : I must use a nano. I also must have dual com. So I need softSerial. I confirm that upgrading to 115200 on both solved the pb.
Anyway thanks for your help.
I close the subject