Thread: How to communicate with com port?

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    6

    How to communicate with com port?

    is there any way to communite with LPT and Com port?
    i mean is like assembly language we can send signal to a device but now i want it in C++ programming.

    can anyone give some example?
    how to open the port and the port name in C++.

    10z for help!!!!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Tell us which Operating system and Compiler you're using.

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    6
    windows XP
    using borland C++ and MS Visual C++....

  4. #4
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    This thread might be of some use for you: serial port programming

    Basically, all you need are [assuming you ain't using threads] a handle, and the functions: ReadFile(), WriteFile(), CreateFile(), CloseFile().

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I've posted a simple wrapper class for perform serial port I/O in this thread.

    If you want to learn how to do it yourself: Serial Communications in Win32.

    gg

  6. #6
    Registered User
    Join Date
    Mar 2004
    Posts
    6
    10z i'll try it...

    and how about for the LPT port?

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Depends on the device, but you can read and write to "LPT1" is the same fashion using CreateFile(), ReadFile(), WriteFile() etc...

    gg

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    If you have any problems on this project, or more detailed questions on the subject, I suggest you use the Network / Device Communications board - you're more likely to have your thread read by someone who is quite knowledgeable in that area.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. serial port to poll on request
    By infineonintern in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2009, 06:52 AM
  2. FTP program
    By jakemott in forum Linux Programming
    Replies: 14
    Last Post: 10-06-2008, 01:58 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Segmentation Fault - Trying to access parallel port
    By tvsinesperanto in forum C Programming
    Replies: 3
    Last Post: 05-24-2006, 03:28 AM
  5. how to communicate with serial port using dll
    By sqx in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2003, 06:41 AM