Communicating to a serial device using Dev-C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dwurmfeld
    New Member
    • Mar 2008
    • 9

    Communicating to a serial device using Dev-C++

    I would like to play with an older GPS unit that has a serial interface. I am using XP and Dev-C++. I have some console based experience in C, but no windows experience to speak of. To remedy that, I would like to write a windows app that will simply monitor the output of the GPS, and send commands to the GPS interactively from a text box.

    My questions:
    Is Dev-C++ suitable to the task?
    Is the "win32" library used, or is there a specific library to use to specify a com port?
    In either case, is there a good reference (preferably free) for the proper library?

    Thanks,
    David
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Serial port access is part of the standard WIN32 API, you don't need any additional libraries and youcan findmost of what you need on MSDN.

    Look up the functions

    CloseHandle Closes an open object handle.
    CreateFile Creates or opens a file, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, or named pipe.
    ReadFile Reads data from a file, starting at the position that is indicated by a file pointer. This function can operate synchronously and asynchronously.
    WriteFile Writes data to a file at a position that a file pointer specifies. This function can operate synchronously and asynchronously.

    And optionally
    ReadFileEx Reads data from a file asynchronously.
    ReadFileScatter Reads data from a file and stores it in an array of buffers.
    WriteFileEx Writes data to a file. This function reports the completion status asynchronously by calling a specified completion routine when writing is completed or canceled and when the calling thread is in an alertable wait state.
    WriteFileGather Retrieves data from an array of buffers, and then writes the data to a file.

    from MSDN File Management functions, yes I know they are called file management functions and you want to use a serial port but in true MS fashion they are poorly named and in fact access any handle with a data stream type.

    Additionally you will want to look up the specific com port functions available as Communication Functions.

    And here is the overview URL Communications Resources

    Comment

    • dwurmfeld
      New Member
      • Mar 2008
      • 9

      #3
      Originally posted by Banfa
      ... MSDN File Management functions, yes I know they are called file management functions and you want to use a serial port but in true MS fashion they are poorly named and in fact access any handle with a data stream type.

      Additionally you will want to look up the specific com port functions available as Communication Functions.

      And here is the overview URL Communications Resources
      Thanks, this is exactly the help I needed, I was not aware there were online Win32 API references. I have been in the embedded community for too long!

      David

      Comment

      Working...