public bool Connect(ref string sErrMsg, ref string sIdInfo) { bool bRet = true; StringBuilder sIdn = new StringBuilder(1024); StringBuilder sErrorMessage = new StringBuilder(1024); int iError; ////////////////////////////////////////////////////////////////////////// // connect to the controller over RS-232 (COM port 1, baudrate 115200). // ////////////////////////////////////////////////////////////////////////// m_iControllerId = PICommand.ConnectRS232(1, 115200); if (m_iControllerId < 0) { iError = PICommand.GetError(m_iControllerId); PICommand.TranslateError(iError, sErrorMessage, sErrorMessage.Capacity); sErrMsg = "ERROR From ConnectRS232 " + iError.ToString() + ": " + sErrorMessage.ToString(); bRet = false; } else { //////////////////////////////////// // Get the IDeNtification string. // //////////////////////////////////// if (PICommand.qIDN(m_iControllerId, sIdn, sIdn.Capacity) == 0) { iError = PICommand.GetError(m_iControllerId); PICommand.TranslateError(iError, sErrorMessage, sErrorMessage.Capacity); sErrMsg = "ERROR From IDN? " + iError.ToString() + ": " + sErrorMessage.ToString(); bRet = false; } else { sIdInfo = sIdn.ToString(); } } return(bRet); }