private async void ReadSerialPort(UnifiedNetworkProcessorInterface port) { if (port == null) { throw new ArgumentNullException(nameof(port)); } while (true) { try { var serialPacket = await SerialPacket.ReadAsync(port.InputStream).ConfigureAwait(false); if (serialPacket.Type == MessageType.SRSP) { _responseQueue.Add(serialPacket); continue; } if (serialPacket.Type == MessageType.AREQ) { _areqQueue.Add(serialPacket); } } catch (Exception e) { // TODO improve this by adding a good error handling OnError(e); } } }
public CCZnp(string portName) { semaphore = new SemaphoreSlim(1, 1); unpi = new UnifiedNetworkProcessorInterface(portName, 115200, 1); }