/**************************************************************************** FILE: rxChat.c AUTH: FSAE Wireless Data Aquisition Senior Sesign Project Igor Yudilevich DESC: Waits for a string to come in on the COM Port VER: 1.0 - April 5, 2002 ****************************************************************************/ #define COM_PORT 1 /* serial port number */ #define SPEED 19200L /* baud rate = 19200 */ #include /*#include /* required for the isalnum function */ /*#include */ /*#include */ /*#include */ /*#include */ #include "ibmcom3.h" /* for serial */ /* Prototypes */ void comm_setting(void); /* set com port */ void close_com(void); /* close com port */ int main(void) { char recieveChar; printf("Setting up serial port\n"); comm_setting(); /* initializing communication */ printf("Serial port initialized\n"); while (1) { if (kbhit()) /* exit by closing the port first */ { close_com(); printf("\nExiting . . .\n"); exit(0); } recieveChar = com_rx(); if (recieveChar != '\0') { printf("%c", recieveChar); } } return 0; } /***************************************************************************/ void comm_setting(void) { int errorCheck; errorCheck = com_install(COM_PORT); if (errorCheck != 0) { switch (errorCheck) { case 1: printf("Invaid port number!\n"); break; case 2: printf("No UART fot specified port!\n"); break; case 3: printf("Drivers already installed!\n"); break; default: printf("Error #%d\n", errorCheck); break; } exit(1); } com_raise_dtr(); com_set_speed(SPEED); com_set_parity(COM_NONE, STOP_BIT_1); } /***************************************************************************/ void close_com(void) { com_lower_dtr(); com_deinstall(); }