/// <summary> /// Sets the communication port timeouts. /// </summary> /// <remarks>Assumption made that port is open.</remarks> /// <exception cref="System.Exception"> /// Thrown when a port failure occurs. /// </exception> /// Revision History /// MM/DD/YY who Version Issue# Description /// -------- --- ------- ------ --------------------------------------- /// 08/01/05 bdm 7.13.00 N/A Created private void SetCommTimeouts() { int intErr; string strErrDesc; try { //Set the Comm timeouts based on C12.18 CommTimeouts ct = new CommTimeouts(); ct.ReadIntervalTimeout = 500; //Inter-char timeout ct.ReadTotalTimeoutMultiplier = 1; ct.ReadTotalTimeoutConstant = 1; //miTimeout; ct.WriteTotalTimeoutMultiplier = 0; ct.WriteTotalTimeoutConstant = 0; if (false == PortAPI.SetCommTimeouts(m_hPort, ct)) { intErr = Marshal.GetLastWin32Error(); strErrDesc = m_rmStrings.GetString("SET_COMM_TMOUTS_FAILED"); strErrDesc = string.Format(strErrDesc, intErr); throw (new Exception(strErrDesc)); } } catch (Exception e) { throw (e); } }
internal static bool SetCommTimeouts(IntPtr hPort, CommTimeouts timeouts) { if (FullFramework) { return(Convert.ToBoolean(WinSetCommTimeouts(hPort, timeouts))); } else { return(Convert.ToBoolean(CESetCommTimeouts(hPort, timeouts))); } }
private static extern int WinSetCommTimeouts(IntPtr hFile, CommTimeouts timeouts);