// serial_read.c : implementation file #include "Main.h" /* This program requires HyperTerminal or similar we hope to add the ability to send text to the terminal soon just set the buad 115,200 */ void serial_read ( void ) { unsigned char byteswaiting; unsigned char byte; unsigned char x = 0; byteswaiting = GetSerialPort1ByteCount( ); // How Many Bytes in the Buffer PrintToScreen("Bytes Waiting %2d\n\r", byteswaiting); // Print How Many Bytes are Waiting PrintToScreen ( "\n\r" ) ; // Skip a line in terminal Wait ( 100 ) ; // Print Every 100ms if ( byteswaiting == 4 ) //If 4 Bytes are waiting run FOR Loop { PrintToScreen ( "Output: " ) ; // Print "Output:" to screen for ( x = byteswaiting ; x != 0 ; x-- ) // set "byteswaiting" to "x" { byte = ReadSerialPortOne( ); // Read Serial Port 1 byte at a time if ( byte == 13 ) // Byte 13 is the enter key { PrintToScreen ( "\n\r" ) ; // Skip a line in terminal PrintToScreen ( "Output: " ) ; // Print Output Line } else // if the enter key isn't pressed { PrintToScreen ( " %d " , byte ) ; // Print to Screen the ASCII byte } } PrintToScreen ( "\n\r\n\r" ) ; // Skip two lines in terminal Wait ( 2000 ) ; // Print Every 2 Seconds } }