I wrote a small script that reads data from the serial port. Then on windows Bluetooth, I created an incoming port (com8). And I connected to Bluetooth from android using an app called Bluetooth terminal. The problem is when I run the script on Unity it is not updating the data in real-time. For example, I sent strings like 1, 2, 3, 4, 5, etc... one by one it only updates something like 1, 3, 4, 6, etc. But on the other hand, when I checked the com port using Arduino serial, it is updating in real-time without any problem. below is my code
using UnityEngine;
using System.IO.Ports;
using UnityEngine.UI;
public class Movement : MonoBehaviour
{
private float speed = 5.0f;
public Text outText;
SerialPort sp=new SerialPort("COM8",9600);
// Start is called before the first frame update
void Start()
{
sp.Open();
sp.ReadTimeout =1;
}
// Update is called once per frame
void Update()
{
if(sp.IsOpen){
try{
print(sp.ReadLine().ToString());
outText.text=sp.ReadLine().ToString();
}catch(System.Exception){
}
}
}
}