Ejemplo n.º 1
0
        private void internalThread()
        {
            while (mIsThreadStopped == false)
            {
                // sample data = 41 7d ff dc e8 e7 1b 87 fb 42
                if (mSerialPort.BytesToRead != 0) // there is data
                {
                    try
                    {
                        byte[] arrByte = new byte[BUFFER_SZ];

                        // get the array
                        for (int ctr = 0; ctr < BUFFER_SZ; ctr++)
                        {
                            arrByte[ctr] = (byte)mSerialPort.ReadByte();
                        }

                        // validation
                        if ((arrByte[0] == 0x41) && (arrByte[9] == 0x42))
                        {
                            mIRfidNotify.Notify(arrByte);
                        }
                    }
                    catch
                    {
                        // TODO: put exception handling here
                    }
                    finally
                    {
                        mSerialPort.DiscardInBuffer();
                    }
                }
            }

            mSerialPort.Dispose();
        }