|
Re: Does reading from the serial port work?
Here you go this is the basics. If you want it to echo the actual character used use WriteSerialPortOne(unsigned char). Other wise you get the ascii byte code. If you compare byte == "X" for instance it will work.
EDIT: DON'T USE THIS, IT DOESN'T WORK, I WAS A DOLT! SEE BELOW
Code:
void main ( void )
{
unsigned char byteswaiting;
unsigned char byte;
unsigned char x;
while ( 1 )
{
byteswaiting = GetSerialPort1ByteCount( );
if ( byteswaiting != 0 )
{
PrintToScreen ( "Output: " ) ;
for ( x = 0 ; byteswaiting == x ; x++ )
{
byte = ReadSerialPortOne( );
if ( byte == 13 )
{
PrintToScreen ( "\n" ) ;
}
else
{
PrintToScreen ( "%d" , byte ) ;
}
}
}
}
}
__________________
FIRST Team 501 PowerKnights - Mentor
FIRST Team 40 Checkmate - Mentor Alum
FIRST Team 146 Blue Lightning - Alumni
Last edited by Kingofl337 : 28-01-2008 at 16:09.
|