public String getHexByteString ( CharSequence prefix , CharSequence separator , CharSequence suffix ) throws IOException { byte data [ ] = getBytes ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < data . length ; i ++ ) { if ( i > 0 ) sb . append ( separator ) ; int v = data [ i ] & 0xff ; if ( prefix != null ) sb . append ( prefix ) ; sb . append ( hexArray [ v >> 4 ] ) ; sb . append ( hexArray [ v & 0xf ] ) ; if ( suffix != null ) sb . append ( suffix ) ; } return sb . toString ( ) ; }
Get a HEX string representation of the bytes available in the serial data receive buffer