delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/03/18/05:00:11

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Dr Green <drgreen27_no AT spam_hotmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: any help with com port routines, please?
Message-ID: <embb9ugb5e4hvkg7puugclhucgi69to7ca@4ax.com>
X-Newsreader: Forte Agent 1.9/32.560
MIME-Version: 1.0
Lines: 155
NNTP-Posting-Date: Mon, 18 Mar 2002 03:09:33 CST
Organization: Giganews.Com - Premium News Outsourcing
X-Trace: sv3-5F9I5SIuQrja1gqQ9SYjhj2+sZEqEyBI9Dg0j9Atfp2+/jqH224ieuZPGE/012gFMsYmYB0Ihy8b5ZC!814FfCVauVBtd3Ksf6hClNVZkC2W4TIsSrgyt1qO+RERG7JbyuXybkAcTA/tpOymJHo=
X-Complaints-To: abuse AT GigaNews DOT Com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
Date: Mon, 18 Mar 2002 09:09:33 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello all.   I've also posted this to the msdos.programmer newsgroup,
with no response.  I was just hoping someone here might recognize some
of this code and be able to help me out.  Thanx!

I have a program that controls a sports scoreboard.  The program was
written 9 years ago by a since-extinct person.  The scoreboard was
also built by this person, so it probably doesn't follow any protocol
standards.

In a recent tragedy, we lost the program.  But we managed to find the
source to an older version.  I need to compile it, and would prefer to
rewrite it in windows.

Problem:
I do not have the compiler or libraries that this was built with.  I
do not know enough about the com functions of old (talking directly
with the chips on the comport card).
I've tried using watcom c 11.0c with _bios_serialcom() but that just
hangs the machine.  

I humbly beg of you... if any of you can help me interpret this code
and/or rewrite it to use libraries that are currently available (ie.
watcom or even ms c++/vb), i would most appreciative.

thanx,
dr green

Here is the routines in question:


/*********************Update Scoreboard*****************************/
void UpdateScoreBoard(void)
   {
    unsigned val, ads;

	/* each digit is it's own item */

	   val = ( ClockMin / 10 ) % 10;

	/* i'm assuming this is some address in the memory on the
scoreboard chip, but who knows... */

	   ads = 0 + 0xC100;

	   if(val==0)
		   val=15;

	   dbpoke(ads,1,val);

	   val = ClockMin % 10;
	   ads = 1 + 0xC100;

	   if(val==0)
		   val=15;

	   dbpoke(ads,1,val);

/* etc... */
}


/*
	write "count" words from "buffer" to address "address" in the
	remote data base over the rs232 bus.  returns "0" if no error
	else "1".  does a read after write verify.
*/

int dbpoke(unsigned address, unsigned count, unsigned buffer[])
   {
   unsigned tbuff[64];
   int i, j;


	flush(port);

   for(j=0; j<1; ++j)
       {
       for(i=0; i<count; ++i)
           sendblk(0x00, HB(address + 2*i), LB(address + 2*i),
buffer[i]);
       }

   return(1);
   }

/*********rs232drv.c********/

#define  DBASE		0x06		/* =60,000 */
#define  IBLKDLY	  -4		/* hunderdths secs   */


void sendblk(int db1, int db2, int db3, int db4)
   {
   if (db1 == 0xff)
       {
		flush(port);
	   	rs232_out(port, 0xf0);
	   	rs232_out(port, DBASE);
		rs232_out(port, db2);
		rs232_out(port, db3);
	   	rs232_out(port, db4);
   	rs232_out(port, 0xf0^DBASE^db2^db3^db4);
       }

	if (db1 == 0x00)
       {
	   	rs232_out(port, 0x0f);
   	rs232_out(port, DBASE);
		rs232_out(port, db2);
		rs232_out(port, db3);
  		rs232_out(port, 1);
		rs232_out(port, HB(db4));
		rs232_out(port, LB(db4));
  		rs232_out(port, 0x0f^DBASE^db2^db3^1^HB(db4)^LB(db4));
       }

/*   Delay(IBLKDLY);*/
   }

/*
	RS232 write
*/

int rs232_out(int port, char data)
  {
	int rx;

/*
	wait for tbe
	clear DLAB for THR access
	tramsmit data
*/

	if (port == COM1)
	  {
		while (((rx = inportb(LSR1)) & 0x20) == 0)
			;
		outportb(LCR1, inportb(LCR1) & 0x7f);
		outportb(THR1, data);
	  }


	if (port == COM2)
	  {
		while (((rx = inportb(LSR2)) & 0x20) == 0)
			;
		outportb(LCR2, inportb(LCR2) & 0x7f);
		outportb(THR2, data);
	  }

	return(rx<<8 | data);
  }

/****END of sample ****/

- Raw text -


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