How to stop waiting on Serial Output

I have this code that reads the serial port from a serial connection to an arduino board

void Update()
    {
        receivedString = data_stream.ReadLine();
        //do stuff
     }

My problem is, that Unity waits until a new line is sent on the Serial connection, resulting in very low fps.

How can I make Unity run normally until a new line is printed on the Serial? I hope this does not require a multithreading solution…

One easy wat to boost up your fps is, read the data stream fast manually.

you can use InvokeRepeating function to do that.

This video might help

Threading doesn’t has to be complicated you know

using System.Threading.Tasks;

async void Start ()
{
	while( this.enabled )
	{
		receivedString = await Task.Run( () => {
			try
			{
				return data_stream.ReadLine();
			}
			catch( System.Exception ex )
			{
				Debug.LogException( ex );
				return "- exception -";
			}
		} );
		Debug.Log($"received string: '{receivedString}'");

		await Task.Delay( 1000 );
	}
}