#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    2
    Rep Power
    0

    RS232C datatransfer software samples in C++


    Hallo, am reprogramming a cnc machine formerly programmed in Pascal, i would like to get some samples of data transfer software in Visual c++, C++, or C, or anyother software that i can use for RS232C serial interface. I would like to also get some advice how to about the whole procedural programming.
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,175
    Rep Power
    2222
    Serial I/O is very system-dependent and can be very involved. And, needless to say, not at all portable.

    From your reference to Visual C++, I assume that you are doing this on a Win32 platform (Win9x, WinME, Win2k, or WinXP), which is very fortunate, because it's much easier to do.

    Basically, in the Win32 API, the comm port is treated as a file, so you end up reading from and writing to that file. You load the device control block (DCB) and the timeouts struct (COMMTIMEOUTS), do a CreateFile, and set up the comm settings. Then you do ReadFile and WriteFile calls.

    Do a Google search on the keywords: SetupComm ReadFile WriteFile . With those hits, you will find lots of information and examples.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Location
    Seattle WA
    Posts
    863
    Rep Power
    14
    If you are indeed on a Windows platform, and your project can host ActiveX, there is also an object that makes serial programming rediculously easy. I think it's called MSCOMM, but I can't remember. Most of the documentation is written for VisualBasic, but since everything is exposed through COM, it all applies to C++ as well.

IMN logo majestic logo threadwatch logo seochat tools logo