# UartDeviceCallback

# UartDeviceCallback

`
public


interface
UartDeviceCallback
`  
`


`

|--------------------------------------------------|
| com.google.android.things.pio.UartDeviceCallback |

<br />

*** ** * ** ***

UART interrupt callback.

Call[registerUartDeviceCallback(Handler, UartDeviceCallback)](https://developer.android.com/reference/com/google/android/things/pio/UartDevice#registerUartDeviceCallback(android.os.Handler, com.google.android.things.pio.UartDeviceCallback))to start getting callbacks.

## Summary

|                                                                                                                                                                                     ### Public methods                                                                                                                                                                                     ||
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract boolean` | ` `[onUartDeviceDataAvailable](https://developer.android.com/reference/com/google/android/things/pio/UartDeviceCallback#onUartDeviceDataAvailable(com.google.android.things.pio.UartDevice))`(`[UartDevice](https://developer.android.com/reference/com/google/android/things/pio/UartDevice)` uart) ` Called when data is ready to be read from the UART.            |
| ` default void`     | ` `[onUartDeviceError](https://developer.android.com/reference/com/google/android/things/pio/UartDeviceCallback#onUartDeviceError(com.google.android.things.pio.UartDevice, int))`(`[UartDevice](https://developer.android.com/reference/com/google/android/things/pio/UartDevice)` uart, int error) ` Called when an error occurs with the interrupt event listener. |

## Public methods

### onUartDeviceDataAvailable

```
boolean onUartDeviceDataAvailable (UartDevice uart)
```

Called when data is ready to be read from the UART.

<br />

|                            Parameters                            ||
|--------|----------------------------------------------------------|
| `uart` | `UartDevice`: The UartDevice that has data ready. <br /> |

|                              Returns                               ||
|-----------|---------------------------------------------------------|
| `boolean` | True to keep watching for events, false to stop. <br /> |

### onUartDeviceError

```
void onUartDeviceError (UartDevice uart, 
                int error)
```

Called when an error occurs with the interrupt event listener. At this point the receiver should assume that this UART is no longer usable. No further callbacks will be received on this object.

<br />

|                                                         Parameters                                                         ||
|---------|-------------------------------------------------------------------------------------------------------------------|
| `uart`  | `UartDevice`: The UartDevice that received an error. <br />                                                       |
| `error` | `int`: An[OsConstants](https://developer.android.com/reference/android/system/OsConstants.html)errno code. <br /> |

-

  ## Interfaces

  - [Gpio](https://developer.android.com/reference/com/google/android/things/pio/Gpio)
  - [GpioCallback](https://developer.android.com/reference/com/google/android/things/pio/GpioCallback)
  - [I2cDevice](https://developer.android.com/reference/com/google/android/things/pio/I2cDevice)
  - [Pwm](https://developer.android.com/reference/com/google/android/things/pio/Pwm)
  - [SpiDevice](https://developer.android.com/reference/com/google/android/things/pio/SpiDevice)
  - [UartDevice](https://developer.android.com/reference/com/google/android/things/pio/UartDevice)
  - [UartDeviceCallback](https://developer.android.com/reference/com/google/android/things/pio/UartDeviceCallback)
-

  ## Classes

  - [PeripheralManager](https://developer.android.com/reference/com/google/android/things/pio/PeripheralManager)