void attemptConnection()
{
try
{
freeSerialLink();
serialPort = new SerialPort("COM3", 19200);
serialPort.Open();
// Start a separate thread to read serial data
serialThread = new Thread(ReadSerial);
serialThread.Start();
SendDataToArduino("Wake up\n");
Debug.Log("Serial port opened!");
}
catch (UnauthorizedAccessException e)
{
Debug.LogError("Access denied opening serial port: " + e.Message);
}
catch (Exception e)
{
Debug.LogError("Error opening serial port: " + e.Message);
}
}