using InnovEnergy.App.SchneiderDriver; using InnovEnergy.Lib.Protocols.DBus; using InnovEnergy.Lib.Utils; using InnovEnergy.Lib.Utils.Net; // dotnet publish EmuMeter.csproj -c Release -r linux-arm -p:PublishSingleFile=true --self-contained true && \ // rsync -av bin/Release/net6.0/linux-arm/publish/ root@10.2.1.6:/home/root/emu && clear && \ // ssh root@10.2.1.6 /home/root/emu/EmuMeter Console.WriteLine("Starting Schneider Driver " + Config.Version); var networkInterfaces = await Nic.GetNetworkInterfaces(); var candidates = networkInterfaces.Where(n => n.IsUp && n.IsEthernet && (!n.Ip4Addresses.Any() || n.Ip4Addresses.Contains(Config.OwnAddress))); foreach (var nic in candidates) { Console.WriteLine($"Found new network interface: {nic.Name}"); if (!nic.Ip4Addresses.Contains(Config.OwnAddress)) { Console.WriteLine($"Configuring Point-to-Point connection on {nic.Name}"); Console.WriteLine($" own address: {Config.OwnAddress}"); Console.WriteLine($" peer address: {Config.PeerAddress}"); var success = await nic.AddPointToPoint($"{Config.OwnAddress}/16", $"{Config.PeerAddress}/16"); if (!success) { Console.WriteLine($"Failed to configure network interface: {nic.Name}"); continue; } } Console.WriteLine($"Pinging peer @ {Config.PeerAddress}"); var ping = await Config.PeerAddress.Ping(); if (ping) { Console.WriteLine($"Got answer from {Config.PeerAddress}"); var ex = await SchneiderMeterDriver.Run($"{Config.PeerAddress}:{Config.PeerPort}", Bus.System); Console.WriteLine($"{nameof(SchneiderMeterDriver)} FAILED with\n{ex}"); } else { Console.WriteLine($"No answer from {Config.PeerAddress}"); } Console.Write($"Removing Point-to-Point connection on {nic.Name} ..."); var removed = await nic.RemoveAddress($"{Config.OwnAddress}/16"); Console.WriteLine(removed ? "done" : "failed"); } Console.WriteLine("Stopping SchneiderMeter Driver");