Ejemplo n.º 1
0
        public void TestSerialPortsSearch()
        {
            var serialPorts = new SerialPorts();
            var portsCount  = serialPorts.GetPortsCount();

            if (portsCount <= 0)
            {
                LogAssert.Expect(LogType.Error, "no ports");
            }

            for (uint i = 0; i < portsCount; i++)
            {
                var portInfo = serialPorts.GetPortAt(i);
                Assert.True(portInfo.IsValid);
                var portInfo2 = serialPorts.GetPortByName(portInfo.port);
                Assert.True(portInfo2.IsValid);
                Assert.True(portInfo == portInfo2);
            }

            // invalid port name
            {
                var portInfo2 = serialPorts.GetPortByName("<invalid port name>");
                Assert.True(!portInfo2.IsValid);
            }
        }
Ejemplo n.º 2
0
    void Start()
    {
        var ports = new SerialPorts();

        Label.text = "Start test:\n";

        var portsCount = ports.GetPortsCount();

        Label.text += "Ports count: " + portsCount + "\n";

        for (uint i = 0; i < portsCount + 1; i++)
        {
            Label.text += "Port #" + i + ": " + ports.GetPortAt(i) + "\n";
        }

        Label.text += "Port \"/dev/cu.usbmodem14C1\": " + ports.GetPortByName("/dev/cu.usbmodem14C1") + "\n";


        Label.text += "Done.\n";
    }
Ejemplo n.º 3
0
        public void TestSerialPortsList()
        {
            var serialPorts = new SerialPorts();
            var portsCount  = serialPorts.GetPortsCount();

            if (portsCount <= 0)
            {
                LogAssert.Expect(LogType.Error, "no ports");
            }

            for (uint i = 0; i < portsCount; i++)
            {
                var portInfo = serialPorts.GetPortAt(i);
                Assert.True(portInfo.IsValid);
            }

            // invalid port index
            {
                var portInfo = serialPorts.GetPortAt(portsCount + 1);
                Assert.True(!portInfo.IsValid);
            }
        }