delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/18/10:25:17

From: spost AT kocrsv01 DOT delcoelect DOT com (Scott E. Post)
Newsgroups: comp.os.msdos.djgpp
Subject: BCserio can't read from port
Date: 18 Nov 1998 15:06:50 GMT
Organization: Delco Electronics
Lines: 60
Message-ID: <72unqa$m48$1@kocrsv08.delcoelect.com>
NNTP-Posting-Host: koptss03.delcoelect.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I need to write a small program to do some serial communications
under Windows 95 (after 15 years using Unix exclusively).  I downloaded
djgpp and Bill Currie's serio package (version 2.1).  I modified the
test.c program that came with the package to simply hang in a loop 
and read from com1.  I hooked up a serial device to continuously transmit
characters to com1.  When I run the program the sio_charready command
never returns that there are characters in the buffer.  Also, sio_getspeed
returns what looks suspiciously like a bad number (327728).

I tried removing com1 from the win95 settings and that didn't help.  This
is on an IBM Thinkpad in a docking station.  I can read from the serial
port using bios calls that come with another (proprietary) compiler, so
I know there is data getting to the serial port.

Attached is the code.  Any ideas?

--
Scott Post    spost AT koptss03 DOT delcoelect DOT com

--------------------------------------------------------------------------
#include <stdio.h>
#include <pc.h>
#include <keys.h>
#include <dpmi.h>
#include "serio.h"

#define b2400        48
#define com1         0x3f8

int main()
{
	int done=0,c;
	SioPort *comPort;

	/* Required by BCSerio */
	extern char sltext[] asm ("sltext");
	extern char eltext[] asm ("eltext");
	extern char sldata[] asm ("sldata");
	extern char eldata[] asm ("eldata");
	_go32_dpmi_lock_code(sltext,eltext-sltext);
	_go32_dpmi_lock_data(sldata,eldata-sldata);

	comPort = sio_openport(com1, 3);
	sio_setparms(comPort, sio8Bits, sioNoParity, sio1StopBit);
	sio_setspeed(comPort, b2400);
	do {
	   if (sio_charready(comPort)) {
		c = sio_get(comPort);
		printf("%02X ",c);
		fflush(stdout);
	   }
	} while (!done);

	printf("Closing COM port...\n");
	sio_closeport(comPort);
	printf("Exiting...\n");
	return(0);
}
-- 
Scott Post    spost AT koptss03 DOT delcoelect DOT com

- Raw text -


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