Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Initialize two comm port in visual C++

Status
Not open for further replies.

ryusgnal

Advanced Member level 4
Full Member level 1
Joined
Oct 4, 2005
Messages
102
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,298
Location
Malaysia
Activity points
1,992
setcommport

I use this command to initialize my Comm Port in port 1

m_Comm.SetCommPort(1);
m_Comm.SetSettings("9600, n, 8, 1");
m_Comm.SetPortOpen(TRUE);

How to initialize one more comm port which is in port 2?

How to control both comport? Example: I want to receive data from comm1 and send whatever i receive to comm2.

Thank you...........
 

setcommport(

its quite simple. You just instantiate another object from Communication object. I don´t know wich object, but, let´s suppose you did this:

COMMSerial Comm;

m_Comm.SetCommPort(1);
m_Comm.SetSettings("9600, n, 8, 1");
m_Comm.SetPortOpen(TRUE);

alright? now, just do this:

COMMSerial Comm_2;

m_Comm_2.SetCommPort(2);
m_Comm_2.SetSettings("9600, n, 8, 1");
m_Comm_2.SetPortOpen(TRUE); .

best regards, and happy holidays

Breno
 

::eek:noncommmscomm1

just add another control, if only your PC has two serial ports.
 

posting comm port event

Yes my PC have two comm port.

am I need to add another "Microsoft Communication Control" (as shown in the picture) or not?

Showing in the picture is what I already did and I already add another comm port initialization as suggested above. when I compile the program, everything is o.k. But when I try to execute the program, nothing happen (the program doesn't executed). Anybody know what is wrong?

Thank you....

**broken link removed**
 

how to do port initialization in c

yes, you will need two control if you use mscomm control.
 

visual c++ profiler com ports

funnynypd said:
yes, you will need two control if you use mscomm control.

But why when I run the program, Nothings happen?
 

m_comm.setcommport(1);

did you initialized the code seperately? and check which port # when there is a COMM event?
 

commport in c++

funnynypd said:
did you initialized the code seperately? and check which port # when there is a COMM event?

for Serial port initialize I do this:

// TODO: Add extra initialization here
m_mscomm.SetCommPort (4);
m_mscomm.SetSettings ("9600,n,8,1");
m_mscomm.SetPortOpen (TRUE);

m_mscomm2.SetCommPort (5);
m_mscomm2.SetSettings ("9600,n,8,1");
m_mscomm2.SetPortOpen (TRUE);

return TRUE; // return TRUE unless you set the focus to a control
}


If there is Comm Event in Port4, I do this:

void CBasicmodemDlg::OnOnCommMscomm1()
{

UpdateData();
CString data;
CString str;
COleVariant myVar;

myVar = m_mscomm.GetInput ();
data = myVar.bstrVal ;

m_rx = m_rx + data;


UpdateData(FALSE);
}


And if there Comm Event in port5, I do this:

void CBasicmodemDlg::OnOnCommMscomm2()
{
// TODO: Add your control notification handler code here
if (m_mscomm2.GetCommEvent()==2)
{
VARIANT in_dat;
in_dat = m_mscomm2.GetInput();
CString strInput(in_dat.bstrVal);
m_tx = m_tx + strInput;
UpdateData(FALSE);
}

}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top