Hi!
I trying to migrate with my project from 3.5 to 4.1. I have RS485 transmitter, that is connected to Serial5 on T3.5 and to Serial8 on T4.1. So afrer tranfer a message i read answer from line. With T3.5 it works fine, but with T4.1 i have some problem. The problem is, that after i transfered a message and read the answer in input buffer i read my transfered message and only after reading i see the answer. I dont understand how it happens.
This is part of my code to transfer message
I repeat that with T3.5. it work fine.
I trying to migrate with my project from 3.5 to 4.1. I have RS485 transmitter, that is connected to Serial5 on T3.5 and to Serial8 on T4.1. So afrer tranfer a message i read answer from line. With T3.5 it works fine, but with T4.1 i have some problem. The problem is, that after i transfered a message and read the answer in input buffer i read my transfered message and only after reading i see the answer. I dont understand how it happens.
This is part of my code to transfer message
Code:
digitalWrite(DIR, HIGH); // begin transfer
delay(2);
buff[0] = byte(RS485_START_BYTE);
buff[1] = Message_to_send.reciver_id;
buff[2] = Message_to_send.reciver_adress;
buff[3] = Message_to_send.sender_id;
buff[4] = Message_to_send.sender_adress;
buff[5] = Message_to_send.Command;
buff[6] = Message_to_send.data1;
buff[7] = Message_to_send.data2;
buff[8] = Message_to_send.data3;
buff[9] = Message_to_send.data4;
buff[10] = Message_to_send.data5;
buff[11] = Message_to_send.data6;
buff[12] = Message_to_send.data7;
buff[13] = Message_to_send.data8;
buff[14] = Message_to_send.data9;
buff[15] = Message_to_send.data10;
buff[16] = Message_to_send.sign;
buff[17] = byte(RS485_STOP_BYTE);
RS485->write(buff, RS485_BUFF_SIZE);
RS485->flush();
digitalWrite(DIR, LOW); // end transfer
delay(2);
I repeat that with T3.5. it work fine.