beautypg.com

Sending a message, Reading analog input scan data, Supported messages – Measurement Computing DAQFlex for Android Quick Start User Manual

Page 5

background image

Sending a Message

5

During the normal Android activity lifecycle, the activity may be destroyed any time after the

onPause()

callback. If you created the

DaqDevice

object inside of the activity, the

DaqDevice

object is also destroyed.

Make sure to call the

close()

method during the activity

onPause()

method.

Managing the activity lifecycle is particularly important when running scan operations. Because the

DaqDevice

object may get destroyed by the activity, stop any active scan operations before calling the

DaqDevice

close()

method.

If a scan must continue while the application is paused, start an Android Service to hold the

DaqDevice

object

and to keep it open in the background. Failure to do so will result in a buffer overrun and data loss.

Sending a Message

After the device has permission and is opened, you can start sending messages to the device. Call the

DAQDevice

sendMessage()

method. The

sendMessage()

method accepts a string command to send to the

device.

For documentation on the DAQFlex command format, refer to the DAQFlex Software Help for the desktop API
at

www.mccdaq.com/pdfs/manuals/DAQFlex Software.pdf

and the Supported Messages section in this

document.

Reading Analog Input Scan Data

Tablet CPU limitations affect the sampling rate

Analog input scans do not run at full speed for all devices due to tablet CPU limitations. Using minimal display
code on a low-end tablet, a maximum of 150 kS/s aggregate was achieved using this API with USB-1608G
Series devices.

After sending an

AISCAN:START

message, scan data is read with the

readScanData()

method. Data is

returned as a

double[][]

data type, with the channel number as the first dimension and the sample number as

the second. This method is overloaded so that if no arguments are passed to the method, the method returns all
available data. Passing the number of samples and timeout only returns that number of samples.

Supported Messages

DAQFlex for Android supports the following messages. Refer to the DAQFlex Software Help for the desktop
API at

www.mccdaq.com/pdfs/manuals/DAQFlex Software.pdf

for more detailed information on these

messages.

If a message from subsequent DAQFlex releases is not in the following table, or if a supported message returns
an unknown status, that message may or may not function correctly.

Component

Properties

DEV

FLASHLED, FPGACFG, FPGAV, FWV, ID, MFGCAL, MFGSER, RESET, STATUS/ISO,
TEMP

AI

CAL, CHMODE, CJC, DATARATE, OFFSET, RANGE, RES, SCALE, SENSOR, SLOPE,
STATUS, VALUE

*

AISCAN

*

BURSTMODE, CAL, COUNT, HIGHCHAN, LOWCHAN, RANGE, RATE, RESET,
SAMPLES, SCALE, START, STATUS, STOP, XFRMODE

AO

OFFSET, RANGE, REG, RES, SCALE, SLOPE, UPDATE, VALUE

CTR

START, STOP, VALUE

DIO

DIR, LATCH, VALUE

TMR

DELAY, DUTYCYCLE, IDLESTATE, PERIOD, PULSECOUNT, START, STOP

*Temperature channels are not currently supported during an

AISCAN

. Temperature channels can be read with

the single-point

AI:VALUE

message.