Sending string to Arduino uno using UART

Hi,
I'm trying to communicate between Arduino uno and Jetson Nvidia tk1 using UART by sendng message from Jetson kit to Arduino and blinking a led connected to Arduino when I recieve this message, but I have problem when to recieve this message

I send my message from Jetson tk1 using the following function
write(int fildes, const void *buf, size_t nbyte) from unistd library

buf contains the message that I want to send and this message is the word "stop"

I'm sure that this function sends my message correctly but not sure if I receive it correctly or not

The code I used to receive this message is

String msg;
void setup()
{
      Serial.begin(9600);
      pinMode(13, OUTPUT);
}


void loop()
{
   if(Serial.available()>0)
   {
      msg = Serial.readString();
      if(msg == "stop")
      {
            digitalWrite(13,HIGH);
            delay(1000);
            digitalWrite(13,HIGH);
            delay(1000);
     }
   }
}

The compiler doesn't give me errors when I upload the code on Arduino but still the led doesn't blink as I want it which means that it didn't receive the word stop.

I hope someone can help me to solve this problem

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

...R

if(msg == "stop")
{
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW); // not HIGH
delay(1000);
}