protected SerialStatusBarExtension(ISerialPort iSerialPort, CurrentDataDevice currentDataDevice) { _serialPort = iSerialPort; _serialPort.PropertyChanged += (sender, args) => UpdateStatusBarItem(); _currentDataDevice = currentDataDevice; _currentDataDevice.PropertyChanged += (sender, args) => UpdateVisibility(); }
/// <summary> /// Initializes an new instance of the ZWaveController /// </summary> /// <param name="port">The serial port to use</param> public ZWaveController(ISerialPort port) { if (port == null) { throw new ArgumentNullException(nameof(port)); } Channel = new ZWaveChannel(port); }
public async Task CloseAsync() { await _serialPort.CloseAsync(); _serialPort.Dispose(); _serialPort = null; IsConected = false; }
public void Close() { if (port != null) { port.SetNotify(null); port.Close(); port = null; } }
/// <summary>Returns an Action to be called when the observer unsubscribes.</summary> /// <param name="port">The port.</param> /// <param name="observer">The observer.</param> /// <returns>Action.</returns> private static Action UnsubscribeAction(ISerialPort port, IObserver <char> observer) { return(() => { port.DataReceived -= ReactiveDataReceivedEventHandler(port, observer); port.ErrorReceived -= ReactiveErrorReceivedEventHandler(observer); // depending on ownership of port, we could Dispose it here too }); }
public ZWaveChannel(ISerialPort port) { if ((Port = port) == null) { throw new ArgumentNullException(nameof(port)); } _semaphore = new SemaphoreSlim(1, 1); }
/// <summary>Creates an observable sequence of characters from the specified serial port.</summary> /// <param name="port">The port that will be the data source.</param> /// <returns><see cref="IObservable{Char}" /> - an observable sequence of characters.</returns> /// <remarks> /// This code suggested by Bart De Smet [MVP] at /// https://social.msdn.microsoft.com/Forums/en-US/5a12822d-92a6-4ff3-9a37-9bcce83dae0c/how-to-implement-serialport-parser-in-rx?forum=rx /// Bart's code correctly handles OnCompleted and OnError cases. /// </remarks> public static IObservable <char> ToObservableCharacterSequence(this ISerialPort port) { return(Observable.Create <char>(observer => { port.DataReceived += ReactiveDataReceivedEventHandler(port, observer); port.ErrorReceived += ReactiveErrorReceivedEventHandler(observer); return UnsubscribeAction(port, observer); })); }
public ActisenseNGT1(ISerialPort serialPort) : base(serialPort) { // NGT-1 com port settings serialPort.BaudRate = 115200; serialPort.DtrEnable = true; serialPort.RtsEnable = true; //Encoding = System.Text.Encoding.UTF8; }
public void Close() { if (this.port != null) { this.port.SetNotify(null); this.port.Close(); this.port = null; } }
/// <summary> /// Open the hardware interface. /// </summary> public bool Open() { bool success = false; // try { //if (Environment.OSVersion.Platform.ToString().StartsWith("Win") == false) if (!System.IO.File.Exists(portName)) { logger.Error("port does not exist :" + portName); return(success); } var controller = Platform.GetController(); if (controller == null) { logger.Error("controller not available"); return(success); } serialPort = controller.GetPort(portName); /*serialPort = new SerialPort(); * serialPort.PortName = portName;*/ serialPort.SerialSettings.BaudRate_Int = 4800; serialPort.SerialSettings.Parity = Parity.None; serialPort.SerialSettings.DataBits = DataBits.D8; serialPort.SerialSettings.StopBits = StopBits.One; serialPort.SerialSettings.Handshake = Handshake.None; serialPort.BufferSettings.ReadTimeout = 150; serialPort.BufferSettings.WriteTimeout = 150; serialPort.PinStates.Rts_Enable = false; serialPort.PinStates.Dtr_Enable = false; // DataReceived event won't work under Linux / Mono //serialPort.DataReceived += HandleDataReceived; //serialPort.ErrorReceived += HanldeErrorReceived; if (serialPort.IsOpen == false) { serialPort.Open(); } // Send status request on connection //this.WriteData(new byte[] { (byte)X10CommandType.PLC_StatusRequest }); serialPort.Uart.DiscardInBuffer(); serialPort.Uart.DiscardOutBuffer(); success = true; } catch (Exception e) { logger.Error(e); } return(success); }
public async Task OpenAsync(SerialPortInfo portInfo) { _serialPort = _deviceManager.CreateSerialPort(portInfo); await _serialPort.OpenAsync(); StartListening(); IsConected = true; }
public static void Init(ISerialPort port) { messageWriteQueue = new QueueThreadWorker(SendMessage); //messageReadQueue = new QueueThreadWorker(ProcessMessage); iBus = port; iBus.DataReceived += new SerialDataReceivedEventHandler(iBus_DataReceived); Inited = true; }
public void TestInitialize() { _mockPort = Substitute.For<ISerialPort>(); _mockEncoder = Substitute.For<IEncoder>(); _arduino = new ArduinoController(_mockPort, _mockEncoder) { RodType = eRod.GoalKeeper }; _arduino.MaxTicks = MAX_TICKS; }
public void Dispose() { messageWriteQueue.Dispose(); _port.DataReceived -= bus_DataReceived; if (_port.IsOpen) { _port.Close(); } _port = null; }
void InitSerial(SerialPortName portName, int baud) { // instantiate our serial port this.classicSerialPort = Device.CreateSerialPort(portName, baud); Console.WriteLine("\tCreated"); // open the serial port this.classicSerialPort.Open(); Console.WriteLine("\tOpened"); }
public void ConstructHoldFingersTest(int[] selectedFingers, string expected) { ISerialPort port = mock.Object; SerialCommand command = new SerialCommand(port); string actual = command.MoveFingers(selectedFingers, true); Assert.Equal(expected, actual); }
//disconnect from the active connection public void Disconnect() { if (serialPort != null) { serialPort.CloseSerial(); } serialPort = null; badConnections.Add(PortName); StopAllCoroutines(); }
/// <summary> /// Gets an observable sequence of all the characters received by a serial port. /// </summary> /// <param name="port">The port that is to be the data source.</param> /// <returns><see cref="IObservable{char}" /> - an observable sequence of characters.</returns> public static IObservable <char> ReceivedCharacters(this ISerialPort port) { var observableEvents = port.ObservableDataReceivedEvents(); var observableCharacterSequence = from args in observableEvents where args.EventArgs.EventType == SerialData.Chars from character in port.ReadExisting() select character; return(observableCharacterSequence); }
public static void Init(ISerialPort port) { if (!Instance.Inited) { Instance.InitPort(port, PORT_NAME); } else { throw new Exception(nameof(Manager) + " already inited."); } }
public async Task DisconnectAsync() { lock (this) { if (!Connected) { AddStatusMessage(StatusMessageTypes.Warning, "Can not disconnected - Not Connected"); return; } Mode = OperatingMode.Disconnected; Connected = false; MachinePosition = new Vector3(); WorkspacePosition = new Vector3(); Status = "Disconnected"; DistanceMode = ParseDistanceMode.Absolute; Unit = ParseUnit.Metric; Plane = ArcPlane.XY; UnacknowledgedBytesSent = 0; lock (_queueAccessLocker) { _toSend.Clear(); _toSendPriority.Clear(); _sentQueue.Clear(); } } if (_port != null) { await _port.CloseAsync(); AddStatusMessage(StatusMessageTypes.Info, "Closed Serial Port"); _port = null; } if (_socketClient != null) { await _socketClient.CloseAsync(); _socketClient.Dispose(); _socketClient = null; } if (this._cancelSource != null) { _cancelSource.Cancel(); _cancelSource = null; } AddStatusMessage(StatusMessageTypes.Info, "Disconnected"); }
public bool Send(string strcmd) { bool rt = false; int errorCode = 0; string errorMsg = "发送成功"; try { if (ISerialPort == null || (!ISerialPort.IsOpen)) { errorCode = 1; if (ISerialPort == null) { errorMsg = "SerialPort对象为空"; errorMsg = string.Format("串口:[{0}]{1}", ISerialPort.PortName, errorMsg); } if (!ISerialPort.IsOpen) { errorMsg = "SerialPort对象未连接"; errorMsg = string.Format("串口:[{0}]{1}", ISerialPort.PortName, errorMsg); } return(rt); } // Convert to byte array and send. byte[] cmdBuffer = Encoding.Default.GetBytes(strcmd); ISerialPort.Write(cmdBuffer, 0, cmdBuffer.Length); rt = true; } catch (Exception ex) { Close(); Property.IsConnected = false; if (ClosedEvt != null) { System.Windows.Forms.Control target = ClosedEvt.Target as System.Windows.Forms.Control; errorCode = 1; errorMsg = string.Format("串口[{0}]{1}", ISerialPort.PortName, ex.Message); if (target != null && target.InvokeRequired) { //非创建控件线程同步调用事件:SerialPortClosed target.Invoke(ClosedEvt, new object[] { errorCode, errorMsg }); } else { //创建控件线程调用事件 ClosedEvt(Property, errorCode, errorMsg); } } } finally { } return(rt); }
private void ConnectionLost() { puzzletConnection.PuzzletDisconnected(); if (serialPort != null) { serialPort.CloseSerial(); } serialPort = null; badConnections.Add(PortName); StartCoroutine(RetryConnection()); }
public async Task CloseAsync() { _isActive = false; _cancellationTokenSource.Cancel(); await _serialPort.CloseAsync(); _serialPort.Dispose(); _serialPort = null; IsConnected = false; }
public static void Init(ISerialPort port, ThreadPriority threadPriority = ThreadPriority.AboveNormal) { if (!Instance.Inited) { Instance.InitPort(port, PORT_NAME, threadPriority); } else { throw new Exception(nameof(DBusManager) + " already inited."); } }
private void ConfigVm(Session vmSession) { /* Check serial port */ ISerialPort dbgPort = vmSession.Machine.GetSerialPort(0); // Path must be set BEFORE setting HostMode! dbgPort.Path = @"\\.\pipe\" + namedPipeName; // Name must always have this special prefix dbgPort.HostMode = PortMode.PortMode_HostPipe; dbgPort.Server = 1; dbgPort.Enabled = 1; }
public void ConstructStatusCheckTest() { ISerialPort port = mock.Object; SerialCommand command = new SerialCommand(port); string expected = "0"; string actual = command.StatusCheck(); Assert.Equal(expected, actual); }
public void InitPort(ISerialPort port, string queueThreadWorkerName = "", ThreadPriority threadPriority = ThreadPriority.AboveNormal) { messageWriteQueue = new QueueThreadWorker(SendMessage, queueThreadWorkerName, threadPriority); //messageReadQueue = new QueueThreadWorker(ProcessMessage); _port = port; _portName = queueThreadWorkerName; _port.DataReceived += bus_DataReceived; Inited = true; }
/// <summary>Initializes a new instance of the <see cref="SerialCommunicationChannel" /> class.</summary> /// <param name="endpoint">The device endpoint.</param> /// <param name="port">The port.</param> /// <exception cref="System.ArgumentException">Expected a SerialDeviceEndpoint</exception> public SerialCommunicationChannel(DeviceEndpoint endpoint, ISerialPort port = null) { if (!(endpoint is SerialDeviceEndpoint)) { throw new ArgumentException("Expected a SerialDeviceEndpoint"); } this.endpoint = endpoint as SerialDeviceEndpoint; Port = port ?? CreateSerialPort(this.endpoint); observableReceiveSequence = Port.ToObservableCharacterSequence() .Trace("Serial Receive") .Publish(); }
public ZWaveChannel(ISerialPort port) { if ((Port = port) == null) { throw new ArgumentNullException(nameof(port)); } _semaphore = new SemaphoreSlim(1, 1); _processEventsTask = new Task(() => ProcessQueue(_eventQueue, OnNodeEventReceived)); _transmitTask = new Task(() => ProcessQueue(_transmitQueue, OnTransmit)); _portReadTask = new Task(() => ReadPort(Port)); }
private async Task Disconnect(bool join) { await Task.Delay(5); Logger?.LogTrace($"Disconnecting: {join.ToString()}"); Aborted = true; _serialPortCancellationTokenSource?.Cancel(); if (join && _readThread != null) { try { _readThread.Abort(); } catch (PlatformNotSupportedException) { // ignore } } _readThread = null; if (join && _writeThread != null) { while (!_writeThread.Join(100)) { await Task.Delay(1); _autoEvent.Set(); } } _writeThread = null; if (_serialPort != null) { try { _serialPort.Close(); } catch (IOException) { // ignore exception } _serialPortCancellationTokenSource?.Dispose(); _serialPortScope?.Dispose(); _serialPort = null; _serialPortCancellationTokenSource = null; } Logger?.LogTrace($"Disconnected: {join.ToString()}"); }
protected override void bus_DataReceived(object sender, SerialDataReceivedEventArgs e) { ISerialPort port = (ISerialPort)sender; if (port.AvailableBytes == 0) { Logger.Trace("Available bytes lost! " + port.ToString()); return; } lock (bufferSync) { byte[] data = port.ReadAvailable(); if (messageBufferLength + data.Length > messageBuffer.Length) { Logger.Trace("Buffer overflow. Extending it. " + port.ToString()); byte[] newBuffer = new byte[messageBuffer.Length * 2]; Array.Copy(messageBuffer, newBuffer, messageBufferLength); messageBuffer = newBuffer; } if (data.Length == 1) { messageBuffer[messageBufferLength++] = data[0]; } else { Array.Copy(data, 0, messageBuffer, messageBufferLength, data.Length); messageBufferLength += data.Length; } while (messageBufferLength >= DBusMessage.PacketLengthMin || messageBufferLength >= DS2Message.PacketLengthMin) { Message dBusMessage = DBusMessage.TryCreate(messageBuffer, messageBufferLength); Message ds2Message = DS2Message.TryCreate(messageBuffer, messageBufferLength); Message m = ds2Message ?? dBusMessage; if (m == null) { if (!DBusMessage.CanStartWith(messageBuffer, messageBufferLength)) { Logger.Trace("Buffer skip: non-dBus data detected: " + messageBuffer[0].ToHex()); SkipBuffer(1); continue; } return; } ProcessMessage(m); //#if DEBUG //m.PerformanceInfo.TimeEnqueued = DateTime.Now; //#endif //messageReadQueue.Enqueue(m); SkipBuffer(m.PacketLength); } lastMessage = DateTime.Now; } }
/// <summary> /// Create a new SerialLcd object. /// </summary> /// <param name="config">TextDisplayConfig object defining the Lcd dimension (null will default to 16x2).</param> /// <param name="baudRate">Baud rate to use (default = 9600).</param> /// <param name="parity">Parity to use (default is None).</param> /// <param name="dataBits">Number of data bits (default is 8 data bits).</param> /// <param name="stopBits">Number of stop bits (default is one stop bit).</param> public SerialLcd(IIODevice device, SerialPortName port, TextDisplayConfig config = null, int baudRate = 9600, Parity parity = Parity.None, int dataBits = 8, StopBits stopBits = StopBits.One) { if (config == null) { // assume a 16x2 Lcd. DisplayConfig = new TextDisplayConfig() { Height = 2, Width = 16 }; } else { DisplayConfig = config; } comPort = device.CreateSerialPort(port, baudRate, dataBits, parity, stopBits); comPort.Open(); // configure the Lcd controller for the appropriate screen size byte lines = 0; byte characters = 0; switch (DisplayConfig.Width) { case 16: characters = (byte)LcdDimensions.Characters16Wide; break; case 20: characters = (byte)LcdDimensions.Characters20Wide; break; default: throw new ArgumentOutOfRangeException(nameof(config.Width), "Display width should be 16 or 20."); } switch (DisplayConfig.Height) { case 2: lines = (byte)LcdDimensions.Lines2; break; case 4: lines = (byte)LcdDimensions.Lines4; break; default: throw new ArgumentOutOfRangeException(nameof(config.Height), "Display height should be 2 or 4 lines."); } Send(new[] { ConfigurationCommandCharacter, characters, ConfigurationCommandCharacter, lines }); Thread.Sleep(10); }
public async Task OpenAsync(ISerialPort serialPort) { _serialPort = serialPort; await _serialPort.OpenAsync(); StartListening(); ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessReceiveQueue), null); ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessSendQueue)); IsConnected = true; }
public DataJson ReadJson(ISerialPort port) { // "{ \"sensNr\":1,\"instNr\":13,\"bRet\":20,\"data\":[48756080,2302038]}" return(JsonConvert.DeserializeObject <DataJson>(port.ReadLine())); //File.ReadAllText(@"D:\HBO\Semester 4\PTT\jsontekst2.json") //// deserialize JSON directly from a file //using (StreamReader file = File.OpenText(@"D:\HBO\Semester 4\PTT\jsontekst.json")) //{ // JsonSerializer serializer = new JsonSerializer(); // return (Sent)serializer.Deserialize(file, typeof(Sent)); //} }
public void connect(ISerialPort sp) { if (connectionState == ConnectionState.Connected) { throw new InvalidOperationException(); } if (sp == null) { throw new ArgumentNullException("sp"); } if (!sp.IsOpen) { sp.Open(); } _sp = sp; connectionState = ConnectionState.Connected; }
private bool CheckIfHeater(ISerialPort port) { if (!port.IsOpen) { throw new ArgumentException("The serial port has to be open to check if the heater is connected to it.", "port"); } HeaterCommand cmd = HeaterCommand.build(HeaterCommand.commandType.MagicByte); byte[] buff; try { port.Write(cmd.toByte()); buff = port.ReadBytes(1); } catch (TimeoutException) { return false; } return buff[0] == magicResponse; }
public SerialStatusbarPortMenu(ISerialPort iSerialPort, CurrentDataDevice currentDataDevice) : base(iSerialPort, currentDataDevice) { }
public TerminalRunner(ITerminal terminal, ISerialPort dataDevice) { Log.Debug("TerminalRunner created"); _dataDevice = dataDevice; _terminal = terminal; }
protected BaseDevice(ISerialPort serialPort) { serialPort.DataReceived += OnSerialPortDataReceived; }
public SerialStatusbarStatusLabel(ISerialPort serialPort, CurrentDataDevice currentDataDevice) : base(serialPort, currentDataDevice) { }
public Dictionary<PropertyKey, int> Connect(InsteonConnection connection) { port?.Close(); port = SerialPortCreator.Create(connection); port.Open(); byte[] input = { Constants.MessageStartByte, (byte)InsteonModemSerialCommand.GetImInfo }; var properties = new Dictionary<PropertyKey, int>(); var response = new List<byte>(); try { for (int i = 1; i <= Constants.negotiateRetries; ++i) { logger.DebugFormat("TX: {0}", Utilities.ByteArrayToString(input)); port.Write(input); port.Wait(Constants.openTimeout); var output = port.ReadAll(); if (output.Length <= 0) { Thread.Sleep(100); continue; // try again } response.Clear(); response.AddRange(output); while (output.Length > 0 && response.Count < 9) { port.Wait(Constants.openTimeout); output = port.ReadAll(); response.AddRange(output); } logger.DebugFormat("RX: {0}", Utilities.ByteArrayToString(response.ToArray())); int offset = 0; // determins the start location of the actual message returned for (int j = 0; j < response.Count; ++j) { if (response[j] == Constants.MessageStartByte) { offset = j; } } if (response.Count >= offset + 9 && response[offset] == Constants.MessageStartByte && response[offset + 1] == (byte)InsteonModemSerialCommand.GetImInfo && response[offset + 8] == Constants.MessageEndByte) { properties[PropertyKey.Address] = response[offset + 2] << 16 | response[offset + 3] << 8 | response[offset + 4]; properties[PropertyKey.DevCat] = response[offset + 5]; properties[PropertyKey.SubCat] = response[offset + 6]; properties[PropertyKey.FirmwareVersion] = response[offset + 7]; break; // found } } } finally { if (response.Count == 0) { throw new IOException("Failed to open port, timeout waiting for response from port."); } if (properties.Keys.Count == 0) { port.Close(); port = null; throw new IOException("Failed to open port, unable to negotiate with INSTEON controller."); } } logger.DebugFormat("Successfully negotiated with INSTEON controller on connection '{0}'...", connection); port.SetNotify(DataAvailable); return properties; }
public Dictionary<PropertyKey, int> Connect(InsteonConnection connection) { if (this.port != null) this.port.Close(); this.port = SerialPortCreator.Create(connection); this.port.Open(); var input = new byte[] { 0x02, 0x60 }; var properties = new Dictionary<PropertyKey, int>(); var response = new List<byte>(); try { for (var i = 1; i <= Constants.negotiateRetries; ++i) { Log.WriteLine("TX: {0}", Utilities.ByteArrayToString(input)); this.port.Write(input); this.port.Wait(Constants.openTimeout); var output = this.port.ReadAll(); if (output.Length <= 0) { Thread.Sleep(100); continue; // try again } response.Clear(); response.AddRange(output); while (output.Length > 0 && response.Count < 9) { this.port.Wait(Constants.openTimeout); output = this.port.ReadAll(); response.AddRange(output); } Log.WriteLine("RX: {0}", Utilities.ByteArrayToString(response.ToArray())); var offset = 0; for (var j = 0; j < response.Count; ++j) if (response[j] == 0x02) offset = j; if (response.Count >= offset + 9 && response[offset] == 0x02 && response[offset + 1] == 0x60 && response[offset + 8] == 0x06) { properties[PropertyKey.Address] = response[offset + 2] << 16 | response[offset + 3] << 8 | response[offset + 4]; properties[PropertyKey.DevCat] = response[offset + 5]; properties[PropertyKey.SubCat] = response[offset + 6]; properties[PropertyKey.FirmwareVersion] = response[offset + 7]; break; // found } } } finally { if (response.Count == 0) throw new IOException("Failed to open port, timeout waiting for response from port."); if (properties.Keys.Count == 0) { this.port.Close(); this.port = null; throw new IOException("Failed to open port, unable to negotiate with INSTEON controller."); } } Log.WriteLine("Successfully negotiated with INSTEON controller on connection '{0}'...", connection); this.port.SetNotify(this.DataAvailable); return properties; }
/// <summary> /// Constructor /// </summary> /// <param name="comPort">COM port to open as string</param> /// <param name="encoder">Encoder for actions</param> public ArduinoController(string comPort, IEncoder encoder) { _comPort = null; ComPortName = comPort; _encoder = encoder; _isInitialized = false; MaxTicks = 0; }
/// <summary> /// Constructor receives ready serial port (USED in UT) /// </summary> /// <param name="openPort"></param> /// <param name="encoder">Encoder for actions</param> public ArduinoController(ISerialPort openPort, IEncoder encoder) { _comPort = openPort; _encoder = encoder; _isInitialized = false; MaxTicks = 0; }
public ParityMenu(ISerialPort serialPort) : base(serialPort) { }
public FlowControlMenu(ISerialPort serialPort) : base(serialPort) { }
public DataBitsMenu(ISerialPort serialPort) : base(serialPort) { }
public StopBitsMenu(ISerialPort serialPort) : base(serialPort) { }
protected SerialSettingsMenu(ISerialPort serialPort) { SerialPort = serialPort; SerialPort.PropertyChanged += (sender, args) => UpdateCheckedStates(args.PropertyName); }
public BaudRateMenu(ISerialPort serialPort) : base(serialPort) { }
public PortMenu(ISerialPort serialPort, CurrentDataDevice terminal) : base(serialPort) { _dataDevice = terminal; }
public void disconnect() { connectionState = ConnectionState.NotConnected; _sp = null; }
protected void ReadBytes(ISerialPort port, int count, ref byte[] buffer) { int bytesRead = 0; while (isConnected && (bytesRead < count)) { try { buffer[bytesRead] = port.ReadByte(); bytesRead++; } catch(TimeoutException) { // Continue trying to read while connected } } }
public ZWaveController(ISerialPort port) : this(new ZWaveChannel(port)) { }
/// <summary> Default Constructor. </summary> /// <param name="sport"> The serial port. </param> public SerialStream(ISerialPort sport) { _SPort = sport; }
/// <summary> /// Open Arduino Com Port /// </summary> /// <exception cref="InvalidOperationException">Thrown in case of error while opening port</exception> public void OpenSerialPort() { if (_comPort == null) _comPort = new SerialPortWrapper(ComPortName, Communication.BAUDRATE); int currentRetry = 0; while (currentRetry < MAX_OPEN_PORT_RETRIES) { try { Log.Print(String.Format("Opening Arduino port {0}...", ComPortName), eCategory.Info, LogTag.COMMUNICATION); _comPort.Open(); Log.Print(String.Format("Arduino port {0} is open!", ComPortName), eCategory.Info, LogTag.COMMUNICATION); return; } catch (Exception ex) { currentRetry++; if (currentRetry < MAX_OPEN_PORT_RETRIES) { Log.Print(String.Format("Unable to open arduino port {0}, will retry after {1}. [Retry {2} of {3}]", _comPort, WAIT_ON_FAIL_OPENING_PORT, currentRetry, MAX_OPEN_PORT_RETRIES), eCategory.Warn, LogTag.COMMUNICATION); Thread.Sleep(WAIT_ON_FAIL_OPENING_PORT); } else { throw new InvalidOperationException(String.Format("[{0}] Error opening Arduino port {1}. Reason: {2}", MethodBase.GetCurrentMethod().Name, ComPortName, ex.Message), ex); } } } }
/// <summary> Default Constructor. </summary> /// <param name="sport"> The serial port. </param> public SerialReader(ISerialPort sport) : base(new SerialStream(sport), sport.BufferSettings.Encoding, true) { _SPort = sport; }
public SerialStatusbarBaudMenu(ISerialPort serialPort, CurrentDataDevice currentDataDevice) : base(serialPort, currentDataDevice) { _baudRates = new List<int>(new[] { 110, 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 }); }