Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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();
            }
        }