byteAvailable
RL41
Posts: 1
The Uart.byteAvailable() method is not working as I expected.· My code is something like this (though I don't have it in front of me and so can't copy verbatim):
while( true ) {
· if( rxUart.byteAvailable() ) {
··· c = rxUart.receiveByte();
··· System.out.println( c );
· }
}
The observed result of this is a long string of zeros when there is no data being transmitted.· The expected effect would be that nothing is printed when no data is transmitted.· Why the difference?· Thanks.
while( true ) {
· if( rxUart.byteAvailable() ) {
··· c = rxUart.receiveByte();
··· System.out.println( c );
· }
}
The observed result of this is a long string of zeros when there is no data being transmitted.· The expected effect would be that nothing is printed when no data is transmitted.· Why the difference?· Thanks.
Comments
Connect a 10k pullup or pulldown resistor to that pin
or connect that pin to a rs232 level driver like max232.
That stops the pin from floating and picking up noise.
regards peter