コード例 #1
0
ファイル: OttoSession.cs プロジェクト: kyberpunk/OttoHelper
        private async Task <bool> GetFirmataVersionAsync()
        {
            var firmware = await _session.GetFirmwareAsync();

            Console.WriteLine($"Firmware: {firmware.Name} version {firmware.MajorVersion}.{firmware.MinorVersion}");
            var protocolVersion = await _session.GetProtocolVersionAsync();

            Console.WriteLine($"Firmata protocol version {protocolVersion.Major}.{protocolVersion.Minor}");
            return(true);
        }
コード例 #2
0
        public void GetFirmwareAsync()
        {
            const int    majorVersion = 5;
            const int    minorVersion = 1;
            const string Name         = "Arduïno Firmata";

            var connection = new MockSerialConnection();
            var session    = new ArduinoSession(connection);

            connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x79, 0xF7 }, new byte[] { 0xF0, 0x79, majorVersion, minorVersion });
            connection.EnqueueResponse(Name.To14BitIso());
            connection.EnqueueResponse(0xF7);

            Firmware firmware = session.GetFirmwareAsync().Result;

            Assert.AreEqual(firmware.MajorVersion, majorVersion);
            Assert.AreEqual(firmware.MinorVersion, minorVersion);
            Assert.AreEqual(firmware.Name, Name);
        }
コード例 #3
0
        public void GetFirmwareAsync()
        {
            const int majorVersion = 5;
            const int minorVersion = 1;
            const string Name = "Arduïno Firmata";

            var connection = new MockSerialConnection();
            var session = new ArduinoSession(connection);

            connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x79, 0xF7 }, new byte[] { 0xF0, 0x79, majorVersion, minorVersion });
            connection.EnqueueResponse(Name.To14BitIso());
            connection.EnqueueResponse(0xF7);

            Firmware firmware = session.GetFirmwareAsync().Result;
            Assert.AreEqual(firmware.MajorVersion, majorVersion);
            Assert.AreEqual(firmware.MinorVersion, minorVersion);
            Assert.AreEqual(firmware.Name, Name);
        }