Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial Communications

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

I've got some problem to know which include file i have to declare to use the functions for serial communications (SetCommPort,...)
Thanks for your help

Eric le Rouge
 
Never heard of SetCommPort but the majority of the others (SetCommState, SetCommMask, CreateFile etc.) are declared in winbase.h.

HTH
William
Software Engineer
ICQ No. 56047340
 
Ok but it says I've got some errors in my file winbase.h...
What should I do?
 
What are the errors? William
Software Engineer
ICQ No. 56047340
 
The function you were looking for was SetupComm. You should use it with something like this:

...
HANDLE handle = CreateFile("COM1", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

SetupComm(handle, 2048, 2048);
if (!SetCommState(handle, &DCB)){
//Handle error here
}
...

The DCB is a structure that hold the parameters for the com port: baud rate, parity, etc... You just pass a pointer to that structure to the SetCommState function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top