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 ?...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Windows and Linux compatible Serial (RS232) comm. code in C++

  1. 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 ?



  2. 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


  3. 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

+ Reply to Thread