private const int _defaultTimeout = 500; // 50ms default timeout for nonblocking operations. public PTUnit(String comPortName) { ComPort = comPortName; _c = new PTConnection(comPortName); Initialize(); }
/// <summary>Tests the specified serial port to see if there is a PTU controller attached. This method is blocking, but throws if the unit is unresponsive (2000ms timeout).</summary> public static PTFirmwareInfo GetFirmwareInfo(String portName) { PTFirmwareInfo ret; using (PTConnection c = new PTConnection(portName)) { try { c.ResetParser(); c.SetTimeout(500); String firmware = c.GetLine(PTCommand.GetFirmwareVersion); ret = PTFirmwareInfo.FromString(firmware); c.SetTimeout(_defaultTimeout); } catch (TimeoutException) { return(null); } } return(ret); }