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

From: Wolfgang Draxinger (wdraxinger_at_darkstargames.de)
Date: 02/15/05

  • Next message: E. Charters: "Re: OSS Image Editing?"
    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
    

  • Next message: E. Charters: "Re: OSS Image Editing?"

    Relevant Pages

    • Re: Driver filter for Serial Port
      ... > Hi Slobodan! ... I have write my Program in API and Use it to Communicate via Comm ... > of your port. ...
      (microsoft.public.win32.programmer.kernel)
    • Re: Windows and Linux compatible Serial (RS232) comm. code in C++
      ... Only using the pure System API? ... comm parameters: ... For windows that means that you will have ...
      (comp.os.linux.development.apps)
    • Re: Displaying on Another Computer
      ... > Does anyone know how to make these work on a network of MS Windows ... machine that would send Tk commands through the comm interface ... to generate the GUI. ... > Do I need to set some access control on the receiving Windows ...
      (comp.lang.tcl)