delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/30/07:53:10

Message-ID: <20000630115251.55963.qmail@hotmail.com>
X-Originating-IP: [200.50.95.142]
From: "kevin collymore" <spizard AT hotmail DOT com>
To: djgpp AT delorie DOT com
Subject: Interface between the pc and stamp2
Date: Fri, 30 Jun 2000 07:52:51 AST
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

Hello you all. I am kevin and I need your assistance with a project of mine. 
Normally, through trial and error, I would find the solutions to my 
programming problems but this time I am time restricted. You see, I wish to 
send bytes of data to the stamp2( a microprocessor chip) using the keyword 
outportb. The program to send the bytes of data via the RS-232 port is 
written in C++. The program for the stamp2 which will recieve the data is 
finished and tested. I am unfamilar with it, as a matter of fact, this is 
the first time I am ever using it. I have been browsing your mail archives 
and have found some interesting stuff but not what I need. Please help me 
out as soon as possible.  Thanks.
This is the code that I have written so far:

					   //Proram Function//
/*******************************HEADER 
FILES********************************/
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
//#include "digit.h"
/************************GLOBAL 
CONTANTS/VARIABLES**************************/
/**************************STRUCTURE 
DEFINITIONS****************************/
/***************************FUNCTION 
PROTOTYPES*****************************/
void Invalid();
void Instructions();
void Test_baord( char Test = 'o' );
void Clear_baord( char Clear = 'x' );
//int Edit_Board( char data );
/******************************PROGRAM 
MAIN*********************************/
int main()
{
	clrscr();				//Clear the screen
//Display introduction and menu of executable operations.
	cout << "\n\n\n\n\n\n\n\n\t\t  CRICKET BOARD TESTING PROGRAM OPERATIONAL"<< 
endl;
	delay( 3000 );			//Provide a 3 sec delay
	Instructions();		//Display menu
char choice, digit, data;     //declare variable
//Get character from keyboard and determine if user wishes to exit
while(( choice = getch() ) != 'X' )
{
switch( choice )    {
/*  case'R':clrscr();					//Clear the screen
		cout << "\nEnter digit to update then RETURN when sure." << endl;
		cout << "\n\n\n\n\n\t\t\t\t\tDigit:";
		digit = cin.get();
		Reset_digit( char );   		break;
  case'S':clrscr();					//Clear the screen
		cout << "\nEnter digit to update and number to display then RETURN when 
sure." << endl;
		cout << "\n\n\n\n\n\t\t\t\t\tDigit:";
		digit = cin.get();
		cout << "\n\n\n\n\n\t\t\t\t\tNumber:";
		data = cin.get();
		Set_digit( char, char );      break;
*/
  case'T':Test_baord( );				break;
  case'C':Clear_baord( );  			break;
/*  case'E':cout << "\nEnter runs made then RETURN when sure." << endl;
		cout << "\n\n\n\n\n\t\t\t\t\tRuns:";
		data = cin.get();
		Edit_Board( data );			break;  */
  default:Invalid();				break;
				}
	Instructions();		//Display menu
}
	clrscr();				//Clear the screen
//Display message conveying good wishes.
	printf( "\n\n\n\\n\n\t\t   I hope your tests were successfull. " );
	delay( 3000 );			//Provide a 3 sec delay
	printf( "\n\n\n\n\n\n\n\t\t\t\t  GOODBYE." );
	delay( 3000 );			//Provide a 3 sec delay
//Terminate program
	return 0;
}
/***************************FUNCTION 
DEFINITIONS****************************/
void invalid()
{
for( int i = 0 ; i < 5 ; i++ )
{
	clrscr();
	delay( 300 );
	cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tINVALID KEY!" << endl;
	delay( 300 );
}
}
void Instructions()
{
	clrscr();
	cout << "\\n\n\n\n\n\n\n\n\n\t\t\t  Press S to Set a digit"
		<< "\n\n\t\t\t\tR to Reset a digit"
		<< "\n\n\t\t\t\tT to Test the board"
		<< "\n\n\t\t\t\tC to clear board"
		<< "\n\n\t\t\t    and X to eXit this program"	<< endl;
}
void Test_baord( char Test )
{
	clrscr();				//Clear the screen
//Display current operation.
	cout << "\nTesting the Cricket scoreboard digits." << endl;
	delay( 3000 );			//Provide a 3 sec delay
	cout << "you have passed " << Test << endl;
	delay( 3000 );			//Provide a 3 sec delay
//	Reset_digit( Test );
}
void Clear_baord( char Clear )
{
	clrscr();				//Clear the screen
//Display current operation.
	cout << "\nResetting the Cricket scoreboard digits." << endl;
	delay( 3000 );			//Provide a 3 sec delay
	cout << "you have passed " << Clear << endl;
	delay( 3000 );			//Provide a 3 sec delay
//	Reset_digit( Clear );
}

//************************DIGIT.H************************************//
//Program tests the "outportb" keyword
/**************************HEADER FILES********************************/
#include <iostream.h>
#include <stdio.h>
#include <dos.h>
/*****************GLOBAL VARAIBLES+DEFINED ENTITIES********************/
//int port = 1016;  //port address of comm1 in decimal
int port = 0x3f8;  //port address of comm1 in hex
char START = '[';  //Special character that will tell the stamp to start 
reading
char STOP = ']';   //Special character that will tell the stamp to stop 
reading
/***************************FUNCTION DEFINITIONS************************/
void Reset_digit( char digit )
{
	outportb( port , START );
	outportb( port , digit );
	outportb( port , STOP );
}/*
void Set_digit( char digit, char data )
{
	outportb( port , START );
	outportb( port , digit );
	outportb( port , data );
	outportb( port , STOP );

}  */
/****************************PROGRAM MAIN******************************/
int main()
{
cout << "\nEnter character to be transmitted over the serial line: " << 
endl;
Reset_digit( cin.get() );
cout << "\neND";
//Terminate program
	return 0;
}


PS: I will start trying to correct my digit. h that I will send after 
reading some of the helpful letters you have as I like to help myself. Hear 
from you soon.
Kelvin.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

- Raw text -


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