On the example code you'll see a variable (array) called dataAcquired
, where the data acquired from the device is stored. That variable belongs to class Frame
, which has as member variables CRC
After the line dataAcquired = device.read(...);
on the example, the variable will be populated will all the frames sent by the device. You can use for example System.out.println(...)
to output to the content of each member variable console:https://www.google.com/search?client=safari&rls=en&q=system.out.println&ie=UTF-8&oe=UTF-8
Note that since dataAcquired
is an array, it needs to be indexed (e.g. System.out.println(dataAcquired.seq)
) should output the sequence number of the first frame).
If you want to print all the frames, you need to put the System.out.println(...)
statements inside a loop (e.g. a for
) that runs from index 0 to the length of dataAcquired
Furthermore, the analog
members of dataAcquired
are arrays as well, which means that to print all the channels you'll need an additional loop running from 0 to the length of each (e.g. System.out.println(dataAcquired.analog)
only prints analog input A1 from the first frame).
Another important aspect to consider is that the example is reading a single batch of frames from the device; after the frames are retrieved the devices will stop the acquisition (as programmed from the calls to device.stop()
To keep acquiring frames the dataAcquired = device.read(...);
(and related parts of code you want to be done repeatedly with the frames; e.g. outputting to the console) need to be placed inside a loop.
Given that the device is streaming data in real time, if the operations you place after the dataAcquired = device.read(...);
statement take too long (e.g. outputting to the console), the device will not be able to dispatch all the frames at the expected rate and automatically stop acquisition.
Should you experience this issue, a few workarounds are to optimize the code base to take less time, ask more frames in each call to device.read(...)
, use a lower sampling rate and/or a combination of all these factors.
Our suggestion is that you take this one step at the time. Try first to adapt the example to just output a single batch of frames to the console and work your way from there.
Hope you found this information useful... in case you have any further questions where our support may be of added value just let us know; we'll do our best to support.
The BITalino Team