VanGo
High-Rate Data Acquisition System
»Home
»Download
»Install
»Brief Intro
System Overview

FragmentM

The Fragmenter is used to break large SampleSets into smaller SampleSets. The Fragmenter, when used, sits just after the Sampler. The Fragmenters sole job is to make sure that the Sampler uses the SampleSet buffer as efficiently as possible.

Note The Fragmenter should be placed right after the Sampler.

Since BufferPool has only fixed size buffers to work with, SampleSet data buffers are fixed as well. To reduce the number of times the DMA is restarted, the buffer size should be as big as possible; however, a packet can hold only a relatively small amount of data especially when no compression is used. To increase the number of ADC readings a DMA can collect per buffer and to satisfy the packet size limit, the Fragmenter increases the data buffer size and splits the SampleSet into two before passing the SampleSet to the rest of the filters.

The Fragmenter works by increasing the size of the data buffer by discrete multiples when the SingelFilter bufferSize interface SampleSet calculation is taking place. The Fragmenter determines the discrete multiple by looking at the size of the data buffer the previous filter needs and comparing that to the maximum buffer the BufferPool can provide. At run-time, the Fragmenter takes the large SampleSets and breaks them up into smaller SampleSets as requested by the previous filter in the chain.

The Fragmenter, as currently implemented, uses the SampleSet SampleSet.newFragment function to split up the larger SampleSet. The SampleSet implementation of newFragment allocates a new buffer for each new fragment. This can result in wasted memory because the allocated buffers will most likely fall into the largest buffer category out of the three buffers BufferPool has to choose from, but the SampleSet data will not fill up the buffer completely.

AdpcmM

Note of caution: the ADPCM compression algorithm is lossy. Specifically, if the data being collected has momentary spikes, the compression can down play the actual size of the spike. Check to make sure the losses due to the ADPCM algorithm are tolerable before relying on the compressor.

Packetizer

The Packetizer is responsible for packetizing the SampleSet, enqueueing it into a queue before it is sent over the radio, and deleting the SampleSet when it is no longer needed. Before a SampleSet is packetized, the Packetizer first checks whether the SampleSet needs to be sent. Each SampleSet has a flags variable; one of the bits in this variable indicates whether the SampleSet is interesting and should be set over the radio or not interesting and should be deleted.

Note The Packetizer should be placed at the end of the filter chain.

The packetization is not built into the Packetizer, but into the SampleSetM library. The SampleSet header is marshaled acording to the user defined send_mask. This marshaling is provided so that entries in the SampleSet header not interesting to the user will not be sent over the radio. This marshaling reduces the size of the header and allows more room for data. The send_mask is defined in the SnackConstants.h file. The list of available flags that can be set in send_mask is in the transmission_mask_t enumeration defined in the MotephonesTypes.h file.

Example: vango/apps/AuricleDemo2/SnackConstants.h
#define FastSamplerM____sendMask (SEND_SOURCE | SEND_FORMAT | SEND_RATE |
                                  SEND_SAMPLE_NUMBER | SEND_SAMPLE_COUNT |
                                  SEND_MEAN | SEND_MD)

SampleSetM marshals the packets by scanning the SampleSet and building a packet header by including only those SampleSet variables defined in the send_mask. First, SampleSetM allocates a buffer the size of the packet header (calculated using the SampleSet's send_mask) plus the size of the data and attributes. The buffer is then sequentially filled with SampleSet data structure variables only if they are set in the send_mask. After the header is built, all of the attributes are attached to the buffer after the marshaled header. Finally, the data is copied into the rest of the buffer. The buffer is then attached to a TinyOS packet header and placed into a queue ready to be sent. The queue works like the Sampler queue, sending packets to the radio only when the radio is ready to send packets.