public bool FlushBuffer(FlushTypes ft)
        {
            int func = 2;

            switch (ft)
            {
            case FlushTypes.In:
                func = 0;
                break;

            case FlushTypes.Out:
                func = 1;
                break;

            case FlushTypes.Both:
                func = 2;
                break;
            }
            int nRes = sio_flush(PortIndex, func);

            if (nRes == SIO_OK)
            {
                return(true);
            }
            return(false);
        }
        public bool FlushBuffer(string portname, FlushTypes ft)
        {
            int port = Convert.ToInt32(portname.Substring(3));
            int func = 2;

            switch (ft)
            {
            case FlushTypes.In:
                func = 0;
                break;

            case FlushTypes.Out:
                func = 1;
                break;

            case FlushTypes.Both:
                func = 2;
                break;
            }
            int nRes = sio_flush(port, func);

            if (nRes == SIO_OK)
            {
                return(true);
            }
            return(false);
        }