Windows and Linux compatible Serial (RS232) comm. code in C++ - Questions
This is a discussion on Windows and Linux compatible Serial (RS232) comm. code in C++ - Questions ; Is there any C++ code for Serial (RS232) communication compatible both with
Windows and Linux ?...
-
Windows and Linux compatible Serial (RS232) comm. code in C++
Is there any C++ code for Serial (RS232) communication compatible both with
Windows and Linux ?
-
Re: Windows and Linux compatible Serial (RS232) comm. code in C++
wrote:
> Is there any C++ code for Serial (RS232) communication
> compatible both with
> Windows and Linux ?
Only using the pure System API? As long as you don't want to set
comm parameters (speed, databits, parity): Yes. Just do an
char comm_dev[80];
int const comm_nr;
#ifdef WIN32
#define COMM "COM%d"
#elseif
#define COMM "/dev/ttyS%d"
#endif
sprintf(comm_dev, COMM, comm_nr);
FILE *comm_f=fopen(comm_dev, "w+");
// your comm here
fclose(comm_f);
However if you want to set comm parameteres you will have to use
an OS dependent API. For windows that means that you will have
to use it's ugly file API.
--
Wolfgang Draxinger
-
Re: Windows and Linux compatible Serial (RS232) comm. code in C++
wrote:
> Is there any C++ code for Serial (RS232) communication compatible both
> with
> Windows and Linux ?
Sort of.... It you use the Qt-toolkit, there is an extension called
QExtSerialPort that provides what youŕe looking for.
Regards
Peter