Beispiel #1
0
        int ISerialDriver.BytesInBuffer(int serialPortNum, bool fRx)
        {
            if (fRx)
            {
                ComPortToStream port = GetComPort(serialPortNum) as ComPortToStream;

                if (port != null)
                {
                    return(port._fifoToDevice.Available);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
Beispiel #2
0
        void ISerialDriver.DiscardBuffer(int serialPortNum, bool fRx)
        {
            if (fRx)
            {
                byte[] buf = new byte[1024];

                ComPortToStream port = GetComPort(serialPortNum) as ComPortToStream;

                if (port != null)
                {
                    while (port.AvailableBytes > 0)
                    {
                        port.DeviceRead(buf);
                    }

                    while (port._fifoToDevice.Available > 0)
                    {
                        port._fifoToDevice.Read(buf, 0, buf.Length);
                    }
                }
            }
        }