Re: Windows and Linux compatible Serial (RS232) comm. code in C++
From: Wolfgang Draxinger (wdraxinger_at_darkstargames.de)
Date: 02/15/05
- Previous message: DM McGowan II: "Re: OSS Image Editing?"
- In reply to: Khan: "Windows and Linux compatible Serial (RS232) comm. code in C++"
- Next in thread: P.M. Groen: "Re: Windows and Linux compatible Serial (RS232) comm. code in C++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 15 Feb 2005 12:26:57 +0100
<Khan> 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
- Previous message: DM McGowan II: "Re: OSS Image Editing?"
- In reply to: Khan: "Windows and Linux compatible Serial (RS232) comm. code in C++"
- Next in thread: P.M. Groen: "Re: Windows and Linux compatible Serial (RS232) comm. code in C++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|