View Full Version: Serial port access with C++ under Linux

C++ Learning Community > C++ for Linux > Serial port access with C++ under Linux


Title: Serial port access with C++ under Linux
Description: Serial port acess, Linux.


SummitWulf - August 11, 2005 08:08 AM (GMT)
Hi,

I have a Linux C program for accessing and controlling the serial port of a PC, that I want to convert to C++. My compiler is gcc/g++.

It seems to me that I will either want to use directly, or find equivalents for, some of the header files and functions used in my original program. The C header files, for example, are:

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include </usr/include/asm/termios.h>

I can see replacing stdio.h with iostream, but from there on... I'm not sure. Can I simply include the others - and use their functions - without modification? That seems a bit unlikely. If not, how do I find suitable functional replacements?

I'm new to C++, so I'm a bit stuck with this issue. I'd very much appreciate any help or advice.

SummitWulf

KTC - August 11, 2005 02:35 PM (GMT)
Why do you need to convert it anyway ? What are you trying to do or trying to achieve ?

SummitWulf - August 12, 2005 09:08 AM (GMT)
[QUOTE]

I want to convert the program because I am trying to learn C++ and I would like to write an extension to this program in C++. Plus, if I want to write future software to access the serial port from C++, I need to know how to do it.

The program drives serial port lines to control an external analogue-to-digital converter that I built. Data is read as a conventional serial data stream.




Hosted for free by InvisionFree