STDMETHODIMP CSensatronicsModelF::put_ComPort(BSTR newVal) { std::wstring ComPort(newVal); int nComPort = -1; if(ComPort.length() == 0) { return E_INVALIDARG; } else { try { nComPort = boost::lexical_cast<int>(ComPort); } catch(boost::bad_lexical_cast&) { return E_INVALIDARG; } if(nComPort <= 0) return E_INVALIDARG; m_bstrComPort = CComBSTR(ComPort.c_str()).Copy(); return S_OK; } }
void tH3000LinkRx::SetComPort( tSerialPort::eComPort comPort ) { if( ComPort() != comPort ) { tSerialPortUser::SetComPort(comPort); SetPortType(tSerialPortUser::eSPDT_H3000); RegisterRxSerialUser(); } }
void RbFirmataController::Load(StdUtils::CStdXml &oXml) { RobotIOControl::Load(oXml); oXml.IntoElem(); ComPort(oXml.GetChildString("ComPort", m_strComPort)); BaudRate(oXml.GetChildInt("BaudRate", m_iBaudRate)); oXml.OutOfElem(); }
bool RbFirmataController::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError) { std::string strType = Std_CheckString(strDataType); if(RobotIOControl::SetData(strDataType, strValue, false)) return true; if(strType == "COMPORT") { ComPort(strValue); return true; } else if(strType == "BAUDRATE") { BaudRate((int) atoi(strValue.c_str())); return true; } //If it was not one of those above then we have a problem. if(bThrowError) THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType); return false; }