delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/08/13/07:23:56

Message-ID: <15398F0C38D6D411AC8A00B0D03D919E694E36@MAESTRO>
From: John Bond <Jbond AT musictele DOT com>
To: djgpp AT delorie DOT com
Subject: Problem with bioscom() when using HyperTerm at 9600 7bits even pa
rity and 2 stop bits
Date: Tue, 13 Aug 2002 06:23:39 -0400
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)
Reply-To: djgpp AT delorie DOT com

HELP!?!?!

I've been using DJGPP for all sorts of low level board testing (great PCI
access and good speed).

Now I would like to connect to a serial device to input signals into my
boards to test them...

I decided to use bioscom().  Below is a program that is a rough terminal.
When connected to HyperTerm with a null modem with both set to 9600 baud, 7
data bits, 2 stop bits and even parity, half of the characters come out
wrong.  I tried odd parity and it also had half of the chars perverted...

The program works fine with 8N1 connected to Hyper Term (similarly
configured).  HEEEEELP!!!
-John Bond

**********************************beginning of
code*********************************************************
//BiosTerm.cpp -- test of bioscom() function in DJGPP
//created 8/13/2002 by John Bond for a quick fix test, bug test on 9600 and
7E2

#include <stdio.h>
#include <pc.h> //required for kbhit()
#include <conio.h> //required for getch() and putch() (and puts() )
#include <bios.h>
//#include "Timers.h"

void CheckBiosReturn(int iCmd, int iRet)
{
	//at present this is just semi-active documentation of the return
bits
//	bool bCTSChange = (0x1 & iRet) !=0;
//	bool bDSRChange = (0x2 & iRet) !=0;
//	bool bRingChange = (0x4 & iRet) !=0;
//	bool bCarrierDetectChange = (0x8 & iRet) !=0;
//	bool bCTSPresent = (0x10 & iRet) !=0;
//	bool bDSRPresent = (0x20 & iRet) !=0;
//	bool bRingPresent = (0x40 & iRet) !=0;
//	bool bCarrierPresent = (0x80 & iRet) !=0;
//	bool bDataReady = (0x100 & iRet) !=0;
//	bool bOverRunError = (0x200 & iRet) !=0;
//	bool bParityError = (0x400 & iRet) !=0;
//	bool bFramingError = (0x800 & iRet) !=0;
//	bool bBreakDetected = (0x1000 & iRet) !=0;
//	bool bXmitHoldingRegEmpty = (0x2000 & iRet) !=0;
//	bool bXmitShiftRegEmpty = (0x4000 & iRet) !=0;
//	bool bTimeOutError = (0x8000 & iRet) !=0; //error for iCmd==1 or 2
} //CheckBiosReturn

int main(int argc, char *argv[])
{
//Test program to demonstrate/determine the usage of the bioscom() function
of DJGPP
	//int  bioscom(int _cmd, char _data, int _port);
	const int iPortInit = 0;
	const int iPortWrite = 1;
	const int iPortRead = 2;
	const int iPortGetStat = 3;

	const char cBaudBitsParityStop = 0xfe; /*9600, 7bits, even parity,
and 2 stop bits*/

	const int iComPort = 0; //0-Com1, 1-Com2, etc.

	const bool bEchoKeys = true;

	int iBiosReturn;

	//Initialize the (RS-232) Communications Port
	iBiosReturn = bioscom(iPortInit, cBaudBitsParityStop, iComPort);
	CheckBiosReturn(iPortInit, iBiosReturn);

	//let user know that program has started
	puts("Ready");

	//Terminal loop -- effectively connects the console to the serial
port...
	bool disconnect = false;
	while(!disconnect)
	{
		if(kbhit())
		{
		//get key from keyboard and send to the serial port
			int ch=getch();
			if (ch==0)
			{
				getch(); //throw away extended key strokes
			}
			else
			{
				if(bEchoKeys)
				{
					putch(ch); //echo the char to the
screen
				}
				iBiosReturn = bioscom(iPortWrite, char(ch),
iComPort); //write key to serial port
				CheckBiosReturn(iPortWrite, iBiosReturn);
			}
		}

		//get character from the serial port and send to the screen
		iBiosReturn = bioscom(iPortGetStat, cBaudBitsParityStop,
iComPort);
		CheckBiosReturn(iPortGetStat, iBiosReturn);
		if(iBiosReturn & 0x100) //if dataready
		{
			iBiosReturn = bioscom(iPortRead,
cBaudBitsParityStop, iComPort);
			CheckBiosReturn(iPortRead, iBiosReturn);
			switch(iBiosReturn&0xff)
			{
			case 12: //form feed, control L
				for(int i=0; i<25; i++)
					puts("");
				break;
			default:
				putch(iBiosReturn&0xff);
				break;
			}
		}
	} //while !disconnect

	//abandon the port, there is no close or de-initialize function
	return 0;
} //main of BiosTerm.cpp
**********************************************************end of
code************************************************************************

John Bond, Music Telecom, Inc., Corporate Park III, 
580 Howard Ave., Somerset, NJ 08873
Tel: 732.469.0880  Fax: 732.469.2298 jbond AT musictelecom DOT com

Subscribe to our monthly newsletter, "The Monitor", for the latest news and
product information at www.musictelecom.com, or send a blank message to:
mailto:join-themonitor AT list DOT musictele DOT com. 


- Raw text -


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