private void Exec(Action <MTRFXXAdapter> action, Action <MTRFXXAdapter> actionF) { try { device.Open(); if (fMode) { actionF(device); } else { action(device); } } catch (Exception ex) { logger.LogError(ex, "Error on command sending"); } }
static void Invoke(CommonArgs args, Action <MTRFXXAdapter, byte> action, Action <MTRFXXAdapter, byte> actionF) { using (var adapter = new MTRFXXAdapter(args.Port.ParsedValue)) { adapter.Open(); adapter.ExitServiceMode(); Thread.Sleep(50); if (args.ModeF.HasValue()) { actionF(adapter, args.Channel.ParsedValue); } else { action(adapter, args.Channel.ParsedValue); } Thread.Sleep(100); } }
public override void StartPlugin() { device.Open(); }
static void Main(string[] args) { foreach (var name in SerialPort.GetPortNames()) { Console.WriteLine(name); } return; //using (var adapter = new MTRFXXAdapter("/dev/tty.usbserial-AI04XT35")) using (var adapter = new MTRFXXAdapter("/dev/tty.usbserial-AL00HDFI")) { adapter.Connect += AdapterOnConnect; adapter.Disconnect += AdapterOnDisconnect; adapter.ReceiveData += AdapterOnReceiveData; adapter.ReceiveMicroclimateData += AdapterOnReceiveMicroclimateData; adapter.Error += AdapterOnError; // Console.WriteLine("open"); // adapter.Open(); // Console.ReadKey(); // // Console.WriteLine("exit service mode"); // adapter.ExitServiceMode(); // Console.ReadKey(); // // Console.WriteLine("close"); // adapter.Close(); // Console.ReadKey(); Console.WriteLine("open"); adapter.Open(); Console.ReadKey(); Console.WriteLine("exit service mode"); adapter.ExitServiceMode(); Console.ReadKey(); // Console.WriteLine("bind"); // adapter.BindF(13); // // Console.ReadKey(); // Console.WriteLine("bind"); // adapter.Bind(Mode.NooLiteF, 13); // // Console.ReadKey(); // // Console.WriteLine("unbind"); // adapter.Unbind(Mode.NooLiteF, 13); // // Console.ReadKey(); // Console.WriteLine("on"); // adapter.OnF(13, 1594); // // Console.ReadKey(); // // Console.WriteLine("off"); // adapter.OffF(13, 1594); // // Console.ReadKey(); // // Console.WriteLine("on"); // adapter.OnF(13, 2405); // // Console.ReadKey(); // // Console.WriteLine("off"); // adapter.OffF(13, 2405); // // Console.ReadKey(); Console.WriteLine("bind: start"); adapter.On(64); Console.ReadKey(); Console.WriteLine("bind: stop"); adapter.BindStop(); } }
public override async Task StartPlugin() { device.Open(); }