public abstract class BytestreamDataSource extends ContextualVehicleDataSource implements java.lang.Runnable
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.locks.ReadWriteLock |
mConnectionLock |
protected java.lang.String |
mDataFormatValue |
protected java.util.concurrent.locks.Condition |
mDeviceChanged |
protected static int |
RECONNECTION_ATTEMPT_WAIT_TIME_S |
protected static int |
SLOW_RECONNECTION_ATTEMPT_WAIT_TIME_S |
| Constructor and Description |
|---|
BytestreamDataSource(SourceCallback callback,
android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
connect()
Initiate a connection to the vehicle interface.
|
protected void |
connected()
Must have the connection lock before calling this function
|
protected abstract void |
disconnect()
Perform any cleanup necessary to disconnect from the interface.
|
protected void |
disconnected()
Must have the connection lock before calling this function
|
boolean |
isConnected()
Return true if the data source is actively connected to its target, be it
a USB endpoint, a Bluetooth channel, a trace file, etc.
|
protected boolean |
isRunning()
Returns true if this source should be running, or if it should die.
|
protected abstract int |
read(byte[] bytes)
Read data from the source into the given array.
|
void |
receive(VehicleMessage command) |
void |
run() |
protected void |
setFastPolling(boolean enabled) |
void |
start() |
void |
stop()
Clear the callback so no further updates are sent.
|
protected void |
stopConnectionAttempts() |
protected void |
waitForConnection()
If not already connected to the data source, initiate the connection and
block until ready to be read.
|
protected abstract boolean |
write(byte[] bytes) |
getContextgetCallback, getTag, handleMessage, onPipelineActivated, onPipelineDeactivated, setCallback, waitForCallbackprotected static final int RECONNECTION_ATTEMPT_WAIT_TIME_S
protected static final int SLOW_RECONNECTION_ATTEMPT_WAIT_TIME_S
protected final java.util.concurrent.locks.ReadWriteLock mConnectionLock
protected final java.util.concurrent.locks.Condition mDeviceChanged
protected java.lang.String mDataFormatValue
public BytestreamDataSource(SourceCallback callback, android.content.Context context)
public void start()
public void stop()
BaseVehicleDataSourcestop in interface VehicleDataSourcestop in class BaseVehicleDataSourceprotected void setFastPolling(boolean enabled)
protected void waitForConnection()
throws java.lang.InterruptedException
java.lang.InterruptedException - if the interrupted while blocked -- probably
shutting down.protected void stopConnectionAttempts()
public void run()
run in interface java.lang.Runnablepublic void receive(VehicleMessage command) throws DataSinkException
DataSinkExceptionpublic boolean isConnected()
VehicleDataSourceisConnected in interface VehicleDataSourceisConnected in class BaseVehicleDataSourceprotected void disconnected()
disconnected in class BaseVehicleDataSourceprotected void connected()
connected in class BaseVehicleDataSourceprotected boolean isRunning()
protected abstract int read(byte[] bytes)
throws java.io.IOException
bytes - the destination array for bytes from the data source.java.io.IOException - if the source is unexpectedly closed or returns an
error.protected abstract boolean write(byte[] bytes)
protected abstract void disconnect()
protected abstract void connect()
throws DataSourceException
DataSourceException