int read()
Throws:
int read(byte[] buf)
Throws:
int read(byte[] buf, int offset, int len)
Throws:
_INSERT_METHOD_SIGNATURE_HERE_
Description:
read() method:
Returns | Description |
---|---|
value | a single byte |
The read() method returns one single byte or -1 if nothing was read.
read(byte[] buf) method:
Parameter | Description |
---|---|
buf | array storing the returned data |
The read(byte[]) method reads data from the UART RX buffer. The first parameter buf is used to return the received data bytes in an array of bytes. The number of data bytes to be read at once are specified by the buf.length parameter. This method returns the number of bytes read from the RX buffer.
Returns | Description |
---|---|
value | number of returned bytes |
read(byte[] buf, int offset, int len) method:
Parameter | Description |
---|---|
buf | array storing the returned data |
offset | offset of bytes |
len | count of bytes |
The read(byte[], int, int) method reads data from the UART RX buffer. The first parameter buf is used to return the received data bytes in an array of bytes. The number of data bytes to be read at once are specified by the len parameter. The offset paramter specifies the offest to the first byte in the buf array. This method returns the number of bytes read from the RX buffer.
Returns | Description |
---|---|
value | number of returned bytes |
Example
try
{
retCnt = uart.read(rxData);
}
catch (CommStateException ise)
{
Console.println("error: " + ise);
int numberOfOverrieddenBytes = uart.getNumberOfOverriddenBytes();
if (numberOfOverrieddenBytes != 0)
{
Console.print("Buffer overflow, number of overriden bytes: "
+ numberOfOverrieddenBytes + " - data: ");
for (int i = 0; i < uart.getNumberOfBytesRead(); i++)
Console.print("" + (char)rxData[i]);
Console.println("");
}
}
Note
See also:
Copyright © demmel products gmbh. All rights reserved.