示例#1
0
        public override IObservable <TSource> Process <TSource>(IObservable <TSource> source)
        {
            var newLine = ObservableSerialPort.Unescape(NewLine);

            return(Observable.Using(
                       () => SerialPortManager.ReserveConnection(PortName),
                       connection => source.Do(value =>
            {
                lock (connection.SerialPort)
                {
                    connection.SerialPort.Write(value.ToString());
                    connection.SerialPort.Write(newLine);
                }
            })));
        }
示例#2
0
        public override IObservable <string> Generate()
        {
            var newLine = ObservableSerialPort.Unescape(NewLine);

            return(ObservableSerialPort.ReadLine(PortName, newLine));
        }