/// <summary>
        /// Body of the thread that polls the messages.
        /// It will poll data EVEN IF nobody is registered on the event!
        /// </summary>
        protected void PollMessageThread(object pParam)
        {
            while (this.mPollMessages)
            {
                if (!this.mWaitingForAck)
                {
                    //if not waiting for a ACK
                    //small probabily of thread collision, but let's see like that first... (should lock the variable before)
                    lock (mWaitingForAckSynchroKey) {
                        if (!this.mWaitingForAck)
                        {
                            //synchro : lock the line
                            lock (this.mPollingMessageSynchroKey) {
                                try {
                                    bool         vReceiveOk = false;
                                    ARCPO_Packet vPacket    = new ARCPO_Packet();
                                    vReceiveOk = vPacket.ReadPacket(this.mPort);

                                    if (vReceiveOk && this.PacketReceived != null)
                                    {
                                        //received + someone waiting for notification : raise the event
                                        ARCPO_ReceivedEventArgs vE = new ARCPO_ReceivedEventArgs(vPacket);
                                        this.PacketReceived(this, vE);
                                    }
                                }
                                catch (Exception ex) {
                                    //nothing (for now)
                                }
                            }
                        }
                    }
                }

                //get some rest
                Thread.Sleep(RECEIVE_POLLING_IN_MS);
            }
        }
        /// <summary>
        /// Body of the thread that polls the messages.
        /// It will poll data EVEN IF nobody is registered on the event!
        /// </summary>
        protected void PollMessageThread(object pParam)
        {
            while (this.mPollMessages) {

                if (!this.mWaitingForAck) {
                    //if not waiting for a ACK
                    //small probabily of thread collision, but let's see like that first... (should lock the variable before)
                    lock (mWaitingForAckSynchroKey) {
                        if (!this.mWaitingForAck) {
                            //synchro : lock the line
                            lock (this.mPollingMessageSynchroKey) {
                                try {
                                    bool vReceiveOk = false;
                                    ARCPO_Packet vPacket = new ARCPO_Packet();
                                    vReceiveOk = vPacket.ReadPacket(this.mPort);

                                    if (vReceiveOk && this.PacketReceived != null) {
                                        //received + someone waiting for notification : raise the event
                                        ARCPO_ReceivedEventArgs vE = new ARCPO_ReceivedEventArgs(vPacket);
                                        this.PacketReceived(this, vE);
                                    }
                                }
                                catch (Exception ex) {
                                    //nothing (for now)
                                }
                            }
                        }
                    }
                }

                //get some rest
                Thread.Sleep(RECEIVE_POLLING_IN_MS);
            }
        }
示例#3
0
 private void Connector_PacketReceived(object sender, ARCPO_ReceivedEventArgs e)
 {
     textBox1.Text += ">>RECEIVED unexpected message " + e.Packet.mID + " : ";
     textBox1.Text += e.Packet.ContentString;
     textBox1.Text += "\r\n";
 }
示例#4
0
        /// <summary>
        /// Message received from arduino
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Connector_PacketReceived(object sender, ARCPO_ReceivedEventArgs e)
        {
            this.mReceivedMessageHistory.Add(e.Packet);

            if (this.PacketReceived != null)
            {
                this.PacketReceived(this, e);
            }
        }