It doesnt work. :((
LongDuyTran
Posts
-
The problem with Serial library for C++ -
The problem with Serial library for C++I'm a beginner with VC++. I tried to do program to communicate with COM port of PC but I failed to use the MSComm lib. After that, I changed to use the "Serial library for VC++" which was written by Ramon de Klein but now I had an error I dont know how to solve. The following sentence is the error: "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1512;}\viewkind4\uc1\pard\f0\fs20 H:\\Program Files\\Microsoft Visual Studio\\MyProjects\\TestXbee\\TestXbeeDlg.cpp(130) : error C2664: 'Open' : cannot convert parameter 2 from 'class CTestXbeeDlg *const ' to 'unsigned long' This conversion requires a reinterpret_cast, a C-style cast or function-style cast }" Now is the part of my program which informed about that error "CString m_strComPort; m_strComPort.Format(TEXT("COM2")); CSerial port; if (port.Open(m_strComPort,this) != ERROR_SUCCESS { AfxMessageBox(TEXT("Unable to open COM"),MB_ICONSTOP | MB_OK); GetParent()->PostMessage(WM_CLOSE); return 0;" Thank you very much
-
Beginner with C++ - Need helps with overload member function errorThat was my bad in typing. I also have that part. I also wanna ask you guys more questions. "void CXbeefixedDlg::InitComboBox() { // ComboBox ComPort m_cboComport.ResetContent(); m_cboComport.AddString("COM1"); m_cboComport.AddString("COM2"); m_cboComport.AddString("COM3"); m_cboComport.AddString("COM4"); m_cboComport.SetCurSel(2); // ComboBox BitRate m_cboBitrate.ResetContent(); m_cboBitrate.InsertString(0,"1200"); m_cboBitrate.InsertString(1,"2400"); m_cboBitrate.InsertString(2,"4800"); m_cboBitrate.InsertString(3,"9600"); m_cboBitrate.InsertString(4,"19200"); m_cboBitrate.InsertString(5,"38400"); m_cboBitrate.InsertString(6,"57600"); m_cboBitrate.InsertString(7,"115200"); m_cboBitrate.InsertString(8,"230400"); m_cboBitrate.SetCursel(3); // Combobox Databit m_cboDatabits.ResetContent(); m_cboDatabits.AddString("4"); m_cboDatabits.AddString("5"); m_cboDatabits.AddString("6"); m_cboDatabits.AddString("7"); m_cboDatabits.AddString("8"); m_cboDatabits.SetCurSel(0); //Combox Stopbit m_cboStopbits.ResetContent(); m_cboStopbits.AddString("1"); m_cboStopbits.AddString("1.5"); m_cboStopbits.AddString("2"); m_cboStopbits.SetCurSel(0); //Combox Paritybit m_cboParitybit.ResetContent(); m_cboParitybit.InsertSring(0,"None"); m_cboParitybit.InsertString(1,"Odd"); m_cboParitybit.InsertString(2,"Even"); m_cboParitybit.InsertString(3,"Mark"); m_cboParitybit.InsertString(4,"Space"); m_cboParitybit.SetCursel(0); } void CXbeefixedDlg::Settings() { // Check whether port was openned, Close port to setup parameter if (m_mscomm.SetPortOpen()) m_mscomm.SetPortOpen(false); // Initialize Port name m_mscomm.SetCommPort(m_cboComport.GetCursel()+1); // Initialize parameters, databits, stopbits, parity bits, flowcontrol CString strBitrate = getCurStrInCombobox(m_cboBitrate); CString strParitybit = getCurStrInCombobox(m_cboParitybit); CString strStopbits = getCurStrInCombobox(m_cboStopbits); CString strDatabits = getCurStrInCombobox(m_cboDatabits); //Cstring strflowcontrol = getCurStrInCombobox(m_FlowControl); CString strSetting; strSetting.Format("%s,%c.%s,%s",strBitrate,strParitybit[1],strStopbits,strDatabits); m_mscomm.SetSettings(strSetting); // Other initializations m_mscomm.SetRThreshold(1); m_mscomm.SetInputlen(2); // Read 2 characters per once time m_mscomm.SetInputBufferSize(1024); m_mscomm.SetInputMode(0); // 0 - Text mode, 1 - Binary Mode m_mscomm.SetPortOpen(true); // Open COM port }
-
Beginner with C++ - Need helps with overload member function errorI'm trying to do programming C++ for my project. I got into trouble when I tried to do program for communicating with COM port(reading information in ComboBox). The error " overloaded member function 'class CString(class CComboBox &a) not found in 'CXeedlg'. Could someone help me to overcome ? overloaded member function not found in 'class' The following is my code: " CString getCurStrInComboBox(const CComboBox &a) { CString str; a.getLBText(a.GetCurSel(),str); return str; } " And the 2nd one is I dont know the reason why the complier informed that InsertString, AddString, GetCursel() arent members of ComboBox. The deadline for my project is coming soon so I will really appreciate all your helps. Thank you very much