Hello everybody..
I'm trying to make Modbus RTU communication protocol in Arduino. I use the Arduino Mega ADK. but I have problems in making a program on arduino as a slave. I've made a VB.NET program as a master to request data from the Arduino.Data sent in hex format 110340000006D298 and I try to return the same data to my vb program. but when I try to send a request through Hterm serial monitor, Arduino reply in ascii. Can anyone help me to improve this program?
byte buffer[8];
 void setup(){
  Serial.begin(9600);
 }
 void loop()
 {
  unsigned long startWait = millis();
  while(Serial.available() < 8 )
  {
   Â
  Â
  }
  // At this point, there are 8 characters
  if(Serial.available() >= 8)
  {
   for (int i=0; i< 8; i++)
   {
     buffer[i] = Serial.read();
   }
  Â
   Serial.write(buffer,8);
   Serial.println("");
  Â
  }
  else
  {
   Â
  }
  Â
     Â
 }