示例#1
0
        static void Main(string[] args)
        {
            Calls    call  = new Calls();
            CommNode comm1 = new Comms(1);
            CommNode comm2 = new Comms(2);

            comm1.LinkCallback(new Ping(), new CallBack(call.PingCallback));
            comm2.LinkCallback(new Ping(), new CallBack(call.PingCallback));

            comm1.InitConnection(TransportProtocol.ZIGBEE_LINK, "COM5", "", 57600);
            comm2.InitConnection(TransportProtocol.ZIGBEE_LINK, "COM6", "", 57600);
            Console.WriteLine(comm1.AddAddress(2, "0013A2004067E4AE", 0));
            Console.WriteLine(comm2.AddAddress(1, "0013A20040917A31", 0));
            //comm1.InitConnection(TransportProtocol.UDP_LINK, "1337", "127.0.0.1", 57600);
            //comm2.InitConnection(TransportProtocol.UDP_LINK, "1338", "127.0.0.1", 57600);
            //Console.WriteLine(comm1.AddAddress(2, "127.0.0.1", 1338));
            //Console.WriteLine(comm2.AddAddress(1, "127.0.0.1", 1337));
            //Ping ping = new Ping("I am from C#!");
            comm1.Run();
            comm2.Run();
            Ping ping = new Ping("From C#, From the xbee!!");

            //TargetDesignationCommand command = new TargetDesignationCommand(45.34f, 23.22f, 234.44f);
            while (true)
            {
                comm1.Send(ping, 2);
                //comm1.Send(command, 1);
                System.Threading.Thread.Sleep(1000);
            }
            comm1.Stop(); //This call is essential to stop threads because finalizer may not be called.
            comm2.Stop();
        }
示例#2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.MyButton);
            Comms  comms  = new Comms(new TcpClient("192.168.0.30", 1490));

            button.Click += delegate { comms.Send("Request Build"); };
        }
示例#3
0
 /// <summary>
 /// This method should be called by an event handler for each time there is a gain to be written for any servo
 /// </summary>
 /// <param name="servo_id"></param>
 /// <param name="write_value"></param>
 private void SendArmData(int servo_id, int write_value)
 {
     //@TODO send values
     NGCP.ArmCommand ac = new NGCP.ArmCommand((byte)servo_id, write_value);
     comms.Send(ac, UGV_ID);
 }