Error serial communication - LINUX

I have a Unity application that sends a byte to the Arduino and receives a string as a response.

On Windows OK!

In LINUX does not work, the Arduino receives the Byte and when it sends the String the application of the error and can not read the string.

ERROR (TimeoutException: The operation has time-out.)
ERROR (System.IO.Ports.SerialPort.)

Do I have to change some parameter for serial communication in LINUX?

The arkin can read the byte that the application sends, why the application can not read the string that the arduino sends?

Sorry for my bad english.

2kbit:
Do I have to change some parameter for serial communication in LINUX?

Without seeing your Arduino code or your Linux code it is hard to know what you are trying to do.

What Arduino board are you using?

Have you made yourself a member of the dialout group on your Linux PC to have permission to use the serial port? (I am assuming you are using Ubuntu or one of its derivatives)

...R

Yes I am using Ubuntu.
Put the user in the list group to access a serial port.

I'm using Arduino 101.

In the arduino code, I'm testing it like this:
When it receives the number 2 by Serial, it turns on the LED and sends a string to serial.
...

byteSerial = Serial.read();
if ( byteSerial == 2 ){
  digitalWrite(LED_BUILTIN, HIGH); 
  Serial.println("Hello Word");
}

...

In Unity, I send the number 2, and I get the string.
....

port.Write(pingTest, 0, pingTest.Length); //  pingTest = 2 = byte
string stringTest = port.ReadLine();

....
Config SerialPort in Unity

        port = new SerialPort();
        port.PortName = "/dev/ttyACM0";
        port.BaudRate = 9600;
        port.Parity = Parity.None;
        port.DataBits = 8;
        port.StopBits = StopBits.One;
port.ReadTimeout = 500;

When the Unity application is running on Windows, running no error.

When it is in UBUNTU, error timeOut.

I believe it is some detail of the serial communication of the Linux system.

I have never used Unity.

What happens if you increase the timeout?

Is your Unity program sending the byte value 2 or the character '2' (which has the byte value of 50 (decimal))?

Your Arduino program is testing for the byte value 2.

...R

If you increased the time, it passed the time and the same error.

I get the byte (2) and test the byte myself, turns on the LED (confirms that it received) and sends the String. But the Unity application can not read the string.

2kbit:
and sends the String. But the Unity application can not read the string.

Then it is a Unity problem and you need to ask on a Unity Forum.

...R

Unity use C#, I believe this does not have much to do with Unity.
I’m using the library System.IO.Ports.

The line 'port.PortName = "/dev/ttyACM0";' indicates that the Arduino is recognized as a "communications class" device (a modem). It may be that there is a service in Linux that automatically tries to attach to your Arduino thinking it to be a modem and is interfering with communications.

See post #14 in this thread: https://forum.arduino.cc/index.php?topic=129647.0 in particular, which once resolved the issue for me.

The Unity program may have to set DTR high/true and turn off hardware flow control.