示例#1
0
        public ControlMessage Call(CommandType cmd, byte[] data, CommandType expected = CommandType.CMD_ACK)
        {
            ControlMessage msg = null;

            if (Port.IsOpen)
            {
                got_expected  = false;
                this.expected = expected;
                expected_seq  = out_seq;
                SendMessage(cmd, data);

                DateTime timeout = DateTime.Now.AddMilliseconds(Timeout);
                while (!got_expected && DateTime.Now < timeout)
                {
                    Thread.Sleep(100);
                    Application.DoEvents();
                }
                if (got_expected && DateTime.Now < timeout)
                {
                    msg = this.msg;
                }
            }
            return(msg);
        }
示例#2
0
 public MessageReceivedEventArgs(ControlMessage msg)
 {
     this.msg = msg;
 }