Thread: Serial Port

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    Serial Port

    Regarding this: http://cboard.cprogramming.com/showthread.php?t=25784

    http://mc-computing.com/Languages/Se...bios_serialcom
    Where can I get a copy of bios.h? It seems there are many header files under that name, so I need the one that allows me to use _bios_serialcom/communicate with a serial port.

    Actually, any way of reading/writing a COM port in C/C++ on Win32 would be much appreciated. I've Googled for this, thinking it'd be simple, but all the results involve huge blocks of code. The Microsoft KB solution sure is nice and simple...and it doesn't work, of course.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by raylu View Post
    Regarding this: http://cboard.cprogramming.com/showthread.php?t=25784

    http://mc-computing.com/Languages/Se...bios_serialcom
    Where can I get a copy of bios.h? It seems there are many header files under that name, so I need the one that allows me to use _bios_serialcom/communicate with a serial port.
    Don't bother.

    Quote Originally Posted by raylu View Post
    Actually, any way of reading/writing a COM port in C/C++ on Win32 would be much appreciated. I've Googled for this, thinking it'd be simple, but all the results involve huge blocks of code.
    Such it is. But that's what you've got.

    Maybe you may find something better here:
    http://www.lvr.com/serport.htm
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    ?

    Why not bother?

    And I've seen that page already.

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Because programming for DOS on Windows XP is generally stupid unless you're working in a real DOS environment, in which case your target machine won't be running Windows XP.

  5. #5
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    CreateFile() can be used in Win32 to access a serial port. Pass "COM1" (or whatever port you want) as the filename. From there, use ReadFile and WriteFile to send/recv data. CloseHandle() when you're done.

    If you have the Win32 API reference that comes in a .hlp file, the "Communications" page, and those following, have what you want. This seems to be the corresponding MSDN section.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

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. Can't Read From Serial Port
    By HalNineThousand in forum Linux Programming
    Replies: 14
    Last Post: 03-20-2008, 05:56 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Reading and writing to a serial port
    By SwarfEye in forum C Programming
    Replies: 2
    Last Post: 08-18-2006, 12:28 AM
  5. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM