Thread: Using the serial (COM) Port

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    278

    Using the serial (COM) Port

    I am writing software for a Single Board computer (SBC) running DOS 6.2. I need to interface with a device via a serial (COM) port. I've searched this board (without much success) as well as the internet, but I'm having trouble getting started with the basics. It seems as though all the sources I've found start at point B, but I'm still at point A. I could be missing something though. I'm using C (Turbo C 3.0). Any directions to a good source of information or the information itself is much appreciated. If you need more information, please let me know.

  2. #2
    Registered User
    Join Date
    Jan 2009
    Posts
    26
    find the com port address, usually they are:
    com1 0x3f8
    com2 0x2f8
    com3 0x3e8
    com4 0x2e8

    then in turbo c you can use inport() and outport() functions that are declared in dos.h

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    278
    So I just outport the byte I want to send or inport when I want to receive a byte?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No, you have to configure the port (such as the bitrate, number of bits, type of parity, stop bits, etc), then you will have to handle flow-control in some way (you can't just stuff a whole lot of characters into the serial port and hope that they get sent - there are registers in the serial controller that tell you if there is space available to send more or not).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

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