Example #1
0
    public bool Connect(int port)
    {
        InitConnector();

        string[] ports = SerialUtilities.getPortNames();
        if (port >= ports.Length)
        {
            return(false);
        }
        Disconnect();
        _serialPort.PortName = ports [port];
        _serialPort.BaudRate = 115200;

        try
        {
            _serialPort.Open();
        }catch (Exception e)
        {
            Debug.Log("Failed to open serialPort:" + e.Message);
        }

        if (_serialPort.IsOpen)
        {
            Debug.Log("Connected to Robot at port: " + ports[port]);
            _thread.Start();
        }
        return(_serialPort.IsOpen);
    }
Example #2
0
 public VSidoConnector()
 {
     string[] ports = SerialUtilities.getPortNames();
     for (int i = 0; i < ports.Length; i++)
     {
         Debug.Log("Port[" + i.ToString() + "]: " + ports[i]);
     }
 }