public SerialDevice(WD.SerialCommunication.SerialDevice device) { this.device = device; this.writer = new DataWriter(this.device.OutputStream); this.reader = new DataReader(this.device.InputStream); }
/// <summary> /// Öffnet die Serielle Verbindung und startet den Worker-Thread. /// </summary> public async Task Start() { try { //// Serielle Schnittstelle öffen if (this.IsConnected == false) { serialPort = await Windows.Devices.SerialCommunication.SerialDevice.FromIdAsync(this.Port); serialPort.WriteTimeout = TimeSpan.FromMilliseconds(1000); serialPort.ReadTimeout = TimeSpan.FromMilliseconds(1000); this.serialPort.BaudRate = this.BaudRate; //this.serialPort.PortName = this.Port; this.serialPort.DataBits = (ushort)this.DataBits; switch (this.StopBits) { case SerialStopBitCount.One: this.serialPort.StopBits = Windows.Devices.SerialCommunication.SerialStopBitCount.One; break; case SerialStopBitCount.OnePointFive: this.serialPort.StopBits = Windows.Devices.SerialCommunication.SerialStopBitCount.OnePointFive; break; case SerialStopBitCount.Two: this.serialPort.StopBits = Windows.Devices.SerialCommunication.SerialStopBitCount.Two; break; default: throw new NotImplementedException(); } switch (this.Parity) { case SerialParity.None: this.serialPort.Parity = Windows.Devices.SerialCommunication.SerialParity.None; break; case SerialParity.Odd: this.serialPort.Parity = Windows.Devices.SerialCommunication.SerialParity.Odd; break; case SerialParity.Even: this.serialPort.Parity = Windows.Devices.SerialCommunication.SerialParity.Even; break; case SerialParity.Mark: this.serialPort.Parity = Windows.Devices.SerialCommunication.SerialParity.Mark; break; case SerialParity.Space: this.serialPort.Parity = Windows.Devices.SerialCommunication.SerialParity.Space; break; default: throw new NotImplementedException(); } //this.serialPort.Open(); ReadCancellationTokenSource = new CancellationTokenSource(); dataReaderObject = new Windows.Storage.Streams.DataReader(serialPort.InputStream); dataWriteObject = new Windows.Storage.Streams.DataWriter(serialPort.OutputStream); ////// Input Buffer überprüfen bzw. anlegen //if (this.InputBuffer == null || this.InputBuffer.Count() != this.serialPort.ReadBufferSize) //{ // this.InputBuffer = new byte[this.serialPort.ReadBufferSize]; //} } } catch (Exception ex) { throw ex; } }
public SerialDevice(WD.SerialCommunication.SerialDevice device) { this.device = device; this.writer = new DataWriter(this.device.OutputStream); this.reader = new DataReader(this.device.InputStream); }
public SerialDevice(Windows.Devices.SerialCommunication.SerialDevice device) { this.device = device; }
public SerialDevice(Windows.Devices.SerialCommunication.SerialDevice device) { this.device = device; }