File: ReadStream.nc

package info (click to toggle)
tinyos 2.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 47,476 kB
  • ctags: 36,607
  • sloc: ansic: 63,646; cpp: 14,974; java: 10,358; python: 5,215; makefile: 1,724; sh: 902; asm: 597; xml: 392; perl: 74; awk: 46
file content (104 lines) | stat: -rw-r--r-- 4,422 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * Copyright (c) 2005 Arch Rock Corporation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the
 *   distribution.
 * - Neither the name of the Arch Rock Corporation nor the names of
 *   its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
 * ARCHED ROCK OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE
 *
 */

/**
 * The ReadStream interface is intended for buffered high data rate
 * reading, usually from sensor devices. The type of the values being
 * read is given as a template argument. 
 *
 * <p> To use this interface, allocate one or more buffers in your own
 * space. Then, call postBuffer to pass these buffers into the
 * device. Call read() to begin the sampling process. The buffers will
 * be filled in the order originally posted, and a bufferDone() event
 * will be signaled once each buffer has been filled with data. At any
 * time while the read() is running, you may post new buffers to be
 * filled. If the lower layer finishes signaling readDone() and then
 * finds that no more buffers have been posted, it will consider the
 * read to be finished, and signal readDone(). 
 *
 * <p>
 * See TEP114 - SIDs: Source and Sink Independent Drivers for details.
 * 
 * @param val_t the type of the object that will be returned
 *
 * @author Gilman Tolle <gtolle@archrock.com>
 * @version $Revision: 1.5 $ $Date: 2008-06-04 03:00:31 $
 */

interface ReadStream<val_t> {
  /**
   * Passes a buffer to the device, and indicates how many values
   * should be placed into the buffer. Make sure your count doesn't
   * overrun the buffer.
   *
   * @param 'val_t* COUNT(count) buf' a pointer to the buffer
   * @param count the number of values the buffer should hold
   *
   * @return SUCCESS if the post was successful
   */
  command error_t postBuffer(val_t* buf, uint16_t count);

  /**
   * Directs the device to start filling buffers by sampling with the
   * specified period. 
   * 
   * @param usPeriod the between-sample period in microseconds
   * 
   * @return SUCCESS if the reading process began
   */
  command error_t read(uint32_t usPeriod);

  /**
   * Signalled when a previously posted buffer has been filled by the
   * device. In the event of a read error, result will not equal
   * SUCCESS, and the buffer will be filled with zeroes.
   *
   * @param result SUCCESS if the buffer was filled without errors
   * @param 'val_t* COUNT(count) buf' a pointer to the buffer that has been filled
   * @param count the number of values actually read
   */
  event void bufferDone(error_t result, 
			 val_t* buf, uint16_t count);

  /**
   * Signalled when a buffer has been filled but no more buffers have
   * been posted. In the event of a read error, all previously posted
   * buffers will have their bufferDone() event signalled, and then
   * this event will be signalled with a non-SUCCESS argument.
   *
   * @param result SUCCESS if all buffers were filled without errors
   * @param usActualPeriod Actual sampling period used - may be different
   *   from period requested at read time. Undefined if result != SUCCESS.
   */
  event void readDone(error_t result, uint32_t usActualPeriod);
}