I am working on home automation project to control relays over
WiFi (Ethernet shield)
Physical push buttons
Remote HMI board (arduino UNO) link with modbus RS485 module
I completed the work with WiFi and physical push button which works fine. I also check the test sketch for RS485 which works fine but when I add this with my main sketch its not respond as expected.
Flow of code :
Send the string "A" from transmitter
Receiver receive "A" execute based on string and eco back to transmitter.
challenge :
Receiver always receive block sign or 255. while same setup working fine with test code.
Below first two is test code and 3rd code is my complet code focused area is line #186~223.
I have not looked in detail but first thing I notice is your trying to use 115200 baud with SoftwareSerial but it cannot go this fast (see here).
Also you have delay code in one sketch that calculates the delay needed before switching the RS422 from TX to RX but in the other your using a simple delay(1) that might not allow time for buffers to empty and things to settle after the direction switch to RX.
I follow your comment and put the sketch before delay and also modify my sender code and make it simple Serial.write('A') Now working fine.
I have 1 more thing when I am try to access through Ethernet shield RS48 sketch stuck for few sec until webpage opened. This web page is copied on SD card of Ethernet shield. I am also using digital pin 11 and 12 for soft serial. Is there conflict to use digital pin 11 and 12 on arduino mega with ethernet shield.
I'm not on my PC (off on holiday) so difficult to check but look at the documents for the shield and it will tell you what pins it uses and yes pins 10 thru 13 will conflict and another on for the sd card that I don't remember.
EDIT:
I'm back from holiday now, did you get this sorted out okay?