delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/29/08:47:41

From: peter DOT acs AT dial DOT pipex DOT com (Peter Stokes)
Newsgroups: comp.os.msdos.djgpp
Subject: Porting problem from Borland C++
Date: Wed, 29 Oct 1997 11:07:12 GMT
Organization: Ashlyn Computer Services Ltd
Lines: 54
Message-ID: <345718dd.193834@news.dial.pipex.com>
NNTP-Posting-Host: user24.max22.msn-uk.pipex.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

As a newbie to DOS C programming, I have successfully used the djg C
compiler to write my own programs from new. The problem I now have is
trying to port some programs which have run successfully on Borland
C++. The programs compile OK but when I try to get access to the com
ports the following routine causes the program to crash or report a
non valid port which is most definetly present.

/*--------------------------------------------------------------------------
 * The setup functions makes sure that the com port number passed to
it
 * is from 1 to 4 and has a valid address associated with it.
 */
uchar Setup(uchar CmPt)
{
     unsigned long *ptr = (unsigned long *) 0x00400000;
     uint SPA;

     /* check to see if it is a valid com port number and address */
     printf("Entering Setup");
     /*SPA = *(ptr+CmPt-1); /* get the address */
     printf("Address is %x", SPA);
     if (CmPt < 1 || CmPt > 4 || !SPA )
        return FL;

     /* serial port initialization */
     outportb(SPA+3,0x83);  /* set DLAB */
     outportb(SPA  ,0x01);  /* bit rate is 115200 */
     outportb(SPA+1,0x00);
     outportb(SPA+3,0x03);  /* 8 dta, 1 stp, no par */
     outportb(SPA+1,0x00);  /* no interrupts */
     outportb(SPA+4,0x03);  /* RTS and DTR on */

     return TR;
}

Can anyone help with either -

1) A modified version of the above which will work

2) An example of writing to the com ports using outportb as above

3) Point me in the direction of documentation where I can get the
relevent info.

Thanks in advance 

Peter
--------------------------------------------
Peter Stokes
Ashlyn Computer Services Ltd
Tel: (UK) 01636-626431 Fax: (UK) 01494-890341
http://acgroup.home.ml.org
---------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019