コード例 #1
0
        public static LoRaArduinoSerial CreateFromPort(string port)
        {
            var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            LoRaArduinoSerial result = null;

            TestLogger.Log($"** Starting serial port '{port}' **");

            var serialPort = new SerialPort(port)
            {
                BaudRate  = 115200,
                Parity    = Parity.None,
                StopBits  = StopBits.One,
                DataBits  = 8,
                DtrEnable = true,
                Handshake = Handshake.None
            };

            result = new LoRaArduinoSerial(serialPort);

            try
            {
                serialPort.Open();
            }
            catch (Exception ex)
            {
                TestLogger.Log($"Error opening serial port '{port}': {ex.ToString()}");
                throw;
            }

            return(result);
        }
コード例 #2
0
 public OTAAJoinTest(IntegrationTestFixture testFixture)
 {
     this.testFixture = testFixture;
     this.loraRegion  = LoraRegion.EU;
     this.lora        = LoRaArduinoSerial.CreateFromPort(testFixture.Configuration.LeafDeviceSerialPort);
     this.testFixture.ClearNetworkServerLogEvents();
 }
コード例 #3
0
        public async Task InitializeAsync()
        {
            if (!string.IsNullOrEmpty(this.Configuration.LeafDeviceSerialPort))
            {
                this.arduinoDevice = LoRaArduinoSerial.CreateFromPort(this.Configuration.LeafDeviceSerialPort);
            }
            else
            {
                TestLogger.Log("[WARN] Not serial port defined for test");
            }

            if (this.Configuration.CreateDevices)
            {
                try
                {
                    await CreateOrUpdateDevicesAsync();
                }
                catch (Exception ex)
                {
                    TestLogger.Log($"[ERR] Failed to create devices in IoT Hub. {ex.ToString()}");
                }
            }

            if (!string.IsNullOrEmpty(Configuration.IoTHubEventHubConnectionString) && this.Configuration.NetworkServerModuleLogAssertLevel != LogValidationAssertLevel.Ignore)
            {
                this.IoTHubMessages = new EventHubDataCollector(Configuration.IoTHubEventHubConnectionString, Configuration.IoTHubEventHubConsumerGroup);
                await this.IoTHubMessages.StartAsync();
            }

            if (Configuration.UdpLog)
            {
                this.udpLogListener = new UdpLogListener(Configuration.UdpLogPort);
                this.udpLogListener.Start();
            }
        }
コード例 #4
0
        public void Dispose()
        {
            TestLogger.Log($"{nameof(IntegrationTestFixture)} disposed");

            if (disposed)
            {
                return;
            }

            AppDomain.CurrentDomain.UnhandledException -= this.OnUnhandledException;

            this.arduinoDevice?.Dispose();
            this.arduinoDevice = null;

            this.IoTHubMessages?.Dispose();
            this.IoTHubMessages = null;
            this.registryManager?.Dispose();
            this.registryManager = null;

            this.udpLogListener?.Dispose();
            this.udpLogListener = null;

            GC.SuppressFinalize(this);

            this.disposed = true;
        }
コード例 #5
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                this.arduinoDevice?.Dispose();
                this.arduinoDevice = null;
            }
        }
コード例 #6
0
        public static LoRaArduinoSerial CreateFromPort(string port)
        {
            var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            LoRaArduinoSerial result = null;

            if (!isWindows)
            {
                Console.WriteLine($"Starting serial port '{port}' on non-Windows");

                var serialPort = new SerialDevice(port, BaudRate.B115200);
                result = new LoRaArduinoSerial(serialPort);

                Console.WriteLine($"Opening serial port");
                try
                {
                    serialPort.Open();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error opening serial port '{port}': {ex.ToString()}");
                    throw;
                }
            }
            else
            {
                Console.WriteLine($"Starting serial port '{port}' on Windows");

                var serialPortWin = new SerialPort(port)
                {
                    BaudRate  = 115200,
                    Parity    = Parity.None,
                    StopBits  = StopBits.One,
                    DataBits  = 8,
                    DtrEnable = true,
                    Handshake = Handshake.None
                };
                result = new LoRaArduinoSerial(serialPortWin);

                try
                {
                    serialPortWin.Open();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error opening serial port '{port}': {ex.ToString()}");
                    throw;
                }
            }

            return(result);
        }
コード例 #7
0
        public override async Task InitializeAsync()
        {
            await base.InitializeAsync();

            if (!string.IsNullOrEmpty(this.Configuration.LeafDeviceSerialPort))
            {
                this.arduinoDevice = LoRaArduinoSerial.CreateFromPort(this.Configuration.LeafDeviceSerialPort);
            }
            else
            {
                TestLogger.Log("[WARN] Not serial port defined for test");
            }
        }
コード例 #8
0
        public override async Task InitializeAsync()
        {
            TestLogger.LogDate = true;

            await base.InitializeAsync();

            if (!string.IsNullOrEmpty(this.Configuration.LeafDeviceSerialPort))
            {
                this.arduinoDevice = LoRaArduinoSerial.CreateFromPort(this.Configuration.LeafDeviceSerialPort);
            }
            else
            {
                TestLogger.Log("[WARN] Not serial port defined for test");
            }

            LoRaAPIHelper.Initialize(this.Configuration.FunctionAppCode, this.Configuration.FunctionAppBaseUrl);
        }
コード例 #9
0
 public void Dispose()
 {
     this.lora?.Dispose();
     this.lora = null;
     GC.SuppressFinalize(this);
 }
コード例 #10
0
 public IntegrationTestBaseCi(IntegrationTestFixtureCi testFixture)
     : base(testFixture)
 {
     this.arduinoDevice = testFixture.ArduinoDevice;
 }
コード例 #11
0
 public IntegrationTestBase(IntegrationTestFixture testFixture)
 {
     this.testFixture   = testFixture;
     this.arduinoDevice = testFixture.ArduinoDevice;
     this.TestFixture.ClearLogs();
 }
コード例 #12
0
 public SensorDecodingTest(IntegrationTestFixture testFixture)
 {
     this.testFixture = testFixture;
     this.lora        = LoRaArduinoSerial.CreateFromPort(testFixture.Configuration.LeafDeviceSerialPort);
     this.testFixture.ClearNetworkServerLogEvents();
 }