Troubleshooting RS485 Serial for Underwater ROV Project

Hello, I am trying to use Nick Gammon's RS485 library to send sensor (joystick) values from a master Arduino to a slave. For now, as a test, I am trying to display these values on the serial monitor connected to the slave to experiment with the idea of using rs485 for an ROV. The posted code is mostly modified from Gammon's example.
I am using the wiring shown here...

http://arduino-info.wikispaces.com/SoftwareSerialRS485Example
It uses modules based on the MAX485 chip and supporting components to make a half duplex network.

I am using hardware serial on an Arduino Uno for the master, and Serial1 hardware serial on an Arduino Mega for the slave.

I have not gotten any error messages from the IDE, but the sensor values are not getting displayed at the slave end by there serial monitor. My code is also attached.

Here is the code for the master.

#include "RS485_protocol.h"
int val = 0;
const byte ENABLE_PIN = 4;

// callback routines

void fWrite (const byte what)
{
  Serial.write (what);  
}

int fAvailable ()
{
  return Serial.available ();  
}

int fRead ()
{
  return Serial.read (); 

} 
void setup()
{
  Serial.begin (28800);
  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable

}  // end of setup

void loop()
{

  val = analogRead (A0) / 4;

  // assemble message
  byte msg [] = { 
    5,
    val
      // to what level
  };
  // send to slave  
  digitalWrite (ENABLE_PIN, HIGH);  // enable sending
  sendMsg (fWrite, msg, sizeof msg);
  delayMicroseconds (600);
  digitalWrite (ENABLE_PIN, LOW);  // disable sending  
 // Serial.println(val);


}  // end of loop

And the code for the Slave... (will be underwater on the vehicle)

#include "RS485_protocol.h"

const byte ENABLE_PIN = 4;


void fWrite (const byte what)
  {
  Serial1.write (what);  
  }
  
int fAvailable ()
  {
  return Serial1.available ();  
  }

int fRead ()
  {
  return Serial1.read ();  
  }
  
void setup()
{
  Serial1.begin (28800);
  Serial.begin (9600);
  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable
}

void loop()
{
  digitalWrite (ENABLE_PIN, LOW);
  byte buf [20];
  
  byte received = recvMsg (fAvailable, fRead, buf, sizeof (buf) - 1);
 //  Serial.println(received);
  
  if (received)
    {
       Serial.println(buf [0]);
       Serial.println(buf [1]);
    }
    
    else{
      Serial.println("not recieving anything");
   }  
   delay(1);
   
}
     // end of loop

Master_test.ino (739 Bytes)

Slave_test.ino (735 Bytes)

How do you have the two Arduinos wired together?

Let me put that another way. If you eliminate the RS485 stuff for now, and just connect the two Arduinos together (Tx to Rx, Rx to Tx, and Gnd to Gnd) does it work?

Thanks for the help. The system does work without the rs485 hardware itself, so I am starting to suspect that the MAXIM chips might have gotten fried while I was experimenting to find the problem. I will acquire another set, so that I can check that, but it does seem like a hardware issue for sure now.

Also check you have the DE and /RE signals set up correctly. Maybe check with a scope or logic analyzer.