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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C++ Serial I/O Comm Library

Status
Not open for further replies.

seeplusplusnewbie

Programmer
Nov 14, 2004
9
US
Does anyone know of a good place that has a tutorial or complete "working" programs that use C++ Serial I/O Comm routines? I have found some stuff, but all have many errors which doesn't help me since I dont know much of it to begin with. I am using MSoft's Visual Studio.NET just to let you know in case some code isnt directly compatible with it.

Thanks :)

P.S. I found a C++ Serial Comm Library from "WSC" but all it had was a .lib file (obviously a library) and a header file. Now I never worked with libraries before in c++ so I didnt know how to use it. What I did was include both in my original source file and it came with so many errors I didnt even try to fix them because as I said I dont know enough about how to use serial comm in c++.

P.P.S. I do know How serial comm works in general just not how to incorporate it into a c++ program.
 
Say for example you have
c:\sercom\h\sercom.h
c:\sercom\lib\sercom.lib

In your source file, you do this
Code:
#include <sercom.h>

Then you goto the menu project->properties

On the configuration drop-down list, select "All configurations", since you're likely to want this to be the same whether you're doing a debug build or a release build.

On the C/C++ tab, select the category "General"
Add the location of sercom.h to the additional include directories. Ie, you add "c:\sercom\h"

On the link tab, select the category "Input"
Add the name of the library to the "Additional Dependencies" field. Ie, you add "sercom.lib"

On the link tab, select the category "General"
Add the path to the library to the "Additional Library Directories" field. Ie, you add "c:\sercom\lib"

--
 
Salem,

It's tough getting your first serial program to work! There are many solutions out there but they all seem to be overly simplistic or impossibly complicated!

Alas if you just need to perform synchronous reads and writes you should consider using a simple serial class such as this one:


Otherwise the solution is going to depend on your environment (mfc, etc); ‘lin serial’ seems to work quite well under any, where as the Microsoft Serial ocx has a nice interface but leaks memory.

Hope this helps a bit,
Good luck
Vladimir Cvejnaovic
 
There are some good Serial I/O packages for Visual C++ 6 at the Code Project site -
I have successfully used the CSerialPort wrapper class by P.J. Naughter. This download include both source and demo code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top