Code:
for ( x = 0 ; byteswaiting == x ; x++ )
This for line contains no magic I just threw this together in a rush. I'm not going to lie to you Alan, while I'm an ok programmer most of what I know has been through trial and error, research PID for instance and web programming html/php/cgi. I just bought a Microchip PIC kit to learn more about the lower lever programming.
In PrintToScreen %d does expect a integer, I've never had a issue using %d with int or char without casting data types. I have have had problems with mixing data types for instance %ld with a int or %d with long.
My function is in main() because that was the only function of the whole program. I wrote it in VEX without a competition template in FRC it's called a Standalone Project in the File menu.
I had a hard time making it work and Brad sent me a program like a year
ago to me and this is how it worked for the most part.
1.) Call GetSerialPort1ByteCount( ) to see if there are any bytes waiting in the buffer.
Code:
byteswaiting = GetSerialPort1ByteCount( );
if ( byteswaiting != 0 )
2.) Create a for loop to empty out the buffer and load it into a array, struct,
or
single variable
Code:
for ( x = 0 ; byteswaiting == x ; x++ )
{
byte = ReadSerialPortOne( );
3.) Do as you will with the data you just received
In this case check for return or print the ASCII code for the keypressed